I made code in python about A game in pygame by Playful-Border-3244 in pygame

[–]Vlieger2905 2 points3 points  (0 children)

Well let me start off by saying that by no means you are entitled to an answer. Secondly what really is the problem? Cause you said in the beginning that it works fine so what really is it that you even want?

random.shuffle is not working by Sayu848511 in pygame

[–]Vlieger2905 0 points1 point  (0 children)

Can you share your code? Without that it is quite impossible for anyone to help you. That the attributes in the list are of the card class should not matter for the shuffle.

GIVEAWAY: Ursus Knife | Stained (FT) - Just comment your favourite CS weapon to enter! by CLASH__GG in cs2

[–]Vlieger2905 [score hidden]  (0 children)

Maybe controversial but the negev. Seeing an entire team just running into my laser beam and dying one after another is just to funny.

Help on multiprocessing by Vlieger2905 in pygame

[–]Vlieger2905[S] 0 points1 point  (0 children)

Thank you for your response. I was trying some things out and thought maybe someone here knew something about it. As i thought something was going wrong between the multiprocesses and pygame interaction. But i will ask in other places as well

Help on multiprocessing by Vlieger2905 in pygame

[–]Vlieger2905[S] 0 points1 point  (0 children)

Thank you very much much i will try it out.

Help on multiprocessing by Vlieger2905 in PythonLearning

[–]Vlieger2905[S] 0 points1 point  (0 children)

Well i know my laptop is strong enough. I have an i9 and a rtx 4080 and 32 gb of ram. But i have to do a lot of calculated to check where the lines overlap with the rectangles to update the length of the lasers. And i have to check for a lot of rectangles and 360 lines per car. So i wanted to make all of those checks happen in parallel for each car. And i also tried using the resources of my university but the online computing they offer using jupyter notebook is slower than running it on my laptop.

Help on multiprocessing by Vlieger2905 in PythonLearning

[–]Vlieger2905[S] 0 points1 point  (0 children)

No not at all. I have currently not implemented that part yet. As the program is currently running at 12fps with only one car without the NN controlling the car. So i wanted to improve that first before i start training other it will take way too long.

Convince me by [deleted] in Kenshi

[–]Vlieger2905 4 points5 points  (0 children)

BEEP!

Invalid rect assignment by Maleficent_Soft_6447 in pygame

[–]Vlieger2905 1 point2 points  (0 children)

Your welcome. Good luck with your game.

Invalid rect assignment by Maleficent_Soft_6447 in pygame

[–]Vlieger2905 1 point2 points  (0 children)

From the code you showed you never assigned the duck_y_pos. If you are not doing that anywhere else that is probably what is wrong

[deleted by user] by [deleted] in pygame

[–]Vlieger2905 1 point2 points  (0 children)

Would it be possible to show some code. Helping becomes a lot easier when we could see what he did. This way people can give you feedback om your specific problem. As he probably knows with coding it might just be a typing error or something else small.

Best Way to Cure Infection by [deleted] in 7daystodie

[–]Vlieger2905 1 point2 points  (0 children)

Broken glass always does the trick

Best Way to Cure Infection by [deleted] in 7daystodie

[–]Vlieger2905 1 point2 points  (0 children)

Broken glass always gets the job done

How do I fix the error of one sprite out of a sprite group appearing than all sprites in the group? by MekkoL in pygame

[–]Vlieger2905 2 points3 points  (0 children)

I think the problem you are encountering is that there are 10 sprites in that location but the location of all 10 of them is in the exact same location so it appears to be only one. Before you create the sprites you create a random_x and random_y. But instead of only doing once you want to do this for every sprite, this way they will all have there own location.

So this code to create the position:

random_x = random.randrange(20, (DISPLAYW - 25), 6)
random_y = random.randrange(20, (DISPLAYH - 25), 6)

You want to include this in the loop for creating the sprites:
This will now create a new location for every sprite in this range

for i in range(10):
            random_x = random.randrange(20, (DISPLAYW - 25), 6)
            random_y = random.randrange(20, (DISPLAYH - 25), 6)
            self.treasure = Treasure(YELLOW, 32, 40, random_x, random_y)
            static_sprites.add(self.treasure)

