-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
69 lines (57 loc) · 1.64 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
/**
* Copyright (c) 2022 ZEP Co., LTD
*/
import "zep-script";
import {ScriptPlayer} from "zep-script";
const polarBear = ScriptApp.loadSpritesheet('polar-bear.png', 240, 270);
const polarBearTwo = ScriptApp.loadSpritesheet('polar-bear-2.png', 240, 270);
const DOWN_SPEED = 10;
let down_speed = 1;
ScriptApp.onLeavePlayer.Add(function(p){
})
// 플레이어가 해당 맵에 들어왔을 때 처리
ScriptApp.onJoinPlayer.Add(function (p) {
p.spawnAt(32, 20, 2);
p.sprite = polarBear;
p.moveSpeed = 20;
p.tag = {
alive: true,
ready: false
}
p.title = 'READY!';
p.sendUpdated();
setTimeout(function () {
p.tag.ready = true;
p.title = 'SAVE ME!!';
p.sendUpdated();
}, 4000)
});
ScriptApp.addOnKeyDown(88, function (p) { // 왼쪽 화살표
if(!p.tag.ready) return ;
p.spawnAt(p.tileX, p.tileY-1, 2);
})
ScriptApp.onStart.Add(function(){
});
ScriptApp.onUpdate.Add(function(dt){
ScriptApp.showCenterLabel("Press 'x' to save the polar bear!");
down_speed++;
let players = ScriptApp.players;
players.forEach(player => {
if(player.tileY >= ScriptMap.height) {
player.tag.alive = false;
player.title = `I'll be back..`;
player.sendUpdated();
}
})
if(down_speed >= DOWN_SPEED) {
down_speed = 1;
players.forEach(player => {
if(!player.tag.ready) return;
if(!player.tag.alive) return;
if(player.sprite == polarBear) player.sprite = polarBearTwo;
else player.sprite = polarBear;
player.sendUpdated();
player.spawnAt(player.tileX, player.tileY+1, 2);
});
}
});