1 from operationscore.Renderer import *
2 import util.TimeOps as timeops
3 import pygame
4 from pygame.locals import *
5 import pdb
7 """PygameRenderer is a renderer which renders the LightSystem to a pygame display"""
8
10 pygame.init()
11 self.screen = pygame.display.set_mode((1300,500))
12 self.background = pygame.Surface(self.screen.get_size())
13 self.background = self.background.convert()
14 self.background.fill(Color(0,0,0))
15 self.stopwatch = timeops.Stopwatch()
16 self.stopwatch.start()
17
18 - def render(self, lightSystem, currentTime=timeops.time()):
19 self.background.fill(Color(0,0,0))
20
21 if 'Scale' in self:
22 scale = self['Scale']
23 else:
24 scale = 1
25 for light in lightSystem:
26 scaledLoc = [l*scale for l in light.location]
27 pygame.draw.circle(self.background, light.state(currentTime), scaledLoc, \
28 5)
29
30 self.screen.blit(self.background, (0,0))
31 pygame.display.flip()
32 self.stopwatch.stop()
33 pygame.display.set_caption(str(int(1000/self.stopwatch.elapsed())))
34 self.stopwatch.start()
35