-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
109 lines (104 loc) · 3.35 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
def on_a_pressed():
global mySprite2
sprites.destroy_all_sprites_of_kind(SpriteKind.projectile, effects.ashes, 200)
mySprite2 = sprites.create_projectile_from_sprite(assets.image("""
Fish1
"""),
mySprite,
mySprite.vx,
mySprite.vy)
animation.run_image_animation(mySprite2,
assets.animation("""
MovingFish
"""),
200,
True)
music.play(music.create_sound_effect(WaveShape.SQUARE,
200,
1,
255,
0,
100,
SoundExpressionEffect.NONE,
InterpolationCurve.CURVE),
music.PlaybackMode.UNTIL_DONE)
mySprite2.lifespan = 1200
controller.A.on_event(ControllerButtonEvent.PRESSED, on_a_pressed)
def on_on_overlap(sprite, otherSprite):
info.change_life_by(-1)
music.play(music.melody_playable(music.power_down),
music.PlaybackMode.IN_BACKGROUND)
pause(1000)
sprites.on_overlap(SpriteKind.enemy, SpriteKind.player, on_on_overlap)
def on_life_zero():
music.stop_all_sounds()
game.game_over(False)
music.play(music.string_playable("C5 A B G A F G E ", 300),
music.PlaybackMode.IN_BACKGROUND)
game.set_game_over_effect(False, effects.melt)
mySprite.start_effect(effects.disintegrate, 500)
mySprite.destroy()
game.set_game_over_message(False, "The shark got you!")
info.on_life_zero(on_life_zero)
def on_on_overlap2(sprite2, otherSprite2):
global SharkLifes, myEnemy
SharkLifes += -1
info.change_score_by(100)
music.play(music.melody_playable(music.ba_ding),
music.PlaybackMode.IN_BACKGROUND)
pause(750)
music.play(music.create_sound_effect(WaveShape.SINE,
200,
600,
255,
0,
150,
SoundExpressionEffect.NONE,
InterpolationCurve.LINEAR),
music.PlaybackMode.UNTIL_DONE)
myEnemy = sprites.create(assets.image("""
Shark1
"""), SpriteKind.enemy)
myEnemy.set_position(randint(0, 160), randint(0, 120))
animation.run_image_animation(myEnemy, assets.animation("""
FishMoving
"""), 300, True)
myEnemy.follow(mySprite, randint(1, 10))
sprites.on_overlap(SpriteKind.projectile, SpriteKind.enemy, on_on_overlap2)
mySprite2: Sprite = None
myEnemy: Sprite = None
mySprite: Sprite = None
scene.camera_follow_sprite(mySprite)
music.play(music.string_playable("E B C5 A B G A F ", 200),
music.PlaybackMode.LOOPING_IN_BACKGROUND)
info.set_life(3)
music.set_volume(100)
scene.set_background_image(assets.image("""
Earth
"""))
myEnemy = sprites.create(assets.image("""
Shark
"""), SpriteKind.enemy)
animation.run_image_animation(myEnemy, assets.animation("""
FishMoving
"""), 300, True)
SharkLifes = 7
myEnemy.set_position(160, 120)
myEnemy.set_bounce_on_wall(True)
mySprite = sprites.create(assets.image("""
Shiba
"""), SpriteKind.player)
mySprite.set_scale(0.5, ScaleAnchor.MIDDLE)
controller.move_sprite(mySprite, 30, 30)
mySprite.set_bounce_on_wall(True)
mySprite.say_text("Go!")
game.splash("Scape the shark!")
game.splash("Use A to shoot fish!")
myEnemy.follow(mySprite, randint(1, 10))
def on_forever():
if SharkLifes <= 0:
music.stop_all_sounds()
game.game_over(True)
game.set_game_over_effect(True, effects.confetti)
game.set_game_over_message(True, "YOU WIN!")
forever(on_forever)