diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..99e4b84 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +build \ No newline at end of file diff --git a/README.md b/README.md index 022bf1f..f86fb59 100644 --- a/README.md +++ b/README.md @@ -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``. diff --git a/background.py b/background.py index 097a092..a3cc98e 100644 --- a/background.py +++ b/background.py @@ -1,4 +1,4 @@ -import pygame +import pygame, colorsys class Background: def __init__(self): self.sprite = pygame.image.load('data/gfx/bg.png') diff --git a/data/sfx/bean-pygbag.ogg b/data/sfx/bean-pygbag.ogg new file mode 100644 index 0000000..a3efbf1 Binary files /dev/null and b/data/sfx/bean-pygbag.ogg differ diff --git a/data/sfx/dead-pygbag.ogg b/data/sfx/dead-pygbag.ogg new file mode 100644 index 0000000..1cb5540 Binary files /dev/null and b/data/sfx/dead-pygbag.ogg differ diff --git a/data/sfx/flap-pygbag.ogg b/data/sfx/flap-pygbag.ogg new file mode 100644 index 0000000..da10b3e Binary files /dev/null and b/data/sfx/flap-pygbag.ogg differ diff --git a/data/sfx/upgrade-pygbag.ogg b/data/sfx/upgrade-pygbag.ogg new file mode 100644 index 0000000..289c7c5 Binary files /dev/null and b/data/sfx/upgrade-pygbag.ogg differ diff --git a/main.py b/main.py index a4256fa..a2f9c6d 100644 --- a/main.py +++ b/main.py @@ -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) @@ -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 @@ -91,6 +98,7 @@ def main(): # update display pygame.display.update() + await asyncio.sleep(0) # wait for 10 seconds pygame.time.delay(10) @@ -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 @@ -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()) \ No newline at end of file