-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
58 lines (46 loc) · 1.75 KB
/
main.py
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
def on_pin_pressed_p0():
my_sprite = game.create_sprite(2, 4)
game.set_score(0)
def on_button_pressed_a():
my_sprite.change(LedSpriteProperty.X, -1)
input.on_button_pressed(Button.A, on_button_pressed_a)
def on_button_pressed_b():
my_sprite.change(LedSpriteProperty.X, 1)
input.on_button_pressed(Button.B, on_button_pressed_b)
while True:
ennemie = game.create_sprite(randint(0, 4), 0)
ennemie.set(LedSpriteProperty.BRIGHTNESS, 50)
basic.pause(800)
for index2 in range(4):
ennemie.change(LedSpriteProperty.Y, 1)
basic.pause(800)
if ennemie.is_touching_edge():
game.game_over()
ennemie.delete()
def on_button_pressed_ab():
bullet = game.create_sprite(my_sprite.get(LedSpriteProperty.X), 4)
bullet.set(LedSpriteProperty.BRIGHTNESS, 50)
for index in range(4):
basic.pause(300)
bullet.change(LedSpriteProperty.Y, -1)
if bullet.is_touching(ennemie):
ennemie.delete()
bullet.delete()
game.add_score(1)
input.on_button_pressed(Button.AB, on_button_pressed_ab)
input.on_pin_pressed(TouchPin.P0, on_pin_pressed_p0)
def on_pin_pressed_p1():
my_sprite = game.create_sprite(2, 2)
game.set_score(0)
def on_button_pressed_a2():
if my_sprite.get(LedSpriteProperty.X) == 2:
game.add_score(1)
else:
game.game_over()
input.on_button_pressed(Button.A, on_button_pressed_a2)
def on_forever2():
my_sprite.move(1)
my_sprite.if_on_edge_bounce()
basic.pause(300)
basic.forever(on_forever2)
input.on_pin_pressed(TouchPin.P1, on_pin_pressed_p1)