-
Notifications
You must be signed in to change notification settings - Fork 1
/
spacepilgrim.kv
133 lines (105 loc) · 2.97 KB
/
spacepilgrim.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
#:import metrics kivy.metrics
#:import Window kivy.core.window.Window
#:import Vector kivy.vector.Vector
SpacePilgrimGame:
<Explosion>:
size: 128, 128
canvas:
Ellipse:
texture: self.texture
pos: self.pos
size: self.size
<Asteroid>:
size: 90, 90
canvas:
Ellipse:
source: "images/asteroid_blue.png"
pos: self.pos
size: self.size
canvas.before:
PushMatrix
Rotate:
angle: self.angle
origin: self.center
canvas.after:
PopMatrix
<Shot>
size: 10, 10
canvas:
Ellipse:
source: "images/shot1.png"
pos: self.pos
size: self.size
<Spaceship>:
ship_stop: "images/ship_stop.png"
ship_fly: "images/ship_fly.png"
size: 90, 90
canvas.before:
PushMatrix
Rotate:
angle: self.angle
origin: self.center
canvas.after:
PopMatrix
canvas:
Ellipse:
source:
self.ship_fly if self.thrust else self.ship_stop
pos: self.pos
size: self.size
<SpaceshipStatus>:
Label:
pos: Vector(*Window.size) - Vector(metrics.dp(260), 100)
text: "Lives {:<5} Points {}".format(root.spaceship.lives, root.spaceship.points)
font_size: "23dp"
font_name: 'data/fonts/RobotoMono-Regular.ttf'
<Splash>:
background_normal: "images/splash.png"
background_down: "images/splash.png"
on_press: self.parent.game_start()
size: 400, 300
pos: (Vector(*Window.size) - Vector(*self.size)) / 2
<ScreenButtonsLayout>:
size: Window.size
Button:
text: "Left"
on_press: root.parent.spaceship.turn_left()
on_release: root.parent.spaceship.stop_rotation()
pos: metrics.cm(0.5), metrics.cm(0.5)
size: metrics.cm(1), metrics.cm(1)
Button:
text: "Right"
on_press: root.parent.spaceship.turn_right()
on_release: root.parent.spaceship.stop_rotation()
pos: metrics.cm(2.5), metrics.cm(0.5)
size: metrics.cm(1), metrics.cm(1)
Button:
text: "Up"
on_press: root.parent.spaceship.thrust_on()
on_release: root.parent.spaceship.thrust_off()
pos: metrics.cm(1.5), metrics.cm(1.5)
size: metrics.cm(1), metrics.cm(1)
Button:
text: "Fire"
on_press: root.parent.spaceship.shot()
pos: root.size[0] - metrics.cm(1.5), metrics.cm(0.5)
size: metrics.cm(1), metrics.cm(1)
<Background@Widget>:
source: ''
canvas.before:
Rectangle:
size: self.size
source: self.source
<AnimatedBackground>:
canvas:
Rectangle:
size: self.size
pos: self.pos
texture: self.background
<SpacePilgrimGame>:
Background:
source: "images/nebula_blue.png"
size: root.size
AnimatedBackground:
source: "images/debris.png"
size: root.size