-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB-10-2
52 lines (38 loc) · 1.32 KB
/
B-10-2
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
import pyxel
pyxel.init(200,200)
ballx = [pyxel.rndi(0,199),pyxel.rndi(0,199),pyxel.rndi(0,199)]
bally = [0,0,0]
angle = [pyxel.rndi(30,150),pyxel.rndi(30,150),pyxel.rndi(30,150)]
vx = [pyxel.cos(angle[0]),pyxel.cos(angle[1]),pyxel.cos(angle[2])]
vy = [pyxel.sin(angle[0]),pyxel.sin(angle[1]),pyxel.sin(angle[2])]
padx = 100
speed = [1,1,1]
point = 0
t = [0,0,0]
def update():
global ballx, bally, vx, vy, padx, speed, point, t
padx = pyxel.mouse_x
for i in range(0, 3):
ballx[i] += vx[i] * speed[i]
bally[i] += vy[i] * speed[i]
if bally[i] >= 200:
ballx[i] = pyxel.rndi(0,199)
bally[i] = 0
angle[i] = pyxel.rndi(30, 150)
vx[i] = pyxel.cos(angle[i])
vy[i] = pyxel.sin(angle[i])
speed[i] += 1
t[i] = 0
if ballx[i] >= 200 or ballx[i] <= 0:
vx[i] *= -1
if bally[i] >= 195 and padx-20 <= ballx[i] <= padx+20 and t[i] == 0:
t[i] = 1
point += 1 #list number = [i].
def draw():
global ballx, bally, vx, vy, padx, point
pyxel.cls(7)
pyxel.text(10, 10, "score : " + str(point), 0)
pyxel.rect(padx-20, 195, 40, 5, 14)
for i in range(0, 3):
pyxel.circ(ballx[i], bally[i], 10, 6)
pyxel.run(update, draw)