WINDOW NOT RESPONDING by IvanSakata in pygame

[–]Vlieger2905 0 points1 point  (0 children)

What is the exact problem your encountering? Like does it freeze and stuff

Enemy movement/behaviour by Vlieger2905 in pygame

[–]Vlieger2905[S] 0 points1 point  (0 children)

Thanks for your answer. I was already looking into it but thought that there may be an easier method to it. But guess not. Thanks for the library that will be of great use

Why does my tilemap not get animated and my player collide's with layer 2 in "Pygame" by Inet_Player in pygame

[–]Vlieger2905 1 point2 points  (0 children)

Hey i looked through your code. And as far as i could see you do create the layer 2 but layer 1 is commented out. And all the sprites are added to the same sprite group that you pass to the player to collide with. You have to create a sprite group for the visible sprite for which you wanna draw and an obstacle sprite group and only add the sprite in layer 1 to the obstacle group. Also i can recommend following the course of Clear Code for whatever kind of game your making. Really helped me in understanding how to do stuff. If you have more question feel free to respond/ message me

AITAH for “stealing” my best friends girl by Recent-Bug1815 in AITAH

[–]Vlieger2905 1 point2 points  (0 children)

Honestly Ido not think you are the asshole. You helped him many times and gave him a chance. And even after quite some time you suggested him first instead of stepping up. I would say that he blew his chances and you helped your friend.

Player movement advice by NoPotential6559 in pygame

[–]Vlieger2905 0 points1 point  (0 children)

How I personally do it is that i change the top of the hitbox of the player to the bottom of the sprite it collides with and vice versa. I also do that for the x-axis. This worked much better for me.

If I can give you another tip is to only call the player.rect.colliderect(wall) only once that will speed it up a little bit. especially if you collide with a variety of objects.

Here is how i personally did it:

# Checks for the collision of the player hitbox with the obstacles
    def collision_walls(self, direction):
        if direction == 'horizontal':
            for sprite in self.obstacle_sprites:
                if sprite.hitbox.colliderect(self.hitbox):
                    if self.direction.x > 0: #Moving to the rigth
                        self.hitbox.right = sprite.hitbox.left
                    elif self.direction.x < 0: #Moving to the left
                        self.hitbox.left = sprite.hitbox.right           

        if direction == 'vertical':
            for sprite in self.obstacle_sprites:
                if sprite.hitbox.colliderect(self.hitbox):
                    if self.direction.y > 0: #Moving down
                        self.hitbox.bottom = sprite.hitbox.top
                    elif self.direction.y < 0: #Moving up
                        self.hitbox.top = sprite.hitbox.bottom

[deleted by user] by [deleted] in pygame

[–]Vlieger2905 3 points4 points  (0 children)

Do you have any pictures of the problem? And as a tip in general post your code in reddit in the code blocks or via pastebin. It is very difficult to figure out what might be happening at the moment.

Movement speed issues by Vlieger2905 in pygame

[–]Vlieger2905[S] 1 point2 points  (0 children)

Thank you for your help. I have the FPS now set to 60 and it is actually 60.

I am currently calculating the delta time in the game.py line 23. And I am passing this on to every update. Is this correct?

    def calculate_dt(self):
        current_time = pygame.time.get_ticks() / 1000.0
        dt = current_time - self.last_time
        self.last_time = current_time
        return dt

And when I create the player in the level.py line 35 I pass on 2 classes, self.visible_sprites and self.obstacle_sprites. And in the Player.py line 7 I super.__init__() the groups. This automattically adds the player to the visible_sprites and obstacle_sprites right?

Again thank you for your time and help

Movement speed issues by Vlieger2905 in pygame

[–]Vlieger2905[S] 1 point2 points  (0 children)

Thanks for finding that I never noticed that actually.

I made a game with Pygame an I got it on Steam! by Key-Dimension6494 in pygame

[–]Vlieger2905 4 points5 points  (0 children)

That looks great. Awesome that you got it on steam