Python Forum

Full Version: bird jump in flappy bird games
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am making a game like flappy bird from scratch but I am confused about how to fly / jump that birds do in the game Flappy Bird .. How to do it?

import pygame
import sys


pygame.init()

window = pygame.display.set_mode((800, 600))


class Player:
    def __init__(self):
        self.move_x = 50
        self.move_y = 50
        self.vel = 0
        self.width = 20
        self.height = 20
        self.player = pygame.draw.rect(window, (255, 0, 0), (self.move_x, self.move_y, self.width, self.height))
        
    def update(self):
        pass


game_run = True

while True:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            game_run = False
            pygame.quit()
            sys.exit()

    window.fill((0, 0, 0))

    player = Player()

    pygame.display.update()
You need set keyboard binding for y movement so that the bird can go up and down. This is just the start of the game, you still have a lot of coding to do.