diff --git a/04B_19.TTF b/04B_19.ttf similarity index 100% rename from 04B_19.TTF rename to 04B_19.ttf diff --git a/README.md b/README.md new file mode 100644 index 0000000..4e124c8 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +Install + + python3 -m pip install -r requirements.txt + +Run + + python3 flappy.py diff --git a/flappy.py b/flappy.py index d8428d3..8b4529d 100644 --- a/flappy.py +++ b/flappy.py @@ -69,12 +69,14 @@ def update_score(score, high_score): game_font = pygame.font.Font('04B_19.ttf',40) # Game Variables -gravity = 0.25 +fps = 60 +gravity = 0.45 bird_movement = 0 game_active = True score = 0 high_score = 0 + bg_surface = pygame.image.load('assets/background-day.png').convert() bg_surface = pygame.transform.scale2x(bg_surface) @@ -117,16 +119,17 @@ def update_score(score, high_score): if event.type == pygame.QUIT: pygame.quit() sys.exit() - if event.type == pygame.KEYDOWN: - if event.key == pygame.K_SPACE and game_active: + if event.type in( pygame.KEYDOWN, pygame.MOUSEBUTTONUP): + flappy = pygame.mouse.get_pressed() or event.key == pygame.K_SPACE + if flappy and game_active: bird_movement = 0 bird_movement -= 12 flap_sound.play() - if event.key == pygame.K_SPACE and game_active == False: + if flappy and game_active == False: game_active = True pipe_list.clear() bird_rect.center = (100,512) - #bird_movement = 0 + bird_movement = 0 score = 0 if event.type == SPAWNPIPE: @@ -172,6 +175,5 @@ def update_score(score, high_score): if floor_x_pos <= -576: floor_x_pos = 0 - pygame.display.update() - clock.tick(120) + clock.tick(fps) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..cca2018 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pygame==2.0.0.dev10