-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
104 lines (104 loc) · 2.37 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
let matthew0 = false
let rotation = ""
let Matthew: Sprite = null
let currentDir = ""
function animatePlayer () {
matthew0 = false
rotation = "down"
Matthew = sprites.create(assets.image`Delete`, SpriteKind.Player)
}
function playerHasStopped () {
if (currentDir != "Stop") {
currentDir = "Stop"
if (rotation == "right") {
animation.runImageAnimation(
Matthew,
assets.animation`MatthewRight0`,
200,
true
)
} else if (rotation == "down") {
animation.runImageAnimation(
Matthew,
assets.animation`MatthewDown0`,
200,
true
)
} else if (rotation == "left") {
animation.runImageAnimation(
Matthew,
assets.animation`MatthewLeft0`,
200,
true
)
} else if (rotation == "up") {
animation.runImageAnimation(
Matthew,
assets.animation`MatthewUp0`,
200,
true
)
}
}
}
function walkDown () {
if (currentDir != "Down") {
currentDir = "Down"
animation.runImageAnimation(
Matthew,
assets.animation`MatthewDown`,
200,
true
)
}
}
function walkUp () {
if (currentDir != "Up") {
currentDir = "Up"
animation.runImageAnimation(
Matthew,
assets.animation`MatthewUp`,
200,
true
)
}
}
function walkRight () {
if (currentDir != "Right") {
currentDir = "Right"
animation.runImageAnimation(
Matthew,
assets.animation`MatthewRight`,
200,
true
)
}
}
function walkLeft () {
if (currentDir != "Left") {
currentDir = "Left"
animation.runImageAnimation(
Matthew,
assets.animation`MatthewLeft`,
200,
true
)
}
}
game.onUpdateInterval(100, function () {
if (controller.right.isPressed()) {
walkRight()
rotation = "right"
} else if (controller.down.isPressed()) {
walkDown()
rotation = "down"
} else if (controller.left.isPressed()) {
walkLeft()
rotation = "left"
} else if (controller.up.isPressed()) {
walkUp()
rotation = "up"
} else {
playerHasStopped()
}
})