-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattractor.kv
499 lines (396 loc) · 12.1 KB
/
attractor.kv
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
#: kivy 1.10.0
<AttractorGame>:
id: game
gameworld: gameworld
GameWorld:
id: gameworld
gamescreenmanager: gamescreenmanager
size_of_gameworld: 200 * 1024
zones: {'general': 40000}
system_count: 17
PositionSystem2D:
system_id: 'position'
gameworld: gameworld
zones: ['general']
RotateSystem2D:
system_id: 'rotate'
gameworld: gameworld
zones: ['general']
CymunkPhysics:
id: cymunk_physics
system_id: 'cymunk_physics'
gameworld: gameworld
zones: ['general']
AnimationSystem:
id: animation
system_id: 'animation'
gameworld: gameworld
updateable: True
zones: ['general']
RotateRenderer:
system_id: 'rotate_renderer'
gameworld: gameworld
frame_count: 2
updateable: True
force_update: False
gameview: 'play_camera'
shader_source: 'resources/shaders/p_r_shader.glsl'
zones: ['general']
RotateRenderer:
system_id: 'bg_renderer'
gameworld: gameworld
frame_count: 2
updateable: True
force_update: False
gameview: 'play_camera'
shader_source: 'resources/shaders/p_r_shader.glsl'
zones: ['general']
RotateRenderer:
system_id: 'mid_renderer'
gameworld: gameworld
frame_count: 2
updateable: True
force_update: False
gameview: 'play_camera'
shader_source: 'resources/shaders/p_r_shader.glsl'
zones: ['general']
GameMap:
id: gamemap
gameworld: gameworld
map_size: 100 * 40, 100 * 40
zones: ['general']
GameView:
id: play_camera
system_id: 'play_camera'
gameworld: gameworld
currentmap: gamemap
camera_scale: 0.75
camera_speed_multiplier: 10
size: root.size
window_size: root.size
pos: root.pos
updateable: True
do_scroll: True
do_scroll_lock: False
focus_entity: True
entity_to_focus: game.attractor_id
touch_pass_through: True
render_system_order: ['bg_renderer', 'mid_renderer','rotate_renderer']
zones: ['general']
ChargeSystem:
system_id: 'charge'
gameworld: gameworld
zones: ['general']
updateable: True
PoleChangerSystem:
system_id: 'pole_changer'
gameworld: gameworld
zones: ['general']
updateable: True
FinishSystem:
system_id: 'finish'
gameworld: gameworld
zones: ['general']
updateable: True
LevelEditorSystem:
system_id: 'editor'
gameworld: gameworld
zones: ['general']
updateable: True
AttractorSystem:
system_id: 'attractor'
gameworld: gameworld
zones: ['general']
updateable: True
GameScreenManager:
id: gamescreenmanager
gameworld: gameworld
size: root.size
pos: root.pos
<GameScreenManager>:
play_screen: play_screen
MenuScreen:
id: menu_screen
PlayScreen:
id: play_screen
EditorScreen:
id: editor_screen
FinishScreen:
id: finish_screen
<MenuScreen@GameScreen>:
level_buttons: buttons
scroll_container: scroll_buttons
name: 'menu_screen'
FloatLayout:
BoxLayout:
id: button_container
canvas.before:
Color:
rgba: 0.1, 0.1, 0.1, 0.6
Rectangle:
size: self.parent.size
pos: self.parent.pos
orientation: 'vertical'
padding: 30
spacing: 10
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
size_hint: 0.4, 0.2
BetterButton:
text: 'Levels'
on_release: app.game.open_level_select_menu()
BetterButton:
id: editor_button
text: 'Editor'
on_release: app.game.go_to_editor_screen()
ScrollView:
id: scroll_buttons
size_hint: 0.5, 1
pos: self.parent.width, 0
do_scroll_x: False
canvas.before:
Color:
rgba: 0.1, 0.1, 0.1, 0.75
Rectangle:
size: self.parent.size
pos: self.parent.pos
GridLayout:
id: buttons
size_hint_x: 1
cols: 2
padding: '20dp', '20dp'
spacing: '5dp', '5dp'
row_default_height: '40dp'
row_force_default: True
size_hint_y: None
<PlayScreen@GameScreen>:
name: 'play_screen'
id: scr
changes: changes
time: time
#:set alpha 0.15
#:set w 8
BoxLayout:
spacing: w
orientation: 'vertical'
# Level info
BoxLayout:
padding: 5
size_hint: 1, 0.06
canvas:
Color:
rgba: 0.15, 0.15, 0.15, 1
Rectangle:
size: self.size
pos: self.pos
BetterButton:
text: "Menu"
on_release: app.game.go_to_menu_screen()
Label:
text: '[b]Time:[/b]'
markup: True
Label:
id: time
text: '0'
Label:
text: '[b]Changes:[/b]'
markup: True
Label:
id: changes
text: '0'
BetterButton:
text: "Reset"
on_release: app.game.reset_attractor()
# Change buttons
BoxLayout:
size_hint: 1, 0.94
orientation: 'horizontal'
spacing: 5
canvas:
# Red
Color:
rgba: 0.894, 0.243, 0.282, alpha
Line:
cap: 'none'
width: w
points: [0, 0, 0, self.height]
Line:
cap: 'none'
width: w/2
points: [0, self.height + w/2, 0.325 * self.width, self.height + w/2]
# Gray
Color:
rgba: 0.314, 0.376, 0.412, alpha
Line:
cap: 'none'
width: w/2
points: [0.33 * self.width, self.height + w/2, (1 - 0.33) * self.width, self.height + w/2]
# Blue
Color:
rgba: 0.118, 0.490, 0.694, alpha
Line:
cap: 'none'
width: w
points: [self.width, 0, self.width, self.height]
Line:
cap: 'none'
width: w/2
points: [self.width, self.height + w/2, (1 - 0.325) * self.width, self.height + w/2]
BetterButton:
on_press: app.game.change_attractor_charge(self, '+')
background_color: [1, 0.4, 0.4, 0.]
BetterButton:
on_press: app.game.change_attractor_charge(self, 'n')
background_color: [0.4, 0.4, 0.4, 0.]
BetterButton:
on_press: app.game.change_attractor_charge(self, '-')
background_color: [0.4, 0.4, 1, 0.]
<EditorScreen@GameScreen>:
name: 'editor_screen'
FloatLayout:
GridLayout:
canvas:
Color:
rgba: 0.12, 0.12, 0.12, 0.25
Rectangle:
size: self.size
pos: self.pos
size_hint: 0.2, 0.2
pos_hint: {'x': 0.8, 'y': 0.8}
cols: 3
Label:
text: ''
BetterButton:
text: "^"
on_release: app.game.editor.move_entity_to_place(0, 1)
Label:
text: ''
BetterButton:
text: "<"
on_release: app.game.editor.move_entity_to_place(-1, 0)
BetterButton:
text: "x"
on_release: app.game.editor.set_entity()
BetterButton:
text: ">"
on_release: app.game.editor.move_entity_to_place(1, 0)
Label:
text: ''
BetterButton:
text: "v"
on_release: app.game.editor.move_entity_to_place(0, -1)
Label:
text: ''
Button:
size_hint: 0.1, 0.035
pos: 0, self.parent.height - self.height
text: "Menu"
on_release: app.game.go_to_menu_screen()
Button:
size_hint: 0.1, 0.035
pos: self.parent.width/2 - self.width, self.parent.height - self.height
text: "Clear"
on_release: app.game.clear_level()
BoxLayout:
id: ui
padding: 0
spacing: 0
size_hint: 1, 0.05
orientation: 'horizontal'
pos: 0, 0
canvas:
Color:
rgba: 0.12, 0.12, 0.12, 0.85
Rectangle:
size: self.size
pos: self.pos
Label:
text: 'Grid'
TouchedTextBox:
id: grid
text: '10'
ToggleButton:
id: delete
text: 'Delete'
on_release: app.game.editor.toggle_deleting()
Label:
text: 'Level'
TouchedTextBox:
id: level_name
text: ''
Button:
text: 'Save'
on_release: app.game.save_level()
Button:
text: 'Load'
on_release: app.game.load_level()
Button:
text: 'Rotate'
on_release: app.game.editor.rotate_entity_to_place()
TouchedTextBox:
id: rotation
text: '0'
on_text: app.game.update_editor_rotation(self.text)
Label:
text: 'x'
TouchedTextBox:
id: attractor_pos_x
text: ''
Label:
text: 'y'
TouchedTextBox:
id: attractor_pos_y
text: ''
<FinishScreen@GameScreen>:
name: 'finish_screen'
BoxLayout:
padding: 10
spacing: 10
orientation: 'vertical'
size_hint: 0.5, 0.3
pos_hint: {'center_x': 0.5, 'y': 0}
canvas.before:
Color:
rgba: 0.12, 0.12, 0.12, 1
Rectangle:
size: self.size
pos: self.pos
Label:
canvas.before:
Color:
rgba: 0.15, 0.15, 0.15, 1
Rectangle:
size: self.size
pos: self.pos
text: '[b]Complete![/b]'
markup: True
size_hint_y: 0.4
GridLayout:
canvas.before:
Color:
rgba: 0.15, 0.15, 0.15, 1
Rectangle:
size: self.size
pos: self.pos
cols: 2
Label:
text: '[b]Time:[/b]'
markup: True
Label:
id: time
text: ''
Label:
text: '[b]Changes:[/b]'
markup: True
Label:
id: changes
text: ''
BoxLayout:
size_hint: 1, 0.25
pos_hint: {'center_x': 0.5, 'bottom': 1}
spacing: 5
BetterButton:
text: "Menu"
on_release: app.game.go_to_menu_screen()
BetterButton:
text: "Continue"
on_release: app.game.go_to_next_level()