-
Notifications
You must be signed in to change notification settings - Fork 0
/
animation_system.py
99 lines (90 loc) · 3.35 KB
/
animation_system.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from system import System
from screen_system import ScreenSystem
import time
from constants import *
import random
class AnimationSystem(ScreenSystem):
def update(self):
# get events from system
damage_event = None
bonk_event = None
death_event = None
noise_event = None
sanity_event = None
health_event = None
for event in self._events:
if event['type'] == 'damage_event':
damage_event = event
if event['type'] == 'bonk_event':
bonk_event = event
if event['type'] == 'death_event':
death_event = event
if event['type'] == 'noise_event':
noise_event = event
if event['type'] == 'sanity_event':
sanity_event = event
if event['type'] == 'health_event':
health_event = event
if damage_event is None and bonk_event is None and death_event is None and noise_event is None and sanity_event is None and health_event is None:
return
for i in range(1,5):
if bonk_event is not None:
System.push_event({
'type': 'bonk',
'value': {
'count': i,
'value': bonk_event['value']
}
})
if damage_event is not None:
System.push_event({
'type': 'damage',
'value': {
'count': i,
'value': str(damage_event['value'])
}
})
if death_event is not None:
System.push_event({
'type': 'death',
'value': {
'position': death_event['value'],
'color':random.choice([COLOR_BROWN, COLOR_GREEN, COLOR_RED, COLOR_WHITE, COLOR_LIGHT_RED, COLOR_LIGHT_BROWN])
}
})
if noise_event is not None:
System.push_event({
'type': 'noise',
'value': {
'color': COLOR_WHITE,
'symbol': random.choice(['-', '*', '+']),
'radius': NOISE_RADIUS + i,
'position': noise_event['value'],
}
})
if sanity_event is not None:
System.push_event({
'type': 'sanity',
'value': {
'count': i,
'value': sanity_event['value']
}
})
if health_event is not None:
System.push_event({
'type': 'health',
'value': {
'count': i,
'value': health_event['value']
}
})
super().update()
time.sleep(0.1)
# remove noise_event from system
self.remove_events('damage_event')
self.remove_events('bonk_event')
self.remove_events('death_event')
self.remove_events('noise_event')
self.remove_events('sanity_event')
self.remove_events('health_event')
super().update()