-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB-10-3
66 lines (48 loc) · 1.58 KB
/
B-10-3
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
import pyxel
pyxel.init(200,200)
ballx = [pyxel.rndi(0,199)]
bally = [0]
angle = [pyxel.rndi(30,150)]
vx = [pyxel.cos(angle[0])]
vy = [pyxel.sin(angle[0])]
padx = 100
speed = [1]
point = 0
t = [0]
def update():
global ballx, bally, vx, vy, padx, speed, point, t
padx = pyxel.mouse_x
for i in range(0, len(ballx)):
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
if point == 10 * len(ballx):
for i in range(len(ballx)):
speed[i] = 1
ballx.append(pyxel.rndi(0,199))
bally.append(0)
angle.append(pyxel.rndi(30,150))
vx.append(pyxel.cos(angle[len(ballx)-1]))
vy.append(pyxel.sin(angle[len(ballx)-1]))
speed.append(1)
t.append(0)
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, len(ballx)):
pyxel.circ(ballx[i], bally[i], 10, 6)
pyxel.run(update, draw)