Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__pycache__
build
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ Grab the latest release of Python from [here](https://www.python.org/downloads/)
``python3 -m pip install pygame``
3. Linux:
Same as windows.
4. Browser
```sh
pip install pygbag
cd ..
pygbag Flappuccino
```
Then
http://localhost:8000

Ensure ``main.py`` is in the same directory as ``./data`` and execute ``python main.py``.

Expand Down
2 changes: 1 addition & 1 deletion background.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pygame
import pygame, colorsys
class Background:
def __init__(self):
self.sprite = pygame.image.load('data/gfx/bg.png')
Expand Down
Binary file added data/sfx/bean-pygbag.ogg
Binary file not shown.
Binary file added data/sfx/dead-pygbag.ogg
Binary file not shown.
Binary file added data/sfx/flap-pygbag.ogg
Binary file not shown.
Binary file added data/sfx/upgrade-pygbag.ogg
Binary file not shown.
36 changes: 23 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import pygame, sys, time, random, colorsys, math
import pygame, sys, time, random, colorsys, math, asyncio
from pygame.math import Vector2
from pygame.locals import *
from .player import Player
from .background import Background
from .button import Button
from .bean import Bean
from .utils import clamp
from .utils import checkCollisions
from player import Player
from background import Background
from button import Button
from bean import Bean
from utils import clamp
from utils import checkCollisions


def main():
async def main():
pygame.init()
# set the display
DISPLAY=pygame.display.set_mode((640,480),0,32)
Expand All @@ -27,11 +27,18 @@ def main():
title_bg = pygame.image.load('data/gfx/bg.png')
title_bg.fill((255, 30.599999999999998, 0.0), special_flags=pygame.BLEND_ADD)
shadow = pygame.image.load('data/gfx/shadow.png')

# get sounds
flapfx = pygame.mixer.Sound("data/sfx/flap.wav")
upgradefx = pygame.mixer.Sound("data/sfx/upgrade.wav")
beanfx = pygame.mixer.Sound("data/sfx/bean.wav")
deadfx = pygame.mixer.Sound("data/sfx/dead.wav")
# sounds
if ['win','linux'].__contains__(sys.platform):
soundExt = '.wav'
else:
soundExt = '.ogg'

flapfx = pygame.mixer.Sound("data/sfx/flap" + soundExt)
upgradefx = pygame.mixer.Sound("data/sfx/upgrade" + soundExt)
beanfx = pygame.mixer.Sound("data/sfx/bean" + soundExt)
deadfx = pygame.mixer.Sound("data/sfx/dead" + soundExt)
# colors
WHITE=(255,255,255) # constant
# variables
Expand Down Expand Up @@ -91,6 +98,7 @@ def main():

# update display
pygame.display.update()
await asyncio.sleep(0)
# wait for 10 seconds
pygame.time.delay(10)

Expand Down Expand Up @@ -129,6 +137,7 @@ def main():
DISPLAY.blit(startMessage, (DISPLAY.get_width()/2 - startMessage.get_width()/2, 292))

pygame.display.update()
await asyncio.sleep(0)
pygame.time.delay(10)

# the main game loop
Expand Down Expand Up @@ -271,7 +280,8 @@ def main():
bg[2].position = bg[0].position - DISPLAY.get_height()

pygame.display.update()
await asyncio.sleep(0)
pygame.time.delay(10)

if __name__ == "__main__":
main()
asyncio.run(main())