-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
81 lines (81 loc) · 2.76 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
scene.onOverlapTile(SpriteKind.Player, myTiles.tile2, function (sprite, location) {
game.over(false)
})
scene.onOverlapTile(SpriteKind.Player, myTiles.tile4, function (sprite, location) {
startNextLevel()
})
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
newPlayer.vy = -200
})
function startNextLevel () {
for (let value of sprites.allOfKind(SpriteKind.Enemy)) {
value.destroy(effects.hearts, 200)
}
if (currentLevel == 0) {
tiles.setTilemap(tilemap`level_0`)
} else if (currentLevel == 1) {
tiles.setTilemap(tilemap`level_1`)
} else if (currentLevel == 2) {
tiles.setTilemap(tilemap`level_2`)
} else {
game.over(true)
}
tiles.placeOnRandomTile(newPlayer, myTiles.tile3)
for (let value2 of tiles.getTilesByType(myTiles.tile5)) {
newEnemy = sprites.create(img`
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . c c . c c . . . . . . . .
. . f 3 c c 3 c c c . . . . . .
. f c 3 b c 3 b c c c . . . . .
f c b b b b b b b b f f . . . .
c c 1 b b b 1 b b b f f . . . .
c b b b b b b b b c f f f . . .
c b 1 f f 1 c b b f f f f . . .
f f 1 f f 1 f b c c b b b . . .
f f f f f f f b f c c c c . . .
f f 2 2 2 2 f b f b b c c c . .
. f 2 2 2 2 2 b c c b b c . . .
. . f 2 2 2 b f f c c b b c . .
. . . f f f f f f f c c c c c .
. . . . . . . . . . . . c c c c
`, SpriteKind.Enemy)
tiles.placeOnTile(newEnemy, value2)
newEnemy.follow(newPlayer, 20)
}
currentLevel += 1
}
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
otherSprite.destroy()
if (sprite.bottom < otherSprite.y) {
sprite.vy = -100
} else {
info.changeLifeBy(-1)
}
})
let newEnemy: Sprite = null
let currentLevel = 0
let newPlayer: Sprite = null
newPlayer = sprites.create(img`
. . . . . . . . . . . . . . . .
. . . . . f f f f f f . . . . .
. . . f f e e e e f 2 f . . . .
. . f f e e e e f 2 2 2 f . . .
. . f e e e f f e e e e f . . .
. . f f f f e e 2 2 2 2 e f . .
. . f e 2 2 2 f f f f e 2 f . .
. f f f f f f f e e e f f f . .
. f f e 4 4 e b f 4 4 e e f . .
. f e e 4 d 4 1 f d d e f . . .
. . f e e e e e d d d f . . . .
. . . . f 4 d d e 4 e f . . . .
. . . . f e d d e 2 2 f . . . .
. . . f f f e e f 5 5 f f . . .
. . . f f f f f f f f f f . . .
. . . . f f . . . f f f . . . .
`, SpriteKind.Player)
controller.moveSprite(newPlayer, 150, 0)
newPlayer.ay = 500
scene.cameraFollowSprite(newPlayer)
info.setLife(3)
startNextLevel()