diff --git a/img/hourglass.png b/img/hourglass.png new file mode 100644 index 0000000..1099f8d Binary files /dev/null and b/img/hourglass.png differ diff --git a/interface/hud.py b/interface/hud.py index cd01e60..99d2c0f 100644 --- a/interface/hud.py +++ b/interface/hud.py @@ -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) diff --git a/support/colors.py b/support/colors.py index d6f6c16..a21a54b 100644 --- a/support/colors.py +++ b/support/colors.py @@ -124,4 +124,3 @@ WHITE=(255,255,255) BLACK=(0,0,0) #-----------End of colors-----------# - diff --git a/support/operations.py b/support/operations.py new file mode 100644 index 0000000..97b8f89 --- /dev/null +++ b/support/operations.py @@ -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