Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alan Aguiar
Test
Commits
5ca86a65
Commit
5ca86a65
authored
Mar 25, 2014
by
Alan Aguiar
Browse files
play sounds
parent
e4a0ea3a
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.py
View file @
5ca86a65
...
...
@@ -54,10 +54,13 @@ class Flappy():
def
__init__
(
self
):
self
.
state
=
INIT
self
.
best
=
0
self
.
sound
=
True
def
increment_score
(
self
):
self
.
score
=
self
.
score
+
1
self
.
currentS
.
set_score
(
self
.
score
)
if
self
.
sound
:
self
.
_snd_pipe
.
play
()
def
load_all
(
self
):
self
.
game_w
=
GAME_SIZE
[
0
]
...
...
@@ -110,6 +113,7 @@ class Flappy():
def
main
(
self
):
pygame
.
display
.
init
()
pygame
.
font
.
init
()
pygame
.
mixer
.
init
()
self
.
clock
=
pygame
.
time
.
Clock
()
self
.
screen
=
pygame
.
display
.
get_surface
()
if
self
.
screen
:
...
...
@@ -122,6 +126,10 @@ class Flappy():
else
:
self
.
screen
=
pygame
.
display
.
set_mode
(
GAME_SIZE
)
pygame
.
display
.
set_caption
(
'Flappy'
)
self
.
_snd_pipe
=
pygame
.
mixer
.
Sound
(
'sounds/pipe.ogg'
)
self
.
_snd_pipe
.
set_volume
(
0.5
)
self
.
_snd_bird
=
pygame
.
mixer
.
Sound
(
'sounds/bird.ogg'
)
self
.
_snd_bird
.
set_volume
(
0.5
)
self
.
load_all
()
self
.
state
=
INIT
self
.
running
=
True
...
...
@@ -137,6 +145,8 @@ class Flappy():
self
.
load_game
()
elif
self
.
state
==
PLAY
:
self
.
bird
.
setVel
(
8
)
if
self
.
sound
:
self
.
_snd_bird
.
play
()
elif
self
.
state
==
END
:
self
.
state
=
INIT
self
.
load_all
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment