Merge branch 'master' of github.com:lvl2/avocados

master
Steve Clement 2014-08-30 17:44:26 +02:00
commit c1bc5fabba
4 changed files with 18 additions and 4 deletions

BIN
img/hourglass.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -1,8 +1,9 @@
#!/usr/bin/env python3
import pygame
import os, pygame
from pygame.locals import *
from support.colors import *
from support import operations
class Hud:
@ -25,9 +26,15 @@ class Hud:
return score
def draw_timeleft(self, time):
# Add a clock icon here (maybe egg-clock)
# Not sure this is clever, to recreate the surface each time ;)
timesurface = pygame.Surface((200, 20))
hourglass = pygame.image.load(os.path.join('img', 'hourglass.png')).convert_alpha()
hourglass = pygame.transform.scale(hourglass, (15, 18))
operations.color_surface(hourglass, WHITE)
time = self.font.render(str(time), 1, WHITE)
return time
timesurface.blit(hourglass, (0, 0))
timesurface.blit(time, (40, 0))
return timesurface
def draw_fps(self, fps):
return self.font.render('fps: ' + str(fps), 10, RED)

View File

@ -124,4 +124,3 @@ WHITE=(255,255,255)
BLACK=(0,0,0)
#-----------End of colors-----------#

8
support/operations.py Normal file
View File

@ -0,0 +1,8 @@
import pygame
def color_surface(surface, color):
red, green, blue = color
arr = pygame.surfarray.pixels3d(surface)
arr[:,:,0] = red
arr[:,:,1] = green
arr[:,:,2] = blue