Compare commits

..

No commits in common. "67ffda01545c89374ba60795e5ebcb208892d368" and "2ad36e52e961b0384b66558499d005a5112f8c22" have entirely different histories.

3 changed files with 10 additions and 68 deletions

View File

@ -1,54 +0,0 @@
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;

View File

@ -1,6 +1,6 @@
const tileSize = 32;
let level = {
var level = {
tiles: [
1, 2, 2, 2, 2, 6, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 6,
4, 21, 22, 23, 21, 7, 0, 4, 22, 23, 21, 22, 23, 21, 22, 23, 21, 22, 23, 21, 22, 23, 21, 22, 23, 21, 22, 23, 21, 7,
@ -27,10 +27,9 @@ let level = {
y: 64
},
entities: [
{ type: "Mage", pos: { x: 9 * tileSize, y: 2 * tileSize }},
{ type: "Mage", pos: { x: 8 * tileSize, y: 2 * tileSize }},
{ type: "Mage", pos: { x: 1 * tileSize, y: 8 * tileSize }},
{ type: "Chest", pos: { x: 4 * tileSize, y: 2 * tileSize }, action: (player) => { player.pos = {x:512,y:256}; } },
{ type: "Portal", pos: { x: 8 * tileSize, y: 2 * tileSize }, texture: "Ladder", action: (player) => { player.pos = {x:512,y:256}; }}
{ type: "Chest", pos: { x: 4 * tileSize, y: 2 * tileSize }, action: (player) => { player.pos = {x:512,y:256}; } }
]
};

View File

@ -8,11 +8,9 @@ const tileSize = 32;
const Mage = require("../entities/mage.js");
const Chest = require("../entities/chest.js");
const Portal = require("../entities/portal.js");
class Level extends TileMap {
constructor (level, keys, player) {
console.log(level);
// Convert id array to tile array
var levelTiles = level.tiles.map(function(e) {
@ -31,19 +29,18 @@ class Level extends TileMap {
// Handle Entities
for (let index = 0; index < level.entities.length; index++) {
let e = level.entities[index];
const e = level.entities[index];
var entity;
switch (e.type) {
case "Mage":
e.entity = new Mage(e.pos, this.player, this);
entity = new Mage(e.pos, this.player, this);
break;
case "Chest":
e.entity = new Chest(e.pos, this.player, this.keys, () => { return e.action(this.player); });
break;
case "Portal":
e.entity = new Portal(e.pos, this.player, e.texture, () => { return e.action(this.player); });
entity = new Chest(e.pos, this.player, this.keys, () => { return e.action(this.player); });
break;
}
this.children.push(e.entity);
console.log(e);
this.children.push(entity);
}
}