-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pyll Machine.py
214 lines (178 loc) · 5.65 KB
/
Pyll Machine.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
from ursina import *
app = Ursina()
# window.borderless = False
window.fullscreen = True
Arrow = load_texture("oreo_blue_cursors/arrow.png")
BGTexture = load_texture("TexturePacks/Default/BG.png")
moveTexture = load_texture("TexturePacks/Default/MoveCell.png")
generatorTexture = load_texture("TexturePacks/Default/GeneratorCell.png")
ccwRotatorTexture = load_texture("TexturePacks/Default/CCWRotatorCell.png")
cwRotatorTexture = load_texture("TexturePacks/Default/CWRotatorCell.png")
playButtonTexture = load_texture("Assets/Play.png")
pauseButtonTexture = load_texture("Assets/Pause.png")
cell_pick = 1
rotation_pick = 0
cell_place_position = (0, 0)
camera.orthographic = True
pplace = None
pdestroy = None
timee = 0
timeq = 0
def update():
global rotation_pick, cell_pick
global cells, cell
global bg, BG
global timee, timeq
global show
if held_keys['1']: cell_pick = 1
if held_keys['2']: cell_pick = 2
for i in show:
i.color = "#a0a0a0"
show[cell_pick-1].color = color.white
if held_keys['e']:
if timee == 0:
rotation_pick = (rotation_pick + 1) % 4
for i in show:
i.rotation_z += 90
timee = 1
else:
timee = 0
if held_keys['q']:
if timeq == 0:
rotation_pick = (rotation_pick - 1) % 4
for i in show:
i.rotation_z -= 90
timeq = 1
else:
timeq = 0
if held_keys['left mouse']:
global pplace
hentity = mouse.hovered_entity
if type(hentity) == BG or type(hentity) in cells:
try:
if type(hentity) != cells[cell_pick - 1] or hentity.rotation != (0, 0, 90 * rotation_pick):
if hentity != pplace:
placecell(hentity)
pplace = hentity
except AssertionError as e:
pass
if held_keys['right mouse']:
global pdestroy
hentity = mouse.hovered_entity
if type(hentity) in cells and hentity != pdestroy:
destroycell(hentity)
pdestroy = hentity
camera.y += held_keys['w'] * 0.1
camera.x -= held_keys['a'] * 0.1
camera.y -= held_keys['s'] * 0.1
camera.x += held_keys['d'] * 0.1
camera.fov -= held_keys['x'] * 0.25
camera.fov += held_keys['z'] * 0.25
mouse.visible = False
Cursor(origin = (-.34, .49), texture = Arrow, color = color.white, scale = (0.04, 0.04))
class BG(Entity):
def __init__(self, position = (0, 0, 0)):
super().__init__(
model = "quad",
collider = "box",
texture = BGTexture,
color = color.white,
position = position,
)
class MoveCell(Entity):
def __init__(self, position = (0, 0, 0), rotation = (0, 0, 0)):
super().__init__(
model = "quad",
collider = "box",
texture = moveTexture,
color = color.white,
position = position,
rotation = rotation,
)
class GeneratorCell(Entity):
def __init__(self, position = (0, 0, 0), rotation = (0, 0, 0)):
super().__init__(
model = "quad",
collider = "box",
texture = generatorTexture,
color = color.white,
position = position,
rotation = rotation,
)
def placecell(self):
global rotation_pick, cell_pick, cells, cell
cell = cells[cell_pick - 1](position = self.position, rotation = (0, 0, 90 * rotation_pick))
destroy(self)
def destroycell(self):
global bg
bg = BG(position = self.position)
destroy(self)
cells = [
MoveCell,
GeneratorCell,
# CCWRotatorCell,
# CWRotatorCell,
]
for x in range(10):
for y in range(10):
bg = BG((x - 4.5, y - 4.5, 0))
background = Entity(model = "quad",
scale = (10000, 10000, 0),
color = "#292929",
position = (0, 0, 10),
)
def pickCell(pick):
global cell_pick
cell_pick = pick
show = [
Entity(parent = camera.ui,
model = "quad",
collider = "box",
texture = moveTexture,
scale = (0.1, 0.1),
position = (-0.7, -0.4),
color = color.white,
on_click = Func(pickCell, 1),
),
Entity(parent = camera.ui,
model = "quad",
collider = "box",
texture = generatorTexture,
scale = (0.1, 0.1),
position = (-0.58, -0.4),
color = "#a0a0a0",
on_click = Func(pickCell, 2),
),
]
class playButton(Button):
def __init__(self):
super().__init__(
model = "quad",
texture = playButtonTexture,
scale = (0.1, 0.1),
position = (-0.82, -0.4),
color = color.white,
)
def input(self, key):
if mouse.hovered_entity == self:
if key == "left mouse down":
global pause
pause = pauseButton()
destroy(self)
class pauseButton(Button):
def __init__(self):
super().__init__(
model = "quad",
texture = pauseButtonTexture,
scale = (0.1, 0.1),
position = (-0.82, -0.4),
color = color.white,
)
def input(self, key):
if mouse.hovered_entity == self:
if key == "left mouse down":
global play
play = playButton()
destroy(self)
play = playButton()
app.run()