-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTron.py
39 lines (31 loc) · 1.13 KB
/
Tron.py
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
30
31
32
33
34
35
36
37
38
39
import pygame
from Scenes import *
class Director:
def __init__(self):
pygame.init()
pygame.font.init()
self.screen = pygame.display.set_mode((1920, 1080), pygame.NOFRAME|pygame.DOUBLEBUF)
self.events = None
self.scene = None
self.clock = pygame.time.Clock()
self.is_running = True
def stop(self):
self.is_running = False
def load_scene(self, scene):
self.scene = scene
self.main_loop()
def main_loop(self):
while self.is_running:
if pygame.event.peek(pygame.QUIT):
pygame.quit()
exit()
dtime = self.clock.tick() * 0.001
self.events = pygame.event.get()
self.scene.update(dtime, self.events)
self.scene.draw(self.screen)
if __name__ == "__main__":
director = Director()
keymapping = ({"LEFT": pygame.K_q, "RIGHT": pygame.K_d},
{"LEFT": pygame.K_LEFT, "RIGHT": pygame.K_RIGHT})
#keymapping = [{"LEFT": pygame.K_LEFT, "RIGHT": pygame.K_RIGHT} for x in range(666)]
director.load_scene(Game(director, LigthCycles=keymapping))