Relative Content

Tag Archive for pygame

How to create multiple enemy objects with different coordinate loacations

Im trying to make a game on pygame for my school project. And i followed clearcodes ultimate guide for python where he creates a runner game. In that video he creates a single place where the enemy rects spawn in. But im trying to make a platformer game where enemies can appear in multiple places.

Adding Gameover screen in pygame

I would like to add a simple “Game Over” screen at the end of the game – when the player collides with the enemy, but not sure how to do this. Here’s what the game currently looks like:

Pygame: Centering a rect after using self.rect.inflate()

So basically I’ve been tryng to create a small RPG for a school project and have struck a wall when trying to use attacks. I wanted the hitbox for the attack to be bigger than the characters usual hitbox, so I looked around and found rect.inflate() which seems to work. But it only extened in the bottom right corner. So now what I want to do is center it around my character so it has equal distance on all sides. I did try rect.center with another rect which I gave the variables of the first rect before inflatiing it (when it was centered on the character) but that doesn’t seem to work. So what I’d like is either a solution to center it, or maybe a better way to do my attacks because for now I just put another animation on top of the non-attacking one.

Pygame sprite post-collision mouvemnt

I’ve made it so when the sprites of player1 and player2 collide, the code stops taking input and they do not move. I’ve been having trouble implementing the movement if the input after the collision is opposite to the direction of the collision, so that when the two sprites collide they don’t overlap and can move away from eachother.

Not correct rotation in Pygame using trigonometric functions

I’m trying to write a little physics simulation using only standart Pygame. I wanna to have a trapezoid a draw it using 4 dots. So I wanna to rotate every single of this dots independetly (not use pygame.transform.rotate ). I write a code that calculate a new coordinates of dot, after rotation around a pivot, using trigonometric functions.