Added several features and moved some strings
- Moved sign strings to default.js - Textboxes are fixed to scene and center text - Pause function added (press escape) - Chests now be assigned textboxes individually - Added source button to titlescreen
This commit is contained in:
parent
6061c6c254
commit
c7a629517c
6
package-lock.json
generated
6
package-lock.json
generated
@ -290,9 +290,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"asdf-games": {
|
"asdf-games": {
|
||||||
"version": "1.0.14",
|
"version": "1.0.15",
|
||||||
"resolved": "https://registry.npmjs.org/asdf-games/-/asdf-games-1.0.14.tgz",
|
"resolved": "https://registry.npmjs.org/asdf-games/-/asdf-games-1.0.15.tgz",
|
||||||
"integrity": "sha512-0CCsgxfPjJL5BI7a8CYw49Y14rslG1BIsg20gnaf8Hi0SOaXJ61mZXf6Q96l9h5OhDaOLsv9e/yAMY9P0vq3IQ=="
|
"integrity": "sha512-wq3hDDkVGCbQ8CnQVh0IjzXNMG/mXwSQPJDx87pNg0Zw5k93sim6iD2NPpXfur/PZOR48spNXsQQOQeTvMYf1w=="
|
||||||
},
|
},
|
||||||
"astral-regex": {
|
"astral-regex": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
],
|
],
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"asdf-games": "^1.0.14"
|
"asdf-games": "^1.0.15"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cross-env": "^7.0.2",
|
"cross-env": "^7.0.2",
|
||||||
|
BIN
res/images/keys/s.png
Normal file
BIN
res/images/keys/s.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 380 B |
@ -4,7 +4,7 @@ module.exports = {
|
|||||||
"Press Space to Start!",
|
"Press Space to Start!",
|
||||||
"Press T for the tutorial",
|
"Press T for the tutorial",
|
||||||
"Press Q to quit",
|
"Press Q to quit",
|
||||||
//"Press G to see the game's code"
|
"Press S to go to the source code"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
tutorial: [
|
tutorial: [
|
||||||
@ -19,14 +19,18 @@ module.exports = {
|
|||||||
dead: "You died!",
|
dead: "You died!",
|
||||||
instruction: "Press space to return to title"
|
instruction: "Press space to return to title"
|
||||||
},
|
},
|
||||||
logoScreen: [
|
|
||||||
"Made by JoVo and McArn"
|
|
||||||
],
|
|
||||||
game: {
|
game: {
|
||||||
lives: "Lives",
|
lives: "Lives",
|
||||||
stamina: "Stamina",
|
stamina: "Stamina",
|
||||||
keyFind: "You found a key!",
|
keyFind: "You found a key!",
|
||||||
keyMissing: "You do not have the key for this door!"
|
keyMissing: "You do not have the key for this door!",
|
||||||
|
lifeBoost: "You found some health replenishing food!",
|
||||||
|
signs: {
|
||||||
|
"2-2": "Many secrets to the left",
|
||||||
|
"2-6": "Impressive, you're good.",
|
||||||
|
"3-1": "Climb the ladder and walk two tiles to the left",
|
||||||
|
"3-4": "Congrats."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
credits: {
|
credits: {
|
||||||
credits: "Credits:",
|
credits: "Credits:",
|
||||||
|
@ -8,9 +8,6 @@ const sounds = {
|
|||||||
obtain: new Sound(__dirname + "/../../res/sounds/obtain.wav", { volume: 0.1 })
|
obtain: new Sound(__dirname + "/../../res/sounds/obtain.wav", { volume: 0.1 })
|
||||||
};
|
};
|
||||||
|
|
||||||
const TextBox = require(__dirname + "/../helpers/textbox.js");
|
|
||||||
const text = require(__dirname + "/../../res/lang/default.js");
|
|
||||||
|
|
||||||
const Pointer = require("./pointer.js");
|
const Pointer = require("./pointer.js");
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
@ -71,7 +68,6 @@ class Chest extends TileSprite {
|
|||||||
this.state = state.open;
|
this.state = state.open;
|
||||||
this.pressed = true;
|
this.pressed = true;
|
||||||
this.action();
|
this.action();
|
||||||
this.level.entities.add(new TextBox({x: this.pos.x, y: this.pos.y - 10}, text.game.keyFind, 2.5));
|
|
||||||
sounds.obtain.play();
|
sounds.obtain.play();
|
||||||
} else {
|
} else {
|
||||||
if (!sounds.forbidden.playing && !this.pressed) {
|
if (!sounds.forbidden.playing && !this.pressed) {
|
||||||
|
@ -97,15 +97,13 @@ class Portal extends TileSprite {
|
|||||||
this.pointer.anims.play("white");
|
this.pointer.anims.play("white");
|
||||||
if (this.keys.action) {
|
if (this.keys.action) {
|
||||||
this.action();
|
this.action();
|
||||||
console.warn("action");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No key or not the correct key
|
// No key or not the correct key
|
||||||
this.pointer.anims.play("red");
|
this.pointer.anims.play("red");
|
||||||
if (this.keys.action) {
|
if (this.keys.action) {
|
||||||
if (!sounds.forbidden.playing && !this.pressed) {
|
if (!sounds.forbidden.playing && !this.pressed) {
|
||||||
console.log(this.player);
|
this.level.textbox.add(new TextBox(text.game.keyMissing));
|
||||||
this.level.entities.add(new TextBox({x: this.player.pos.x - Math.pow(this.player.pos.x, 160 / 177) - 25, y: this.player.pos.y > 160 ? this.player.pos.y - 160 : 0}, text.game.keyMissing, 2.5));
|
|
||||||
sounds.forbidden.play();
|
sounds.forbidden.play();
|
||||||
this.pressed = true;
|
this.pressed = true;
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,8 @@ class Sign extends TileSprite {
|
|||||||
this.pointer.anims.play("white");
|
this.pointer.anims.play("white");
|
||||||
|
|
||||||
if (this.keys.action) {
|
if (this.keys.action) {
|
||||||
const box = new TextBox({x: this.player.pos.x - Math.pow(this.player.pos.x, 160 / 177) - 25, y: this.player.pos.y > 160 ? this.player.pos.y - 160 : 0}, this.string, 2.5);
|
const box = new TextBox(this.string);
|
||||||
console.log(box);
|
this.level.textbox.add(box);
|
||||||
this.level.entities.add(box);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,7 +16,7 @@ const Sign = require("../entities/sign.js");
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
class Level extends TileMap {
|
class Level extends TileMap {
|
||||||
constructor (level, keys, player) {
|
constructor (level, keys, player, game) {
|
||||||
// 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 };
|
||||||
@ -31,6 +31,7 @@ class Level extends TileMap {
|
|||||||
this.h = level.size.h;
|
this.h = level.size.h;
|
||||||
this.keys = keys;
|
this.keys = keys;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
this.game = game;
|
||||||
|
|
||||||
this.gameComplete = false;
|
this.gameComplete = false;
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ class Level extends TileMap {
|
|||||||
e.entity = new Mage({ x: e.pos.x / 1, y: e.pos.y / 1 }, this.player, this);
|
e.entity = new Mage({ x: e.pos.x / 1, y: e.pos.y / 1 }, this.player, this);
|
||||||
break;
|
break;
|
||||||
case "Chest":
|
case "Chest":
|
||||||
e.entity = new Chest({ x: e.pos.x / 1, y: e.pos.y / 1 }, this.player, this.keys, this, () => { return e.action(this.player); });
|
e.entity = new Chest({ x: e.pos.x / 1, y: e.pos.y / 1 }, this.player, this.keys, this, () => { return e.action(this.player, this); });
|
||||||
break;
|
break;
|
||||||
case "Portal":
|
case "Portal":
|
||||||
e.entity = new Portal({ x: e.pos.x / 1, y: e.pos.y / 1 }, this.player, this.keys, this, e.texture, () => { return e.action(this.player, this); }, e.key);
|
e.entity = new Portal({ x: e.pos.x / 1, y: e.pos.y / 1 }, this.player, this.keys, this, e.texture, () => { return e.action(this.player, this); }, e.key);
|
||||||
@ -59,6 +60,9 @@ class Level extends TileMap {
|
|||||||
this.entities = new Container();
|
this.entities = new Container();
|
||||||
this.children.push(this.entities);
|
this.children.push(this.entities);
|
||||||
|
|
||||||
|
this.textbox = new Container();
|
||||||
|
this.game.add(this.textbox);
|
||||||
|
|
||||||
// sounds.bg.play();
|
// sounds.bg.play();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ const { Container, Text, Rect } = asdf;
|
|||||||
const fillStyle = {fill: "#ffffff", font: "16px Minecraft"};
|
const fillStyle = {fill: "#ffffff", font: "16px Minecraft"};
|
||||||
|
|
||||||
class TextBox extends Container {
|
class TextBox extends Container {
|
||||||
constructor(pos, string, lifespan) {
|
constructor(string, lifespan = 2.5) {
|
||||||
super();
|
super();
|
||||||
this.pos = pos !== undefined ? pos : { x: 0, y: 0 };
|
this.pos = { x: 0, y: 0 };
|
||||||
this.string = string;
|
this.string = string;
|
||||||
this.lifespan = lifespan;
|
this.lifespan = lifespan;
|
||||||
|
|
||||||
@ -16,10 +16,13 @@ class TextBox extends Container {
|
|||||||
this.add(background);
|
this.add(background);
|
||||||
|
|
||||||
const text = new Text(string, fillStyle);
|
const text = new Text(string, fillStyle);
|
||||||
text.pos = { x: this.pos.x + 8, y: this.pos.y + 18 };
|
var letters = string.split("");
|
||||||
|
// 10px is the average letter width
|
||||||
|
text.pos = {
|
||||||
|
x: (640 / 2) - ((letters.length * 10) / 2),
|
||||||
|
y: 16
|
||||||
|
};
|
||||||
this.add(text);
|
this.add(text);
|
||||||
|
|
||||||
console.log(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update(dt) {
|
update(dt) {
|
||||||
|
11
src/index.js
11
src/index.js
@ -14,7 +14,7 @@ const
|
|||||||
|
|
||||||
const window = { w: 640, h: 320 };
|
const window = { w: 640, h: 320 };
|
||||||
|
|
||||||
const game = new Game(window.w, window.h, true);
|
var game = new Game(window.w, window.h, true);
|
||||||
ipcRenderer.send("resize", window);
|
ipcRenderer.send("resize", window);
|
||||||
|
|
||||||
const keys = new KeyControls();
|
const keys = new KeyControls();
|
||||||
@ -41,8 +41,12 @@ function credits() {
|
|||||||
|
|
||||||
game.scene = new Logo(game, titleScreen);
|
game.scene = new Logo(game, titleScreen);
|
||||||
|
|
||||||
game.run();
|
game.run(() => {
|
||||||
|
if (keys.escape) {
|
||||||
|
toggleMenu();
|
||||||
|
keys.reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/* *********************************************************
|
/* *********************************************************
|
||||||
Settings behavior
|
Settings behavior
|
||||||
@ -52,6 +56,7 @@ game.run();
|
|||||||
function toggleMenu() {
|
function toggleMenu() {
|
||||||
const menuRef = document.getElementById("menu");
|
const menuRef = document.getElementById("menu");
|
||||||
menuRef.style.display = menuRef.style.display === "block" ? "none" : "block";
|
menuRef.style.display = menuRef.style.display === "block" ? "none" : "block";
|
||||||
|
game.paused = game.paused ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const elements = [...document.querySelectorAll("#settings, #resume")];
|
const elements = [...document.querySelectorAll("#settings, #resume")];
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
const tileSize = 32;
|
const tileSize = 32;
|
||||||
|
|
||||||
|
const text = require(__dirname + "/../../res/lang/default.js");
|
||||||
|
const TextBox = require(__dirname + "/../helpers/textbox.js");
|
||||||
|
|
||||||
let level = {
|
let level = {
|
||||||
tiles: [
|
tiles: [
|
||||||
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6,
|
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6,
|
||||||
@ -38,7 +41,8 @@ let level = {
|
|||||||
{
|
{
|
||||||
type: "Chest",
|
type: "Chest",
|
||||||
pos: { x: 7 * tileSize, y: 2 * tileSize },
|
pos: { x: 7 * tileSize, y: 2 * tileSize },
|
||||||
action: (player) => {
|
action: (player, level) => {
|
||||||
|
level.textbox.add(new TextBox(text.game.keyFind));
|
||||||
player.items.keys.push("3-4");
|
player.items.keys.push("3-4");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
const tileSize = 32;
|
const tileSize = 32;
|
||||||
|
|
||||||
|
const text = require(__dirname + "/../../res/lang/default.js");
|
||||||
|
const TextBox = require(__dirname + "/../helpers/textbox.js");
|
||||||
|
|
||||||
let level = {
|
let level = {
|
||||||
tiles: [
|
tiles: [
|
||||||
1, 2, 2, 5, 6,
|
1, 2, 2, 5, 6,
|
||||||
@ -21,7 +24,8 @@ let level = {
|
|||||||
{
|
{
|
||||||
type: "Chest",
|
type: "Chest",
|
||||||
pos: { x: 2 * tileSize, y: 2 * tileSize },
|
pos: { x: 2 * tileSize, y: 2 * tileSize },
|
||||||
action: (player) => {
|
action: (player, level) => {
|
||||||
|
level.textbox.add(new TextBox(text.game.keyFind));
|
||||||
player.items.keys.push("1-1_1");
|
player.items.keys.push("1-1_1");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
const tileSize = 32;
|
const tileSize = 32;
|
||||||
|
|
||||||
|
const text = require(__dirname + "/../../res/lang/default.js");
|
||||||
|
const TextBox = require(__dirname + "/../helpers/textbox.js");
|
||||||
|
|
||||||
let level = {
|
let level = {
|
||||||
tiles: [
|
tiles: [
|
||||||
1, 2, 2, 2, 2, 2, 2, 2, 5, 6,
|
1, 2, 2, 2, 2, 2, 2, 2, 5, 6,
|
||||||
@ -38,7 +41,8 @@ let level = {
|
|||||||
{
|
{
|
||||||
type: "Chest",
|
type: "Chest",
|
||||||
pos: { x: 4.5 * tileSize, y: 17 * tileSize },
|
pos: { x: 4.5 * tileSize, y: 17 * tileSize },
|
||||||
action: (player) => {
|
action: (player, level) => {
|
||||||
|
level.textbox.add(new TextBox(text.game.keyFind));
|
||||||
player.items.keys.push("1-4");
|
player.items.keys.push("1-4");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
const tileSize = 32;
|
const tileSize = 32;
|
||||||
|
|
||||||
|
const text = require(__dirname + "/../../res/lang/default.js");
|
||||||
|
const TextBox = require(__dirname + "/../helpers/textbox.js");
|
||||||
|
|
||||||
let level = {
|
let level = {
|
||||||
tiles: [
|
tiles: [
|
||||||
1, 52, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 6,
|
1, 52, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 6,
|
||||||
@ -27,6 +30,14 @@ let level = {
|
|||||||
},
|
},
|
||||||
key: "1-4"
|
key: "1-4"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: "Chest",
|
||||||
|
pos: { x: 1 * tileSize, y: 2 * tileSize },
|
||||||
|
action: (player, level) => {
|
||||||
|
level.textbox.add(new TextBox(text.game.lifeBoost));
|
||||||
|
player.lives = 5;
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: "Portal",
|
type: "Portal",
|
||||||
pos: { x: 4 * tileSize, y: 1 * tileSize },
|
pos: { x: 4 * tileSize, y: 1 * tileSize },
|
||||||
@ -75,7 +86,7 @@ let level = {
|
|||||||
{
|
{
|
||||||
type: "Sign",
|
type: "Sign",
|
||||||
pos: { x: 14 * tileSize, y: tileSize },
|
pos: { x: 14 * tileSize, y: tileSize },
|
||||||
text: "Many secret to the left"
|
text: text.game.signs["2-2"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
const tileSize = 32;
|
const tileSize = 32;
|
||||||
|
|
||||||
|
const text = require(__dirname + "/../../res/lang/default.js");
|
||||||
|
const TextBox = require(__dirname + "/../helpers/textbox.js");
|
||||||
|
|
||||||
let level = {
|
let level = {
|
||||||
tiles: [
|
tiles: [
|
||||||
1, 2, 5, 2, 5, 2, 5, 2, 5, 6,
|
1, 2, 5, 2, 5, 2, 5, 2, 5, 6,
|
||||||
@ -34,7 +37,8 @@ let level = {
|
|||||||
{
|
{
|
||||||
type: "Chest",
|
type: "Chest",
|
||||||
pos: { x: 1 * tileSize, y: 2 * tileSize },
|
pos: { x: 1 * tileSize, y: 2 * tileSize },
|
||||||
action: (player) => {
|
action: (player, level) => {
|
||||||
|
level.textbox.add(new TextBox(text.game.keyFind));
|
||||||
player.items.keys.push("3-1");
|
player.items.keys.push("3-1");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
const tileSize = 32;
|
const tileSize = 32;
|
||||||
|
|
||||||
|
const text = require(__dirname + "/../../res/lang/default.js");
|
||||||
|
const TextBox = require(__dirname + "/../helpers/textbox.js");
|
||||||
|
|
||||||
let level = {
|
let level = {
|
||||||
tiles: [
|
tiles: [
|
||||||
1, 2, 5, 2, 5, 2, 5, 2, 5, 6,
|
1, 2, 5, 2, 5, 2, 5, 2, 5, 6,
|
||||||
@ -30,7 +33,8 @@ let level = {
|
|||||||
{
|
{
|
||||||
type: "Chest",
|
type: "Chest",
|
||||||
pos: { x: 1 * tileSize, y: 2 * tileSize },
|
pos: { x: 1 * tileSize, y: 2 * tileSize },
|
||||||
action: (player) => {
|
action: (player, level) => {
|
||||||
|
level.textbox.add(new TextBox(text.game.keyFind));
|
||||||
player.items.keys.push("2-3");
|
player.items.keys.push("2-3");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
const tileSize = 32;
|
const tileSize = 32;
|
||||||
|
|
||||||
|
const text = require(__dirname + "/../../res/lang/default.js");
|
||||||
|
|
||||||
let level = {
|
let level = {
|
||||||
tiles: [
|
tiles: [
|
||||||
1, 2, 2, 2, 2, 2, 2, 2, 6,
|
1, 2, 2, 2, 2, 2, 2, 2, 6,
|
||||||
@ -42,7 +44,7 @@ let level = {
|
|||||||
{
|
{
|
||||||
type: "Sign",
|
type: "Sign",
|
||||||
pos: { x: 3 * tileSize, y: tileSize },
|
pos: { x: 3 * tileSize, y: tileSize },
|
||||||
text: "Impressive, you're good."
|
text: text.game.signs["2-6"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
const tileSize = 32;
|
const tileSize = 32;
|
||||||
|
|
||||||
|
const text = require(__dirname + "/../../res/lang/default.js");
|
||||||
|
|
||||||
let level = {
|
let level = {
|
||||||
tiles: [
|
tiles: [
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 52, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 6,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 52, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 6,
|
||||||
@ -43,7 +45,7 @@ let level = {
|
|||||||
{
|
{
|
||||||
type: "Sign",
|
type: "Sign",
|
||||||
pos: { x: 25 * tileSize, y: tileSize },
|
pos: { x: 25 * tileSize, y: tileSize },
|
||||||
text: "Climb the ladder and walk two tiles to the left"
|
text: text.game.signs["3-1"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "Portal",
|
type: "Portal",
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
const tileSize = 32;
|
const tileSize = 32;
|
||||||
|
|
||||||
|
const text = require(__dirname + "/../../res/lang/default.js");
|
||||||
|
const TextBox = require(__dirname + "/../helpers/textbox.js");
|
||||||
|
|
||||||
let level = {
|
let level = {
|
||||||
tiles: [
|
tiles: [
|
||||||
1, 2, 5, 2, 5, 2, 5, 2, 5, 6,
|
1, 2, 5, 2, 5, 2, 5, 2, 5, 6,
|
||||||
@ -34,7 +37,8 @@ let level = {
|
|||||||
{
|
{
|
||||||
type: "Chest",
|
type: "Chest",
|
||||||
pos: { x: 8 * tileSize, y: 2 * tileSize },
|
pos: { x: 8 * tileSize, y: 2 * tileSize },
|
||||||
action: (player) => {
|
action: (player, level) => {
|
||||||
|
level.textbox.add(new TextBox(text.game.keyFind));
|
||||||
player.items.keys.push("2-6");
|
player.items.keys.push("2-6");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
const tileSize = 32;
|
const tileSize = 32;
|
||||||
|
|
||||||
|
const text = require(__dirname + "/../../res/lang/default.js");
|
||||||
|
|
||||||
let level = {
|
let level = {
|
||||||
tiles: [
|
tiles: [
|
||||||
1, 2, 2, 2, 2, 2, 2, 2, 6,
|
1, 2, 2, 2, 2, 2, 2, 2, 6,
|
||||||
@ -42,7 +44,7 @@ let level = {
|
|||||||
{
|
{
|
||||||
type: "Sign",
|
type: "Sign",
|
||||||
pos: { x: 3 * tileSize, y: tileSize },
|
pos: { x: 3 * tileSize, y: tileSize },
|
||||||
text: "Congrats."
|
text: text.game.signs["3-4"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
@ -13,6 +13,7 @@ class GameScreen extends Container {
|
|||||||
super();
|
super();
|
||||||
|
|
||||||
this.game = game;
|
this.game = game;
|
||||||
|
this.scene = this;
|
||||||
this.window = window;
|
this.window = window;
|
||||||
this.keys = keys;
|
this.keys = keys;
|
||||||
this.onGameOver = onGameOver;
|
this.onGameOver = onGameOver;
|
||||||
@ -23,7 +24,7 @@ class GameScreen extends Container {
|
|||||||
// Initialise first level 1-1.js at startPosition 0
|
// Initialise first level 1-1.js at startPosition 0
|
||||||
var player = new Player(keys, window);
|
var player = new Player(keys, window);
|
||||||
|
|
||||||
var level = new Level(require(__dirname + "/../levels/2-2.js"), keys, player);
|
var level = new Level(require(__dirname + "/../levels/2-2.js"), keys, player, this);
|
||||||
player.pos.x = level.startPos[0].x / 1;
|
player.pos.x = level.startPos[0].x / 1;
|
||||||
player.pos.y = level.startPos[0].y / 1;
|
player.pos.y = level.startPos[0].y / 1;
|
||||||
player.level = level;
|
player.level = level;
|
||||||
@ -43,7 +44,7 @@ class GameScreen extends Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switchLevel(module, pos = 0) {
|
switchLevel(module, pos = 0) {
|
||||||
var { camera, player, level, stats, keys } = this;
|
var { scene, camera, player, level, stats, keys } = this;
|
||||||
|
|
||||||
camera.map(function(e) {
|
camera.map(function(e) {
|
||||||
camera.remove(e);
|
camera.remove(e);
|
||||||
@ -54,7 +55,7 @@ class GameScreen extends Container {
|
|||||||
var p = new Player(keys, window);
|
var p = new Player(keys, window);
|
||||||
player = p;
|
player = p;
|
||||||
|
|
||||||
e = new Level(module, keys, player);
|
e = new Level(module, keys, player, scene);
|
||||||
level = e;
|
level = e;
|
||||||
|
|
||||||
player.pos.x = level.startPos[pos].x / 1;
|
player.pos.x = level.startPos[pos].x / 1;
|
||||||
|
@ -11,6 +11,7 @@ const textures = {
|
|||||||
space: new Texture("../res/images/keys/space.png"),
|
space: new Texture("../res/images/keys/space.png"),
|
||||||
t: new Texture("../res/images/keys/t.png"),
|
t: new Texture("../res/images/keys/t.png"),
|
||||||
q: new Texture("../res/images/keys/q.png"),
|
q: new Texture("../res/images/keys/q.png"),
|
||||||
|
s: new Texture("../res/images/keys/s.png"),
|
||||||
logo: new Texture("../res/images/logo.png")
|
logo: new Texture("../res/images/logo.png")
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -35,7 +36,8 @@ class Title extends Container {
|
|||||||
this.keyCaps = [
|
this.keyCaps = [
|
||||||
new TileSprite(textures.space, 64, 16),
|
new TileSprite(textures.space, 64, 16),
|
||||||
new TileSprite(textures.t, 16, 16),
|
new TileSprite(textures.t, 16, 16),
|
||||||
new TileSprite(textures.q, 16, 16)
|
new TileSprite(textures.q, 16, 16),
|
||||||
|
new TileSprite(textures.s, 16, 16)
|
||||||
];
|
];
|
||||||
|
|
||||||
this.keyCaps.forEach(element => {
|
this.keyCaps.forEach(element => {
|
||||||
@ -43,10 +45,9 @@ class Title extends Container {
|
|||||||
element.anims = new AnimManager(element);
|
element.anims = new AnimManager(element);
|
||||||
element.anims.add("press", [0, 1].map(y => ({ x: 0, y })), 0.50);
|
element.anims.add("press", [0, 1].map(y => ({ x: 0, y })), 0.50);
|
||||||
element.anims.play("press");
|
element.anims.play("press");
|
||||||
console.log(element);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const textPos = { x: 220, y: 240 };
|
const textPos = { x: 160, y: 210 };
|
||||||
for (let index = 0; index < text.titleScreen.instructions.length; index++) {
|
for (let index = 0; index < text.titleScreen.instructions.length; index++) {
|
||||||
const keyCap = this.keyCaps[index];
|
const keyCap = this.keyCaps[index];
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
@ -87,9 +88,10 @@ class Title extends Container {
|
|||||||
this.onQuit();
|
this.onQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open gitea on key g
|
// Open source code on key s
|
||||||
if (this.keys.key(71)) {
|
if (this.keys.key(83)) {
|
||||||
shell.openExternal("https://gitea.arnweb.nl/Hecc-inc./caa-game");
|
shell.openExternal("https://gitea.arnweb.nl/Hecc-inc./caa-game");
|
||||||
|
this.keys.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user