python version of bottleblaster.

This commit is contained in:
Storm dragon 2016-03-20 18:01:41 -04:00
parent b9986073f9
commit 63a5f17c0c
17 changed files with 40 additions and 0 deletions

Binary file not shown.

View 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

Binary file not shown.

BIN
pybottle/sounds/empty.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
pybottle/sounds/glass1.ogg Normal file

Binary file not shown.

BIN
pybottle/sounds/glass2.ogg Normal file

Binary file not shown.

BIN
pybottle/sounds/glass3.ogg Normal file

Binary file not shown.

BIN
pybottle/sounds/gun1.ogg Normal file

Binary file not shown.

BIN
pybottle/sounds/gun2.ogg Normal file

Binary file not shown.

BIN
pybottle/sounds/gun3.ogg Normal file

Binary file not shown.

BIN
pybottle/sounds/gun4.ogg Normal file

Binary file not shown.

BIN
pybottle/sounds/gun5.ogg Normal file

Binary file not shown.

BIN
pybottle/sounds/load3.ogg Normal file

Binary file not shown.

BIN
pybottle/sounds/load4.ogg Normal file

Binary file not shown.

BIN
pybottle/sounds/load5.ogg Normal file

Binary file not shown.

17
pybottle/storm_games.py Normal file
View 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)