-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObserver.py
More file actions
48 lines (47 loc) · 1.12 KB
/
Copy pathObserver.py
File metadata and controls
48 lines (47 loc) · 1.12 KB
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
40
41
42
43
44
45
46
47
48
from User import user
from Main import Generator
import unicornhat as unicorn
from pyfiglet import figlet_format
import os
import sys
k=-1
unicorn.brightness(.5)
unicorn.set_layout(unicorn.AUTO)
unicorn.rotation(0)
width,height=unicorn.get_shape()
unicorn.rotation(0)
class observer():
def __init__(self):
self.exit = False;
self.generator = Generator();
self.user = user(self);
self.bodyCollision=False
def end(self):
self.exit = True;
self.generator.exit = True;
def up(self):
self.generator.shape.rotate();
def down(self):
self.generator.shape.rotate();
def right(self):
self.generator.shape.shiftRight();
def left(self):
self.generator.shape.shiftLeft();
def cleanup(self):
unicorn.clear();
unicorn.rotation(90);
for i in range(100):
self.showScore();
os.system('stty sane');
sys.exit();
def begin(self):
# self.user.start();
# self.generator.begin()
# self.snake.addNode();
try:
self.user.start();
self.generator.start();
except KeyboardInterrupt:
self.end();
self.cleanup();
observer().begin()