Last active
December 11, 2015 10:58
-
-
Save hortonew/4590382 to your computer and use it in GitHub Desktop.
Pyglet - Play Single Sound
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyglet | |
from pyglet.window import key | |
#Put sound files in a folder called "resources" | |
pyglet.resource.path = ['resources'] | |
pyglet.resource.reindex() | |
#Create sound object for laser | |
screen = pyglet.window.Window(800,600) | |
laser = pyglet.resource.media('laser.wav') | |
@screen.event | |
def on_key_press(symbol, modifiers): | |
if symbol == key.SPACE: | |
laser.play() | |
def update(dt): | |
#update objects here | |
pass | |
if __name__ == "__main__": | |
pyglet.clock.schedule_interval(update, 1/120.0) | |
pyglet.app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment