python version of bottleblaster.
This commit is contained in:
parent
b9986073f9
commit
63a5f17c0c
BIN
pybottle/__pycache__/storm_games.cpython-35.pyc
Normal file
BIN
pybottle/__pycache__/storm_games.cpython-35.pyc
Normal file
Binary file not shown.
23
pybottle/bottle-blaster.py
Normal file
23
pybottle/bottle-blaster.py
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/python
|
||||
# Shoot the bottles as fast as possible.
|
||||
|
||||
from storm_games import *
|
||||
|
||||
initialize_gui("Bottle Blaster")
|
||||
# load sound files
|
||||
bottle = pygame.mixer.Sound("sounds/bottle.ogg")
|
||||
|
||||
# loop forever (until a break occurs)
|
||||
while True:
|
||||
# wait for an event
|
||||
event = pygame.event.wait()
|
||||
# if the event is about a keyboard button that have been pressed...
|
||||
if event.type == pygame.KEYDOWN:
|
||||
bottle.play(-1)
|
||||
if event.type == pygame.KEYUP:
|
||||
bottle.stop()
|
||||
# and if the button is the "q" letter or the "escape" key...
|
||||
if event.key == pygame.K_ESCAPE:
|
||||
# ... then exit from the while loop
|
||||
break
|
||||
time.sleep(.001)
|
BIN
pybottle/sounds/bottle.ogg
Normal file
BIN
pybottle/sounds/bottle.ogg
Normal file
Binary file not shown.
BIN
pybottle/sounds/empty.ogg
Normal file
BIN
pybottle/sounds/empty.ogg
Normal file
Binary file not shown.
BIN
pybottle/sounds/game-intro.ogg
Normal file
BIN
pybottle/sounds/game-intro.ogg
Normal file
Binary file not shown.
BIN
pybottle/sounds/glass1.ogg
Normal file
BIN
pybottle/sounds/glass1.ogg
Normal file
Binary file not shown.
BIN
pybottle/sounds/glass2.ogg
Normal file
BIN
pybottle/sounds/glass2.ogg
Normal file
Binary file not shown.
BIN
pybottle/sounds/glass3.ogg
Normal file
BIN
pybottle/sounds/glass3.ogg
Normal file
Binary file not shown.
BIN
pybottle/sounds/gun1.ogg
Normal file
BIN
pybottle/sounds/gun1.ogg
Normal file
Binary file not shown.
BIN
pybottle/sounds/gun2.ogg
Normal file
BIN
pybottle/sounds/gun2.ogg
Normal file
Binary file not shown.
BIN
pybottle/sounds/gun3.ogg
Normal file
BIN
pybottle/sounds/gun3.ogg
Normal file
Binary file not shown.
BIN
pybottle/sounds/gun4.ogg
Normal file
BIN
pybottle/sounds/gun4.ogg
Normal file
Binary file not shown.
BIN
pybottle/sounds/gun5.ogg
Normal file
BIN
pybottle/sounds/gun5.ogg
Normal file
Binary file not shown.
BIN
pybottle/sounds/load3.ogg
Normal file
BIN
pybottle/sounds/load3.ogg
Normal file
Binary file not shown.
BIN
pybottle/sounds/load4.ogg
Normal file
BIN
pybottle/sounds/load4.ogg
Normal file
Binary file not shown.
BIN
pybottle/sounds/load5.ogg
Normal file
BIN
pybottle/sounds/load5.ogg
Normal file
Binary file not shown.
17
pybottle/storm_games.py
Normal file
17
pybottle/storm_games.py
Normal file
@ -0,0 +1,17 @@
|
||||
"""Standard initializations and functions shared by all games."""
|
||||
|
||||
import os
|
||||
import pygame
|
||||
import time
|
||||
|
||||
def initialize_gui(gameTitle):
|
||||
# start pygame
|
||||
pygame.init()
|
||||
# start the display (required by the event loop)
|
||||
pygame.display.set_mode((320, 200))
|
||||
pygame.display.set_caption(gameTitle)
|
||||
# Load sounds from the sound directory
|
||||
soundFileNames = next(os.walk("sounds/"))[2]
|
||||
for i in soundFileNames:
|
||||
if i[-4:] == ".ogg": i[:-4] = pygame.mixer.Sound("sounds/" + i)
|
||||
|
Loading…
Reference in New Issue
Block a user