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
4f6fbddf
Commit
4f6fbddf
authored
Feb 28, 2014
by
Alan Aguiar
Browse files
end score works
parent
1d2ba343
Changes
2
Hide whitespace changes
Inline
Side-by-side
main.py
View file @
4f6fbddf
...
...
@@ -28,7 +28,7 @@ from pipe import Pipe_I
from
pipe
import
Pipe_S
from
build
import
Build
from
bird
import
Bird
from
scores
import
Score
s
from
scores
import
End
Score
from
scores
import
Message
from
scores
import
CurrentScore
...
...
@@ -71,7 +71,7 @@ class Flappy():
self
.
build
=
Build
(
0
,
self
.
build_y
)
self
.
bird
=
Bird
(
self
,
self
.
bird_x
,
self
.
bird_y
)
self
.
bird
.
mAcc
=
0
self
.
scores
=
Score
s
(
200
,
200
)
self
.
end_
scores
=
End
Score
(
200
,
200
)
self
.
message
=
Message
(
200
,
200
)
self
.
currentS
=
CurrentScore
(
300
,
100
)
########################################################################
...
...
@@ -93,7 +93,7 @@ class Flappy():
self
.
bird
.
mAcc
=
5
self
.
bird
.
count
=
20
self
.
floor
.
mVel
=
-
5
self
.
sprites
.
remove
(
self
.
scores
)
self
.
sprites
.
remove
(
self
.
end_
scores
)
self
.
sprites
.
remove
(
self
.
message
)
def
main
(
self
):
...
...
@@ -148,7 +148,10 @@ class Flappy():
self
.
floor
.
mVel
=
0
for
spr
in
self
.
tubes
:
spr
.
mVel
=
0
self
.
sprites
.
add
(
self
.
scores
,
layer
=
3
)
if
self
.
score
>
self
.
best
:
self
.
best
=
self
.
score
self
.
end_scores
.
update_scores
(
self
.
score
,
self
.
best
)
self
.
sprites
.
add
(
self
.
end_scores
,
layer
=
3
)
self
.
sprites
.
draw
(
self
.
screen
)
self
.
running_t
=
True
while
self
.
running_t
:
...
...
scores.py
View file @
4f6fbddf
...
...
@@ -6,15 +6,34 @@ import pygame
back
=
pygame
.
image
.
load
(
'images/score_alfa.png'
)
mes
=
pygame
.
image
.
load
(
'images/init_alfa.png'
)
class
Score
s
(
pygame
.
sprite
.
Sprite
):
class
End
Score
(
pygame
.
sprite
.
Sprite
):
def
__init__
(
self
,
x
=
0
,
y
=
0
):
pygame
.
sprite
.
Sprite
.
__init__
(
self
)
self
.
mPos
=
[
x
,
y
]
self
.
image
=
back
self
.
score
=
0
self
.
best
=
0
self
.
font
=
pygame
.
font
.
Font
(
'DejaVuSans-Bold.ttf'
,
40
)
self
.
fgColor
=
(
255
,
255
,
255
)
self
.
_update_image
()
def
update_scores
(
self
,
score
,
best
):
self
.
score
=
score
self
.
best
=
best
self
.
_update_image
()
def
_update_image
(
self
):
self
.
image
=
back
.
copy
()
fontSurface
=
self
.
font
.
render
(
str
(
self
.
score
),
True
,
self
.
fgColor
)
xPos
=
(
self
.
image
.
get_width
()
-
fontSurface
.
get_width
())
/
2
self
.
image
.
blit
(
fontSurface
,
(
xPos
,
35
))
fontSurface
=
self
.
font
.
render
(
str
(
self
.
best
),
True
,
self
.
fgColor
)
xPos
=
(
self
.
image
.
get_width
()
-
fontSurface
.
get_width
())
/
2
self
.
image
.
blit
(
fontSurface
,
(
xPos
,
97
))
self
.
rect
=
self
.
image
.
get_rect
()
self
.
rect
.
x
=
self
.
mPos
[
0
]
self
.
rect
.
y
=
self
.
mPos
[
1
]
class
CurrentScore
(
pygame
.
sprite
.
Sprite
):
...
...
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