-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
178 lines (178 loc) · 5.93 KB
/
main.ts
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
enum ActionKind {
Walking,
Idle,
Jumping
}
namespace SpriteKind {
export const Gap = SpriteKind.create()
}
sprites.onOverlap(SpriteKind.Player, SpriteKind.Gap, function (sprite, otherSprite) {
if (otherSprite.right - sprite.left < 2) {
info.changeScoreBy(1)
}
})
sprites.onOverlap(SpriteKind.Player, SpriteKind.Projectile, function (sprite, otherSprite) {
game.over(false, effects.confetti)
})
controller.anyButton.onEvent(ControllerButtonEvent.Pressed, function () {
mySprite.vy = -100
animation.setAction(mySprite, ActionKind.Jumping)
mySprite.startEffect(effects.rings, 300)
})
let projectile: Sprite = null
let gapSprite: Sprite = null
let gapImage: Image = null
let bottomImage: Image = null
let topImage: Image = null
let gap = 0
let mySprite: Sprite = null
scene.setBackgroundColor(8)
info.setScore(0)
effects.blizzard.startScreenEffect()
mySprite = sprites.create(assets.image`norsys1`, SpriteKind.Player)
mySprite.ay = 300
let anim = animation.createAnimation(ActionKind.Jumping, 25)
anim.addAnimationFrame(img`
7 7 f f f f f f f f f f f f 7 7
7 f f f f 8 8 8 8 8 f f f f f 7
7 f f f 8 f f f f f 8 f f f f f
f f f f 8 f f f f f 8 f f f f f
f f 7 7 7 7 7 f 2 2 2 2 2 f f f
f 7 f f 8 f f 7 f f 8 f f 2 f f
f 7 f f 8 f f 7 f f 8 f f 2 f f
f 7 f f f 8 8 8 8 8 f f f 2 f f
f 7 f f f f f 8 f f f f f 2 f f
f 7 f f f f f 8 f f f f f 2 f f
f f 7 7 7 7 7 8 2 2 2 2 2 f f f
f f f 7 7 7 7 8 2 f f f f f f f
7 7 7 7 8 8 8 8 2 f f f f f f f
7 8 8 8 8 2 2 2 2 f f f f f f f
8 8 2 2 2 2 f f f f f f f f f 7
8 2 2 f f f f f f f f f f f 7 7
`)
anim.addAnimationFrame(img`
7 7 f f f f f f f f f f f f 7 7
7 f f f f 8 8 8 8 8 f f f f f 7
7 f f f 8 f f f f f 8 f f f f f
f f f f 8 f f f f f 8 f f f f f
f f 7 7 7 7 7 f 2 2 2 2 2 f f f
f 7 f f 8 f f 7 f f 8 f f 2 f f
f 7 f f 8 f f 7 f f 8 f f 2 f f
f 7 f f f 8 8 8 8 8 f f f 2 f f
f 7 f f f f f 8 f f f f f 2 f f
f 7 f f f f f 8 f f f f f 2 f f
f f 7 7 7 7 7 8 2 2 2 2 2 f f f
f f f 7 7 7 7 8 2 f f f f f f f
7 7 7 7 8 8 8 8 2 f f f f f f f
7 8 8 8 8 2 2 2 2 f f f f f f f
8 8 2 2 2 2 f f f f f f f f f 7
8 2 2 f f f f f f f f f f f 7 7
`)
anim.addAnimationFrame(img`
7 7 f f f f f f f f f f f f 7 7
7 f f f f 8 8 8 8 8 f f f f f 7
7 f f f 8 f f f f f 8 f f f f f
f f f f 8 f f f f f 8 f f f f f
f f 7 7 7 7 7 f 2 2 2 2 2 f f f
f 7 f f 8 f f 7 f f 8 f f 2 f f
f 7 f f 8 f f 7 f f 8 f f 2 f f
f 7 f f f 8 8 8 8 8 f f f 2 f f
f 7 f f f f f 8 f f f f f 2 f f
f 7 f f f f f 8 f f f f f 2 f f
f f 7 7 7 7 7 8 2 2 2 2 2 f f f
f f f 7 7 7 7 8 2 f f f f f f f
7 7 7 7 8 8 8 8 2 f f f f f f f
7 8 8 8 8 2 2 2 2 f f f f f f f
8 8 2 2 2 2 f f f f f f f f f 7
8 2 2 f f f f f f f f f f f 7 7
`)
anim.addAnimationFrame(img`
7 7 f f f f f f f f f f f f 7 7
7 f f f f 8 8 8 8 8 f f f f f 7
7 f f f 8 f f f f f 8 f f f f f
f f f f 8 f f f f f 8 f f f f f
f f 7 7 7 7 7 f 2 2 2 2 2 f f f
f 7 f f 8 f f 7 f f 8 f f 2 f f
f 7 f f 8 f f 7 f f 8 f f 2 f f
f 7 f f f 8 8 8 8 8 f f f 2 f f
f 7 f f f f f 8 f f f f f 2 f f
f 7 f f f f f 8 f f f f f 2 f f
f f 7 7 7 7 7 8 2 2 2 2 2 f f f
f f f f 7 7 8 8 f f f f 2 f f f
f f f f 7 8 8 f f f f 2 2 f f f
f f f 7 7 8 f f f f 2 2 f f f f
f f f 7 8 8 f f 2 2 2 f f f f 7
7 7 7 7 8 2 2 2 2 f f f f f 7 7
`)
anim.addAnimationFrame(img`
7 7 f f f f f f f f f f f f 7 7
7 f f f f 8 8 8 8 8 f f f f f 7
7 f f f 8 f f f f f 8 f f f f f
f f f f 8 f f f f f 8 f f f f f
f f 7 7 7 7 7 f 2 2 2 2 2 f f f
f 7 f f 8 f f 7 f f 8 f f 2 f f
f 7 f f 8 f f 7 f f 8 f f 2 f f
f 7 f f f 8 8 8 8 8 f f f 2 f f
f 7 f f f f f 8 f f f f f 2 f f
f 7 f f f f f 8 f f f f f 2 f f
f f 7 7 7 7 7 8 2 2 2 2 2 f f f
f f f f 7 7 8 8 f f f f 2 f f f
f f f f 7 8 8 f f f f 2 2 f f f
f f f 7 7 8 f f f f 2 2 f f f f
f f f 7 8 8 f f 2 2 2 f f f f 7
7 7 7 7 8 2 2 2 2 f f f f f 7 7
`)
anim.addAnimationFrame(img`
7 7 f f f f f f f f f f f f 7 7
7 f f f f 8 8 8 8 8 f f f f f 7
7 f f f 8 f f f f f 8 f f f f f
f f f f 8 f f f f f 8 f f f f f
f f 7 7 7 7 7 f 2 2 2 2 2 f f f
f 7 f f 8 f f 7 f f 8 f f 2 f f
f 7 f f 8 f f 7 f f 8 f f 2 f f
f 7 f f f 8 8 8 8 8 f f f 2 f f
f 7 f f f f f 8 f f f f f 2 f f
f 7 f f f f f 8 f f f f f 2 f f
f f 7 7 7 7 7 8 2 2 2 2 2 f f f
f f f 7 7 7 7 8 2 f f f f f f f
7 7 7 7 8 8 8 8 2 f f f f f f f
7 8 8 8 8 2 2 2 2 f f f f f f f
8 8 2 2 2 2 f f f f f f f f f 7
8 2 2 f f f f f f f f f f f 7 7
`)
animation.attachAnimation(mySprite, anim)
game.onUpdate(function () {
if (mySprite.vy > 0) {
animation.setAction(mySprite, ActionKind.Idle)
}
if (mySprite.bottom > 120 || mySprite.top < 0) {
game.over(false, effects.confetti)
}
})
game.onUpdateInterval(1500, function () {
gap = randint(0, 3)
if (gap == 0) {
topImage = assets.image`potaux 1 haut`
bottomImage = assets.image`potaux bas 1`
} else if (gap == 1) {
topImage = assets.image`haut 2`
bottomImage = assets.image`bas 2`
} else if (gap == 2) {
topImage = assets.image`haut 3`
bottomImage = assets.image`bas 3`
} else {
topImage = assets.image`haut 4`
bottomImage = assets.image`bas 4`
}
gapImage = image.create(2, scene.screenHeight())
gapImage.fill(1)
gapSprite = sprites.create(gapImage, SpriteKind.Gap)
gapSprite.setFlag(SpriteFlag.AutoDestroy, true)
gapSprite.setFlag(SpriteFlag.Invisible, true)
gapSprite.left = scene.screenWidth()
gapSprite.vx = -45
projectile = sprites.createProjectileFromSide(topImage, -45, 0)
projectile.top = 0
projectile = sprites.createProjectileFromSide(bottomImage, -45, 0)
projectile.bottom = scene.screenHeight()
})