Compare commits

..

No commits in common. "7832563728db3a094a673f8a1163e46eb1cc6e0f" and "e6984483c1977df1977565000288ddf6bec9bb0c" have entirely different histories.

9 changed files with 27 additions and 89 deletions

6
package-lock.json generated
View File

@ -151,9 +151,9 @@
} }
}, },
"asdf-games": { "asdf-games": {
"version": "1.0.12", "version": "1.0.11",
"resolved": "https://registry.npmjs.org/asdf-games/-/asdf-games-1.0.12.tgz", "resolved": "https://registry.npmjs.org/asdf-games/-/asdf-games-1.0.11.tgz",
"integrity": "sha512-XaramOeOnLK4eH3HRRR6joCQClvuZZ/ANBEjKzMpMHsZ/+O/G3arMI2h6KQ86yrWrT0TZGTc89vrfmBhQmqNrQ==" "integrity": "sha512-PXk+PKlm932HHMEsiaKsWwiC/+ZnbBSISqy80Pin8p8TM51P4Sec6iBjyIJ38SbCiDOqZqCc/fGDf0dSQoBHVg=="
}, },
"astral-regex": { "astral-regex": {
"version": "1.0.0", "version": "1.0.0",

View File

@ -10,7 +10,7 @@
"author": "McArn", "author": "McArn",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"asdf-games": "^1.0.12" "asdf-games": "^1.0.11"
}, },
"devDependencies": { "devDependencies": {
"electron": "^8.0.2", "electron": "^8.0.2",

View File

@ -60,14 +60,8 @@ class Mage extends TileSprite {
const yo = Math.sin(angle) * 100 * dt; const yo = Math.sin(angle) * 100 * dt;
const r = wallslide.wallslide(this, this.level, xo, yo); const r = wallslide.wallslide(this, this.level, xo, yo);
if (this.player.repellant) { this.pos.x += r.x;
this.pos.x -= r.x; this.pos.y += r.y;
this.pos.y -= r.y;
} else {
this.pos.x += r.x;
this.pos.y += r.y;
}
if (Math.abs(r.x) > Math.abs(r.y)) { if (Math.abs(r.x) > Math.abs(r.y)) {
// Animation x axis // Animation x axis

View File

@ -37,10 +37,6 @@ class Player extends TileSprite {
this.anims.play("walk_s"); this.anims.play("walk_s");
this.lives = 5; this.lives = 5;
this.key = false;
this.repellant = true;
this.stamina = { this.stamina = {
current: 5, current: 5,
max: 5 max: 5

View File

@ -5,16 +5,13 @@ const { Texture, TileSprite, entity } = asdf;
var texture = new Texture("./res/tilemap.png"); var texture = new Texture("./res/tilemap.png");
class Portal extends TileSprite { class Portal extends TileSprite {
constructor(pos, player, keys, type, action, key) { constructor(pos, player, type, action) {
super(texture, 32, 32); super(texture, 32, 32);
this.pos = pos; this.pos = pos;
this.scale = { x: 1, y: 1 }; this.scale = { x: 1, y: 1 };
this.player = player; this.player = player;
this.action = action; this.action = action;
this.keys = keys;
this.key = key;
switch (type) { switch (type) {
case "Door": case "Door":
this.frame = { x: 1, y: 7 }; this.frame = { x: 1, y: 7 };
@ -48,16 +45,8 @@ class Portal extends TileSprite {
update(dt) { update(dt) {
super.update(dt); super.update(dt);
if (entity.hit(this, this.player) && this.keys.action) { if (entity.hit(this, this.player)) {
if (this.key) { this.action();
if (this.player.key) {
this.action();
} else {
console.log("keyn't");
}
} else {
this.action();
}
} }
} }
} }

View File

@ -2,7 +2,7 @@ const { ipcRenderer, remote } = require("electron");
var asdf = require("asdf-games"); var asdf = require("asdf-games");
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const { Game, KeyControls, MouseControls, Camera, Lightsource } = asdf; const { Game, KeyControls, MouseControls, Camera, Lighting } = asdf;
const window = { w: 640, h: 320 }; const window = { w: 640, h: 320 };
@ -17,39 +17,33 @@ var Level = require("./src/levels/level.js");
const mouseAim = new MouseControls(document.getElementById("board")); const mouseAim = new MouseControls(document.getElementById("board"));
const keys = new KeyControls(); const keys = new KeyControls();
// var lightsources = [
// { x: 100, y: 50 },
// { x: 100, y: 300 },
// { x: 300, y: 50 },
// { x: 300, y: 300 },
// { x: 100, y: 500 },
// { x: 500, y: 100 }
// ];
// var lighting = new Lighting(level.x, level.y, level.w, level.h, lightsources);
var player = new Player(keys, window); var player = new Player(keys, window);
var level = new Level(require("./src/levels/1-1.js"), keys, player); var level = new Level(require("./src/levels/1-1.js"), keys, player);
player.pos = level.startPos; player.pos = level.startPos;
player.level = level; player.level = level;
// Lightsource makes the games extremely laggy for some reason, ill have to check the performance
//var lightsource = new Lightsource(player.pos.x, player.pos.y, level.pos.x, level.pos.y, level.w, level.h);
const camera = new Camera(player, window, { w: level.w * 2, h: level.h * 2 }); const camera = new Camera(player, window, { w: level.w * 2, h: level.h * 2 });
scene.add(camera); scene.add(camera);
camera.add(level); camera.add(level);
camera.add(player); camera.add(player);
//camera.add(lightsource); // camera.add(lighting);
// function switchLevel(camera, module) {
// camera.map(function(e) {
// camera.remove(e);
// if (e instanceof Level) {
// e = new Level(module, keys, player);
// player.pos = level.startPos;
// player.level = level;
// camera.add(e);
// camera.add(player);
// }
// });
// }
game.run(() => { game.run(() => {
if (mouseAim.isDown) { if (mouseAim.isDown) {
console.log("cliccccccccccc"); console.log("cliccccccccccc");
switchLevel(camera, require("./src/levels/1-1 copy.js"));
} }
}); });

View File

@ -1,37 +0,0 @@
const tileSize = 32;
let 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,
4, 17, 17, 17, 17, 7, 0, 4, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 7, 0, 4, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 8, 2, 3, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 0, 22, 22, 22, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
14, 15, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 9
],
size: {
w: 960,
h: 480
},
startPos: {
x: 48,
y: 64
},
entities: [
{ type: "Mage", pos: { x: 9 * 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.key = true; } },
{ type: "Portal", pos: { x: 8 * tileSize, y: 2 * tileSize }, texture: "Ladder", action: (player) => { player.pos = {x:512,y:256}; }, key: true}
]
};
module.exports = level;

View File

@ -29,8 +29,8 @@ let level = {
entities: [ entities: [
{ type: "Mage", pos: { x: 9 * tileSize, y: 2 * tileSize }}, { type: "Mage", pos: { x: 9 * tileSize, y: 2 * tileSize }},
{ type: "Mage", pos: { x: 1 * tileSize, y: 8 * tileSize }}, { type: "Mage", pos: { x: 1 * tileSize, y: 8 * tileSize }},
{ type: "Chest", pos: { x: 4 * tileSize, y: 2 * tileSize }, action: (player) => { player.key = true; } }, { 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}; }, key: true} { type: "Portal", pos: { x: 8 * tileSize, y: 2 * tileSize }, texture: "Ladder", action: (player) => { player.pos = {x:512,y:256}; }}
] ]
}; };

View File

@ -12,6 +12,8 @@ const Portal = require("../entities/portal.js");
class Level extends TileMap { class Level extends TileMap {
constructor (level, keys, player) { constructor (level, keys, player) {
console.log(level);
// Convert id array to tile array // Convert id array to tile array
var levelTiles = level.tiles.map(function(e) { var levelTiles = level.tiles.map(function(e) {
return { x: (tiles[e].x / tileSize), y: (tiles[e].y / tileSize), walkable: tiles[e].walkable }; return { x: (tiles[e].x / tileSize), y: (tiles[e].y / tileSize), walkable: tiles[e].walkable };
@ -38,7 +40,7 @@ class Level extends TileMap {
e.entity = new Chest(e.pos, this.player, this.keys, () => { return e.action(this.player); }); e.entity = new Chest(e.pos, this.player, this.keys, () => { return e.action(this.player); });
break; break;
case "Portal": case "Portal":
e.entity = new Portal(e.pos, this.player, this.keys, e.texture, () => { return e.action(this.player); }, e.key); e.entity = new Portal(e.pos, this.player, e.texture, () => { return e.action(this.player); });
break; break;
} }
this.children.push(e.entity); this.children.push(e.entity);