From 91b51685d86f76f39d4aebc67a8f10d708b33bca Mon Sep 17 00:00:00 2001 From: Humberto Dias Date: Fri, 28 Aug 2020 19:23:20 +0200 Subject: [PATCH 1/2] Linux and mouse support --- 04B_19.TTF => 04B_19.ttf | Bin flappy.py | 16 +++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) rename 04B_19.TTF => 04B_19.ttf (100%) 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/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) From a40382d4f9c424684d5429a41e4bda375c89d7d0 Mon Sep 17 00:00:00 2001 From: Humberto Date: Fri, 28 Aug 2020 20:08:00 +0200 Subject: [PATCH 2/2] Mac OS support --- README.md | 7 +++++++ requirements.txt | 1 + 2 files changed, 8 insertions(+) create mode 100644 README.md create mode 100644 requirements.txt 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/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