-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
78 lines (78 loc) · 2.38 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
sprites.onOverlap(SpriteKind.Player, SpriteKind.Food, function (sprite, otherSprite) {
mySprite2.setPosition(Math.randomRange(10, 150), 0)
mySprite2.vy = 40
mySprite2.ay = 30
info.changeScoreBy(1)
music.baDing.play()
})
let mySprite2: Sprite = null
info.setScore(0)
let mySprite = sprites.create(img`
. . . . . . f f f f . . . . . .
. . . . f f f 2 2 f f f . . . .
. . . f f f 2 2 2 2 f f f . . .
. . f f f e e e e e e f f f . .
. . f f e 2 2 2 2 2 2 e e f . .
. . f e 2 f f f f f f 2 e f . .
. . f f f f e e e e f f f f . .
. f f e f b f 4 4 f b f e f f .
. f e e 4 1 f d d f 1 4 e e f .
. . f e e d d d d d d e e f . .
. . . f e e 4 4 4 4 e e f . . .
. . e 4 f 2 2 2 2 2 2 f 4 e . .
. . 4 d f 2 2 2 2 2 2 f d 4 . .
. . 4 4 f 4 4 5 5 4 4 f 4 4 . .
. . . . . f f f f f f . . . . .
. . . . . f f . . f f . . . . .
`, SpriteKind.Player)
mySprite.y += 110
controller.moveSprite(mySprite, 100, 0)
mySprite.setFlag(SpriteFlag.StayInScreen, true)
scene.setBackgroundColor(7)
mySprite2 = sprites.create(img`
. . 2 2 b b b b b . . . . . . .
. 2 b 4 4 4 4 4 4 b . . . . . .
2 2 4 4 4 4 d d 4 4 b . . . . .
2 b 4 4 4 4 4 4 d 4 b . . . . .
2 b 4 4 4 4 4 4 4 d 4 b . . . .
2 b 4 4 4 4 4 4 4 4 4 b . . . .
2 b 4 4 4 4 4 4 4 4 4 e . . . .
2 2 b 4 4 4 4 4 4 4 b e . . . .
. 2 b b b 4 4 4 b b b e . . . .
. . e b b b b b b b e e . . . .
. . . e e b 4 4 b e e e b . . .
. . . . . e e e e e e b d b b .
. . . . . . . . . . . b 1 1 1 b
. . . . . . . . . . . c 1 d d b
. . . . . . . . . . . c 1 b c .
. . . . . . . . . . . . c c . .
`, SpriteKind.Food)
mySprite2.setPosition(80, 110)
info.setLife(3)
game.onUpdate(function () {
if (mySprite2.top > 120) {
mySprite2 = sprites.create(img`
. . 2 2 b b b b b . . . . . . .
. 2 b 4 4 4 4 4 4 b . . . . . .
2 2 4 4 4 4 d d 4 4 b . . . . .
2 b 4 4 4 4 4 4 d 4 b . . . . .
2 b 4 4 4 4 4 4 4 d 4 b . . . .
2 b 4 4 4 4 4 4 4 4 4 b . . . .
2 b 4 4 4 4 4 4 4 4 4 e . . . .
2 2 b 4 4 4 4 4 4 4 b e . . . .
. 2 b b b 4 4 4 b b b e . . . .
. . e b b b b b b b e e . . . .
. . . e e b 4 4 b e e e b . . .
. . . . . e e e e e e b d b b .
. . . . . . . . . . . b 1 1 1 b
. . . . . . . . . . . c 1 d d b
. . . . . . . . . . . c 1 b c .
. . . . . . . . . . . . c c . .
`, SpriteKind.Food)
mySprite2.vy = 40
mySprite2.ay = 30
mySprite.say("Oh! No!", 500)
music.siren.play()
info.changeLifeBy(-1)
}
})