blob: bc50360c3f7fa71a156d80ab07b50d53aa97c0e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
from operationscore.Renderer import *
import util.TimeOps as timeops
import pygame
from pygame.locals import *
import pdb
class PygameRenderer(Renderer):
"""PygameRenderer is a renderer which renders the LightSystem to a pygame display"""
def initRenderer(self):
pygame.init()
self.screen = pygame.display.set_mode((1300,500))
self.background = pygame.Surface(self.screen.get_size())
self.background = self.background.convert()
self.background.fill(Color(0,0,0))
self.stopwatch = timeops.Stopwatch()
self.stopwatch.start()
def render(self, lightSystem, currentTime=timeops.time()):
self.background.fill(Color(0,0,0))
#print 'drawing color:',light.color
for light in lightSystem:
pygame.draw.circle(self.background, light.state(currentTime), light.location, \
light.radius)
self.screen.blit(self.background, (0,0))
pygame.display.flip()
self.stopwatch.stop()
pygame.display.set_caption(str(int(1000/self.stopwatch.elapsed())))
self.stopwatch.start()
|