-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
149 lines (149 loc) · 3.51 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
namespace SpriteKind {
export const boss = SpriteKind.create()
}
sprites.onOverlap(SpriteKind.boss, SpriteKind.Projectile, function (sprite, otherSprite) {
sprites.destroy(projectile)
boss_hleth += -1
animation.runImageAnimation(
mySprite4,
[],
100,
false
)
pause(5000)
animation.runImageAnimation(
mySprite4,
[],
100,
false
)
})
controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
if (info.score() >= 3) {
mySprite4 = sprites.create(, SpriteKind.boss)
mySprite4.setPosition(146, 51)
mySprite4.changeScale(2, ScaleAnchor.Middle)
dave += 1
boss_hleth = 10
scene.setBackgroundImage()
animation.stopAnimation(animation.AnimationTypes.All, mySprite)
}
})
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
pauseUntil(() => dave == 1)
animation.runImageAnimation(
mySprite,
[],
200,
false
)
pause(500)
projectile = sprites.createProjectileFromSprite(, mySprite, 100, 0)
animation.runImageAnimation(
projectile,
[],
500,
false
)
pause(1000)
animation.runImageAnimation(
mySprite,
[],
500,
false
)
})
sprites.onOverlap(SpriteKind.Food, SpriteKind.Enemy, function (sprite, otherSprite) {
mySprite3.setVelocity(-50, 0)
mySprite2.setVelocity(-50, 0)
mySprite3.setPosition(153, randint(10, 111))
mySprite2.setPosition(153, randint(10, 111))
})
info.onLifeZero(function () {
game.gameOver(false)
})
sprites.onOverlap(SpriteKind.Player, SpriteKind.Food, function (sprite, otherSprite) {
info.changeScoreBy(1)
sprites.destroy(mySprite2)
})
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
sprites.destroy(mySprite3)
info.changeLifeBy(-1)
})
let projectile2 = 0
let mySprite5: Sprite = null
let mySprite2: Sprite = null
let mySprite3: Sprite = null
let mySprite4: Sprite = null
let projectile: Sprite = null
let dave = 0
let boss_hleth = 0
let mySprite: Sprite = null
mySprite = sprites.create(, SpriteKind.Player)
scene.setBackgroundImage()
mySprite.setPosition(10, 57)
animation.runImageAnimation(
mySprite,
[],
100,
true
)
controller.moveSprite(mySprite, 75, 75)
info.setLife(3)
mySprite.setStayInScreen(true)
boss_hleth = 1
dave = 0
forever(function () {
if (dave == 0) {
pause(3000)
mySprite3 = sprites.create(, SpriteKind.Enemy)
animation.runImageAnimation(
mySprite3,
[],
100,
true
)
} else if (dave == 1) {
pause(2000)
mySprite3 = sprites.create(, SpriteKind.Enemy)
animation.runImageAnimation(
mySprite3,
[],
100,
true
)
mySprite5 = sprites.create(, SpriteKind.Enemy)
animation.runImageAnimation(
mySprite5,
[],
100,
true
)
mySprite5.setVelocity(50, 0)
mySprite5.setPosition(4, randint(10, 111))
}
mySprite3.setVelocity(-50, 0)
mySprite3.setPosition(153, randint(10, 111))
})
forever(function () {
if (boss_hleth == 0) {
info.changeScoreBy(100)
pause(100)
game.gameOver(true)
}
})
forever(function () {
if (dave == 0) {
pause(3000)
mySprite2 = sprites.create(, SpriteKind.Food)
projectile2 = 0
mySprite2.setVelocity(-50, 0)
mySprite2.setPosition(151, randint(10, 111))
animation.runImageAnimation(
mySprite2,
[],
100,
true
)
}
})