-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB-9-2
51 lines (41 loc) · 1.2 KB
/
B-9-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
import pyxel
pyxel.init(200,200)
ballx = pyxel.rndi(0,199)
bally = 0
angle = pyxel.rndi(30, 150)
vx = pyxel.cos(angle)
vy = pyxel.sin(angle)
padx = 100
speed = 1
point = 0
t = 0
pyxel.sound(0).set(notes='A2C3', tones='TT', volumes='33', effects='NN', speed=10)
pyxel.sound(1).set(notes='C3A2', tones='TT', volumes='33', effects='NN', speed=10)
def update():
global ballx, bally, vx, vy, padx, speed, point, t
ballx += vx * speed
bally += vy * speed
padx = pyxel.mouse_x
if bally >= 200:
ballx = pyxel.rndi(0,199)
bally = 0
angle = pyxel.rndi(30, 150)
vx = pyxel.cos(angle)
vy = pyxel.sin(angle)
speed += 1
t = 0
if ballx >= 200 or ballx <= 0:
vx = -vx
if bally >= 195 and padx-20 <= ballx <= padx+20 and t == 0:#When successful、ring 0 sound.
t = 1
point += 1
pyxel.play(0,0)
if bally >= 195 and not(padx-20 <= ballx <= padx+20):
pyxel.play(0,1)
def draw():
global ballx, bally, vx, vy, padx, point
pyxel.cls(7)
pyxel.circ(ballx, bally, 10, 6)
pyxel.rect(padx-20, 195, 40, 5, 14)
pyxel.text(10, 10, "score : " + str(point), 0)
pyxel.run(update, draw)