-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsneak.kv
297 lines (235 loc) · 8.31 KB
/
sneak.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
#: import defs defs
SneakGame:
<SneakGame>:
gameworld: gameworld
app: app
camera: gameview
fear: fear
lives: self.lives
points: self.points
steering: steering
levelnum: 0
stones_in_game: self.stones_in_game
arrow_tip: self.arrow_tip
arrow_angle: 45
GameWorld:
id: gameworld
gamescreenmanager: gamescreenmanager
phy: cymunk_physics
size_of_gameworld: 100*1024
zones: {'general': 20000}
PositionSystem2D:
system_id: 'position'
gameworld: gameworld
zones: ['general']
RotateSystem2D:
system_id: 'rotate'
gameworld: gameworld
zones: ['general']
RotateRenderer:
system_names: ['renderer', 'position', 'rotate']
system_id: 'renderer'
gameworld: gameworld
zones: ['general']
shader_source: 'assets/glsl/positionrotateshader.glsl'
gameview: 'gameview'
GameView:
id: gameview
system_id: 'gameview'
size: root.size
pos: root.pos
window_size: root.size
do_scroll: True
do_scroll_lock: False
gameworld: gameworld
updateable: True
camera_speed_multiplier: 5
camera_scale: 1.0
canvas:
PushMatrix
Rotate:
angle: root.arrow_angle
origin: root.arrow_tip if root.arrow_tip else (0, 0)
Color:
rgba: 1, 0, 0, 1
Line:
width: 10
points: [root.arrow_tip[0] - 20, root.arrow_tip[1] - 50, root.arrow_tip[0], root.arrow_tip[1], root.arrow_tip[0] + 20, root.arrow_tip[1] - 50] if root.arrow_tip else []
PopMatrix
SneakSteeringSystem:
id: steering
system_id: 'steering'
gameworld: gameworld
game: root
fear: fear
camera: gameview
updateable: True
joystick: gameworld.gamescreenmanager.joystick
CymunkPhysics:
id: cymunk_physics
system_id: 'cymunk_physics'
gameworld: gameworld
zones: ['general']
damping: 0.15
Fear:
id: fear
system_id: 'fear'
gameworld: gameworld
game: root
updateable: True
AnimationSystem:
id: animation
gameworld: gameworld
system_id: 'animation'
zones: ['general']
GameScreenManager:
id: gamescreenmanager
size: root.size
pos: root.pos
gameworld: gameworld
<GameScreenManager>:
game: self.parent
steering: self.parent.steering
joystick: joy
GameScreen:
id: main_screen
name: 'gameover'
BoxLayout:
Widget:
BoxLayout:
orientation: 'vertical'
Label:
text: "Game Over"
font_size: '70sp'
Label:
font_size: '50sp'
text: "Points: %s"%root.game.points
BoxLayout:
Widget:
Button:
font_size: '30sp'
text: "Play Again"
on_press: root.game.advance_level(reset=True)
size_hint: 1.0, 0.3
background_color: 1, 1, 1, 0.1
Widget:
Widget:
Widget:
GameScreen:
id: levelnum_screen
name: 'levelnum'
BoxLayout:
orientation: 'vertical'
Widget:
size_hint: 0.1, 0.1
Label:
text: "Level %s"%(root.game.levelnum + 1)
font_size: self.width/14
size_hint: 1, None
height: self.texture_size[1]
Widget:
size_hint: 0.1, 0.1
BoxLayout: #horizontal
Widget:
size_hint: 0.2, 0.1
BoxLayout:
orientation: 'vertical'
size_hint: None, 1
width: '300sp'
ToggleButton:
id: use_accel
on_state: root.steering.set_accelerometer(self)
size: self.texture_size
text: "use accelerometer"
font_size: '20sp'
size_hint: 1.0, None
height: self.texture_size[1] + sp(30)
Widget:
size_hint: 0.1, 0.3
Button:
font_size: '30sp'
text: "Start (easy)" if root.game.levelnum == 0 else "Continue"
on_press: root.game.on_play()
# text_size: self.size
Button:
text: "Start (hard)" if root.game.levelnum == 0 else "..."
disabled: root.game.levelnum != 0
on_press: root.game.on_play(hard=True)
Widget:
size_hint: 0.1, 0.2
Widget:
size_hint: 0.2, 0.1
BoxLayout:
orientation: 'vertical'
size_hint: 0.5, 1
Widget:
size_hint: 0.1, 0.1
Label:
text_size: self.width, None
text: "Goal:\n\nAvoid creatures and collect all stones.\n\nSteering: \n - Use touch/mouse and shout button,\n - or use accelerometer (checkbox below)" + "\n - or use keyboard: \n -[left]/[right] - change direction,\n - [up] - run,\n - [space] - shout\n\n[f11]/[alt-enter] - toggle fullscreen"
font_size: min(self.size)/19
Widget:
size_hint: 0.1, 0.1
Widget:
size_hint: 0.1, None
GameScreen:
id: main_screen
name: 'main'
FloatLayout:
# canvas:
# Color:
# rgba: 1, 0, 0, 0.3
# Rectangle:
# pos: self.pos
# size: self.size
pos: self.pos
size: self.size
VirtualJoystick:
# canvas:
# Color:
# rgba: 0, 1, 0, 0.3
# Rectangle:
# pos: self.pos
# size: self.size
id: joy
size: 200, 200
size_hint: None, None
pos: -800, -400 # off the screen by default
BoxLayout:
orientation: 'vertical'
BoxLayout:
size_hint: 1.0, 0.1
orientation: 'horizontal'
Label:
text: "Points: %s"%root.game.points
Label:
text: "Stones left: %s" % root.game.num_stones_left
Widget:
Label:
text: "Lives: %s"%root.game.lives
Label:
text: "Level: %s"%(root.game.levelnum + 1)
Widget:
size_hint: 1.0, 0.9
BoxLayout:
size_hint: 1.0, 0.2
orientation: 'horizontal'
Button:
size_hint: 0.1, 1.0
on_press: root.game.fear.shout()
background_color: 1, 1, 1, 0.1
Image:
source: "atlas://assets/objects/shout-1"
center_x: self.parent.center_x
center_y: self.parent.center_y
Widget:
<Label>:
font_name: "assets/fonts/how-cute.ttf"
font_size: '20sp'
color: 1.0, 1.0, 0.5, 0.8
<Button>:
font_size: '25sp'
background_color: 1.0, 1, 0, 0.2
<ToggleButton>:
color: (1, 0, 0, 1) if self.state == 'down' else (1, 1, 0.5, 0.8)
background_color: (1, 0, 0, 1) if self.state == 'down' else (0, 1, 0, 0.1)