-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpong.kv
77 lines (63 loc) · 1.59 KB
/
pong.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
#:kivy 1.0.9
<PongBall>:
size: 50, 50
canvas:
Ellipse:
pos: self.pos
size: self.size
<PongPaddle>:
size: 25, 200
canvas:
Color:
rgba:self.color
Rectangle:
pos:self.pos
size:self.size
<PongGame>:
ball: pong_ball
player1: player_left
player2: player_right
# playButton: play_pause
canvas:
Rectangle:
pos: self.center_x - 5, 0
size: 10, self.height
BoxLayout:
center_x: root.center_x
top: root.top - 10
size: 500, 150
padding: 10
spacing: 10
Button:
id: play_pause
text: 'Pause' if self.parent.parent.playing else 'Play'
on_press: self.parent.parent.play_pause()
Button:
id: reset
text: 'Reset'
on_press: self.parent.parent.reset()
Button:
# id: reset
text: 'Exit'
# on_press: self.parent.parent.reset()
Label:
font_size: 70
center_x: root.width / 4
top: root.top - 50
text: str(root.player1.score)
Label:
font_size: 70
center_x: root.width * 3 / 4
top: root.top - 50
text: str(root.player2.score)
PongBall:
id: pong_ball
center: root.center
PongPaddle:
id: player_left
x: root.x
center_y: root.center_y
PongPaddle:
id: player_right
x: root.width - self.width
center_y: root.center_y