Moved color surface away

master
David Raison 2014-08-30 17:24:11 +02:00
parent 56c7d3f241
commit 3ac4286668
3 changed files with 10 additions and 9 deletions

View File

@ -3,6 +3,7 @@
import os, pygame import os, pygame
from pygame.locals import * from pygame.locals import *
from support.colors import * from support.colors import *
from support import operations
class Hud: class Hud:
@ -29,7 +30,7 @@ class Hud:
timesurface = pygame.Surface((200, 20)) timesurface = pygame.Surface((200, 20))
hourglass = pygame.image.load(os.path.join('img', 'hourglass.png')).convert_alpha() hourglass = pygame.image.load(os.path.join('img', 'hourglass.png')).convert_alpha()
hourglass = pygame.transform.scale(hourglass, (15, 18)) hourglass = pygame.transform.scale(hourglass, (15, 18))
self.color_surface(hourglass, WHITE) operations.color_surface(hourglass, WHITE)
time = self.font.render(str(time), 1, WHITE) time = self.font.render(str(time), 1, WHITE)
timesurface.blit(hourglass, (0, 0)) timesurface.blit(hourglass, (0, 0))
timesurface.blit(time, (40, 0)) timesurface.blit(time, (40, 0))
@ -37,10 +38,3 @@ class Hud:
def draw_fps(self, fps): def draw_fps(self, fps):
return self.font.render('fps: ' + str(fps), 10, RED) return self.font.render('fps: ' + str(fps), 10, RED)
def color_surface(self,surface, color):
red, green, blue = color
arr = pygame.surfarray.pixels3d(surface)
arr[:,:,0] = red
arr[:,:,1] = green
arr[:,:,2] = blue

View File

@ -124,4 +124,3 @@ WHITE=(255,255,255)
BLACK=(0,0,0) BLACK=(0,0,0)
#-----------End of colors-----------# #-----------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