Display current score in the upper left corner
parent
c241f279bd
commit
80e0b7be4e
4
game.py
4
game.py
|
@ -8,7 +8,7 @@ import pygame
|
|||
from pygame.locals import *
|
||||
|
||||
from support import colors
|
||||
import hud
|
||||
from interface import hud
|
||||
|
||||
# Move this outside
|
||||
screen_width = 800
|
||||
|
@ -26,6 +26,8 @@ def main():
|
|||
while running:
|
||||
# Limit to 50 fps
|
||||
time_passed = clock.tick(30)
|
||||
my_hud = hud.draw_hud(10)
|
||||
screen.blit(my_hud, (0,0))
|
||||
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import pygame
|
||||
from pygame.locals import *
|
||||
from support.colors import *
|
||||
|
||||
def draw_hud(score):
|
||||
hud = pygame.Surface((800, 100))
|
||||
|
||||
# Adding items to the hud
|
||||
hud.blit(draw_score(score), (0, 0))
|
||||
#hud.blit(get_timeleft, (200, 0))
|
||||
return hud
|
||||
|
||||
def draw_score(score):
|
||||
font = pygame.font.Font(None, 30)
|
||||
score = font.render('Score: ' + str(score), 0, WHITE)
|
||||
return score
|
Loading…
Reference in New Issue