Increase score simply on clicking for now

master
David Raison 2014-08-30 17:05:01 +02:00
parent a8addce0f4
commit fe44b1d628
2 changed files with 14 additions and 6 deletions

14
game.py
View File

@ -12,7 +12,7 @@ from interface import hud
def main():
pygame.init()
pygame.display.set_caption('Avocados')
pygame.display.set_caption('Pin the Avocados!')
clock = pygame.time.Clock()
# Move this outside the main code?
@ -34,19 +34,25 @@ def main():
while running:
time_passed = clock.tick(desired_fps)
fps = clock.get_fps()
screen.fill(bg)
timeleft -= time_passed / 1000
timeleft = round(timeleft,2)
timeleft = round(timeleft, 2)
if timeleft <= 0:
screen.blit(game_over, (screen_width/3, screen_height/2))
displaytime = 'Timed out!'
else:
displaytime = timeleft
chud = my_hud.draw_hud(score, timeleft, round(fps,2))
# Redraw the HUD
chud = my_hud.draw_hud(score, displaytime, round(fps,2))
screen.blit(chud, (10,10))
# Catch events
for event in pygame.event.get():
if event.type == MOUSEBUTTONDOWN:
score += 100
if event.type == pygame.QUIT:
running = False

View File

@ -14,8 +14,10 @@ class Hud:
def draw_hud(self, score, timeleft, fps):
self.screen.fill(BLACK)
self.screen.blit(self.draw_score(score), (0, 0))
self.screen.blit(self.draw_timeleft(timeleft), (100, 0))
self.screen.blit(self.draw_fps(fps), (650, 0))
self.screen.blit(self.draw_timeleft(timeleft), (self.screen_width / 2, 0))
thefps = self.draw_fps(fps)
fps_rect = thefps.get_rect()
self.screen.blit(thefps, (self.screen_width - fps_rect.w, 0))
return self.screen
def draw_score(self, score):