this month we have an project and our project is to create a game and we already does the jump with the event get.keypressed but we don’t know and we can’t find the solution to implent a double jump
our game is for two player so we put the movement on keyboard keys
here the code
'key = pygame.key.get_pressed()
if key[pygame.K_w] and not self.jumped:
self.vel_y = -15
self.jumped = True
if not key[pygame.K_w]:
self.jumped = False'
for one player
here our gravity
self.vel_y += 1 if self.vel_y > 10: self.vel_y = 10 dy += self.vel_y
and here our parameters`
self.image_right = pygame.image.load('images/perso/joueur1/mouvement/persodroite.png').convert_alpha() self.image_left = pygame.image.load('images/perso/joueur1/mouvement/persogauche.png').convert_alpha() self.image_still = pygame.image.load('images/perso/joueur1/mouvement/perso1.png').convert_alpha() self.image = self.image_still self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y self.vel_y = 0 self.jumped = False
we had try to put a parameters to count the number of jump
FUN is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.