54 lines
1018 B
JavaScript
54 lines
1018 B
JavaScript
var asdf = require("asdf-games");
|
|
// eslint-disable-next-line no-unused-vars
|
|
const { Texture, TileSprite, entity } = asdf;
|
|
|
|
var texture = new Texture("./res/tilemap.png");
|
|
|
|
class Portal extends TileSprite {
|
|
constructor(pos, player, type, action) {
|
|
super(texture, 32, 32);
|
|
this.pos = pos;
|
|
this.scale = { x: 1, y: 1 };
|
|
this.player = player;
|
|
this.action = action;
|
|
|
|
switch (type) {
|
|
case "Door":
|
|
this.frame = { x: 1, y: 7 };
|
|
this.hitBox = {
|
|
x: 1,
|
|
y: 1,
|
|
w: 30,
|
|
h: 30
|
|
};
|
|
break;
|
|
case "Ladder":
|
|
this.frame = { x: 2, y: 7 };
|
|
this.hitBox = {
|
|
x: 4,
|
|
y: 0,
|
|
w: 24,
|
|
h: 32
|
|
};
|
|
break;
|
|
case "Stairs":
|
|
this.frame = { x: 4, y: 7 };
|
|
this.hitBox = {
|
|
x: 1,
|
|
y: 1,
|
|
w: 30,
|
|
h: 30
|
|
};
|
|
break;
|
|
}
|
|
}
|
|
|
|
update(dt) {
|
|
super.update(dt);
|
|
if (entity.hit(this, this.player)) {
|
|
this.action();
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = Portal; |