Display current score in the upper left corner

master
David Raison 2014-08-30 15:52:27 +02:00
parent c241f279bd
commit 80e0b7be4e
3 changed files with 21 additions and 1 deletions

View File

@ -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
interface/__init__.py Normal file
View File

18
interface/hud.py Normal file
View File

@ -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