[levels]: Add all levels and added credits screen.

This commit is contained in:
corner 2020-04-16 18:42:24 +02:00
parent c6bc46b961
commit 6061c6c254
29 changed files with 940 additions and 34 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -4,6 +4,7 @@ module.exports = {
"Press Space to Start!",
"Press T for the tutorial",
"Press Q to quit",
//"Press G to see the game's code"
]
},
tutorial: [
@ -26,5 +27,12 @@ module.exports = {
stamina: "Stamina",
keyFind: "You found a key!",
keyMissing: "You do not have the key for this door!"
},
credits: {
credits: "Credits:",
arne: "(almost all) Code by Arne van Iterson",
job: "Code and assets by Job Vonk",
hannah: "Heron't logo by Hannah van Iterson",
font: "The logo's font is “Alagard” by Hewett Tsoi"
}
};

View File

@ -14,10 +14,10 @@
* 9. Corner right -> bottom
* 10. bottom wall piece before 8.
* 11. normal bottom wall piece
* 12. Corner bottom -> right
* 13. Corner right -> bottom
* 14. Corner bottom -> left
* 15. Bottom wall piece before 13.
* 12. Corner right -> bottom
* 13. Corner bottom -> right
* 14. Corner left -> bottom
* 15. Bottom wall piece after 14.
* 16. Corner left -> bottom
* 17. Normal floor tile
* 18. +-shaped floor tile
@ -51,8 +51,11 @@
* 46. Fireball
* 47. Door_s
* 48. Corner bottom -> left after 16
* 49. Corner right -> bottom before 12
* 49. Corner right -> bottom before 13
* 50. bottom piece underneath 47
* 51. Transparent tile (walkable)
* 52. top-piece after corner (1)
* 53. Sign on wall
------------------------------------------------------------------- */
module.exports = [
{
@ -310,4 +313,19 @@ module.exports = [
y: 320,
walkable: false
},
{
x: 0,
y: 256,
walkable: true
},
{
x: 32,
y: 320,
walkable: false
},
{
x: 64,
y: 320,
walkable: false
},
];

View File

@ -71,7 +71,7 @@ class Chest extends TileSprite {
this.state = state.open;
this.pressed = true;
this.action();
this.level.entities.add(new TextBox(text.game.keyFind, 2.5));
this.level.entities.add(new TextBox({x: this.pos.x, y: this.pos.y - 10}, text.game.keyFind, 2.5));
sounds.obtain.play();
} else {
if (!sounds.forbidden.playing && !this.pressed) {

View File

@ -27,6 +27,8 @@ class Portal extends TileSprite {
this.keys = keys;
this.key = key;
this.type = type;
switch (type) {
case "Door_n":
this.frame = { x: 1, y: 7 };
@ -64,6 +66,15 @@ class Portal extends TileSprite {
h: 30
};
break;
case "Door_hidden":
this.frame = { x: 0, y: 4 };
this.hitBox = {
x: 1,
y: 1,
w: 30,
h: 45
};
break;
}
}
@ -71,7 +82,7 @@ class Portal extends TileSprite {
super.update(dt);
if (entity.hit(this, this.player)) {
if (!this.pointer) {
if (!this.pointer && this.type !== "Door_hidden") {
var pointer = new Pointer({
x: (this.pos.x + this.tileW / 2) - 8,
y: this.pos.y - 16
@ -80,7 +91,7 @@ class Portal extends TileSprite {
this.pointer = pointer;
}
if (this.key != "") {
if (this.key != "" && this.type !== "Door_hidden") {
if (this.player.items.keys.includes(this.key)) {
// Correct key
this.pointer.anims.play("white");
@ -93,7 +104,8 @@ class Portal extends TileSprite {
this.pointer.anims.play("red");
if (this.keys.action) {
if (!sounds.forbidden.playing && !this.pressed) {
this.level.entities.add(new TextBox(text.game.keyMissing, 2.5));
console.log(this.player);
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();
this.pressed = true;
}

63
src/entities/sign.js Normal file
View File

@ -0,0 +1,63 @@
var asdf = require("asdf-games");
// eslint-disable-next-line no-unused-vars
const { Texture, TileSprite, entity } = asdf;
const texture = new Texture(__dirname + "/../../res/images/tilemap.png");
const TextBox = require(__dirname + "/../helpers/textbox.js");
const Pointer = require("./pointer.js");
class Sign extends TileSprite {
constructor(pos, player, keys, level, text) {
super(texture, 32, 32);
this.pos = pos;
this.scale = { x: 1, y: 1 };
this.frame = { x : 2, y: 10 };
this.player = player;
this.level = level;
this.keys = keys;
this.pointer = false;
this.string = text;
this.hitBox = {
x: 1,
y: 1,
w: 28,
h: 32
};
}
update(dt) {
super.update(dt);
if (entity.hit(this, this.player)) {
if (!this.pointer) {
var pointer = new Pointer({
x: (this.pos.x + this.tileW / 2) - 8,
y: this.pos.y - 16
});
this.level.entities.add(pointer);
this.pointer = pointer;
}
this.pointer.anims.play("white");
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);
console.log(box);
this.level.entities.add(box);
}
} else {
this.level.entities.remove(this.pointer);
this.pointer = false;
}
}
}
module.exports = Sign;

View File

@ -1,6 +1,6 @@
var asdf = require("asdf-games");
// eslint-disable-next-line no-unused-vars
const { Texture, TileMap, Container } = asdf;
const { Texture, TileMap, Container, Sound } = asdf;
const texture = new Texture(__dirname + "/../../res/images/tilemap.png");
const tiles = require("../../res/tilemap.js");
@ -9,6 +9,11 @@ const tileSize = 32;
const Mage = require("../entities/mage.js");
const Chest = require("../entities/chest.js");
const Portal = require("../entities/portal.js");
const Sign = require("../entities/sign.js");
// const sounds = {
// bg: new Sound(__dirname + "/../../res/sounds/bg.wav", { volume: 0.05, loop: true })
// };
class Level extends TileMap {
constructor (level, keys, player) {
@ -27,6 +32,8 @@ class Level extends TileMap {
this.keys = keys;
this.player = player;
this.gameComplete = false;
this.switch = false;
// Handle Entities
@ -42,6 +49,9 @@ class Level extends TileMap {
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);
break;
case "Sign":
e.entity = new Sign({ x: e.pos.x / 1, y: e.pos.y / 1 }, this.player, this.keys, this, e.text);
break;
}
this.children.push(e.entity);
}
@ -49,6 +59,8 @@ class Level extends TileMap {
this.entities = new Container();
this.children.push(this.entities);
// sounds.bg.play();
}
update(dt) {

View File

@ -5,19 +5,21 @@ const { Container, Text, Rect } = asdf;
const fillStyle = {fill: "#ffffff", font: "16px Minecraft"};
class TextBox extends Container {
constructor(string, lifespan) {
constructor(pos, string, lifespan) {
super();
this.pos = { x: 0, y: 0 };
this.pos = pos !== undefined ? pos : { x: 0, y: 0 };
this.string = string;
this.lifespan = lifespan;
const background = new Rect(640, 24, {fill: "rgba(0,0,0,0.5)"});
background.pos = { x: 0, y: 0 };
background.pos = this.pos;
this.add(background);
const text = new Text(string, fillStyle);
text.pos = { x: 8, y: 18 };
text.pos = { x: this.pos.x + 8, y: this.pos.y + 18 };
this.add(text);
console.log(this);
}
update(dt) {

View File

@ -1,14 +1,15 @@
const { ipcRenderer, remote } = require("electron");
var asdf = require("asdf-games");
// eslint-disable-next-line no-unused-vars
const { Game, KeyControls, MouseControls } = asdf;
const { Game, KeyControls } = asdf;
const
Logo = require(__dirname + "/../src/screens/logo.js"),
Title = require(__dirname + "/../src/screens/title.js"),
Tutorial = require(__dirname + "/../src/screens/tutorial.js"),
GameScreen = require(__dirname + "/../src/screens/game.js"),
Gameover = require(__dirname + "/../src/screens/gameover.js")
Gameover = require(__dirname + "/../src/screens/gameover.js"),
Credits = require(__dirname + "/../src/screens/credits.js")
;
const window = { w: 640, h: 320 };
@ -31,7 +32,11 @@ function gameOver() {
}
function newGame() {
game.scene = new GameScreen(game, window, keys, gameOver);
game.scene = new GameScreen(game, window, keys, gameOver, credits);
}
function credits() {
game.scene = new Credits(game, keys, titleScreen);
}
game.scene = new Logo(game, titleScreen);

44
src/levels/0-1.js Normal file
View File

@ -0,0 +1,44 @@
const tileSize = 32;
let level = {
tiles: [
1, 2, 2, 2, 2, 2, 2, 2, 6,
4, 21, 22, 23, 21, 22, 23, 21, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
14, 15, 11, 11, 11, 11, 11, 10, 13,
],
size: {
w: 9 * tileSize,
h: 9 * tileSize
},
startPos: [
{ x: 5 * tileSize, y: 3 * tileSize }
],
entities: [
{
type: "Portal",
pos: { x: 4 * tileSize, y: tileSize },
texture: "Door_n",
action: (_player, level) => {
level.switch = { module: __dirname + "/0-2.js", pos: 0 };
},
key: ""
},
{
type: "Portal",
pos: { x: 4 * tileSize, y: 6 * tileSize },
texture: "Ladder",
action: (_player, level) => {
level.switch = { module: __dirname + "/2-6.js", pos: 0 };
},
key: ""
}
]
};
module.exports = level;

68
src/levels/0-2.js Normal file
View File

@ -0,0 +1,68 @@
const tileSize = 32;
let level = {
tiles: [
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6,
4, 21, 22, 23, 21, 22, 23, 21, 22, 23, 21, 22, 23, 21, 7,
4, 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, 7,
4, 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, 7,
4, 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, 7,
4, 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, 7,
4, 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, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
14, 11, 11, 11, 11, 11, 16, 47, 12, 11, 11, 11, 11, 11, 13,
0, 0, 0, 0, 0, 0, 14, 50, 13, 0, 0, 0, 0, 0, 0, 0
],
size: {
w: 15 * tileSize,
h: 20 * tileSize
},
startPos: [
{ x: 7 * tileSize, y: 12 * tileSize }
],
entities: [
{
type: "Portal",
pos: { x: 7 * tileSize, y: 13 * tileSize },
texture: "Door_s",
action: (_player, level) => {
level.switch = { module: __dirname + "/0-1.js", pos: 0 };
},
key: ""
},
{
type: "Chest",
pos: { x: 7 * tileSize, y: 2 * tileSize },
action: (player) => {
player.items.keys.push("3-4");
}
},
{
type: "Mage",
pos: { x: 7 * tileSize, y: 3 * tileSize }
},
{
type: "Mage",
pos: { x: 2 * tileSize, y: 7 * tileSize }
},
{
type: "Mage",
pos: { x: 13 * tileSize, y: 7 * tileSize }
},
{
type: "Mage",
pos: { x: 11 * tileSize, y: 2 * tileSize }
},
{
type: "Mage",
pos: { x: 7 * tileSize, y: 7 * tileSize }
}
]
};
module.exports = level;

View File

@ -10,8 +10,8 @@ let level = {
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,
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, 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, 11, 10, 13
14, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 16, 47, 12, 11, 11, 10, 13,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 50, 13, 0, 0, 0, 0,
],
size: {
w: 30 * tileSize,
@ -19,20 +19,9 @@ let level = {
},
startPos: [
{ x: 5 * tileSize, y: 3 * tileSize },
{ x: 48, y: 128 }
{ x: 24 * tileSize, y: 6 * tileSize }
],
entities: [
{
type: "Mage",
pos: { x: 1 * tileSize, y: 8 * tileSize }
},
{
type: "Chest",
pos: { x: 4 * tileSize, y: 2 * tileSize },
action: (player) => {
player.items.keys.push("1-1_1");
}
},
{
type: "Portal",
pos: { x: 5 * tileSize, y: 1 * tileSize },
@ -41,6 +30,24 @@ let level = {
level.switch = { module: __dirname + "/1-1.js", pos: 0 };
},
key: "1-1_1"
},
{
type: "Portal",
pos: { x: 24 * tileSize, y: 1 * tileSize },
texture: "Door_n",
action: (_player, level) => {
level.switch = { module: __dirname + "/1-4.js", pos: 0 };
},
key: "1-4"
},
{
type: "Portal",
pos: { x: 24 * tileSize, y: 8 * tileSize },
texture: "Door_s",
action: (_player, level) => {
level.switch = { module: __dirname + "/1-3.js", pos: 0 };
},
key: ""
}
]
};

57
src/levels/1-3.js Normal file
View File

@ -0,0 +1,57 @@
const tileSize = 32;
let level = {
tiles: [
1, 2, 2, 2, 2, 2, 2, 2, 5, 6,
4, 21, 22, 23, 21, 22, 23, 21, 22, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
14, 15, 11, 11, 11, 11, 11, 11, 10, 13
],
size: {
w: 10 * tileSize,
h: 20 * tileSize
},
startPos: [
{ x: 5 * tileSize, y: 3 * tileSize }
],
entities: [
{
type: "Mage",
pos: { x: 4.5 * tileSize, y: 10 * tileSize }
},
{
type: "Chest",
pos: { x: 4.5 * tileSize, y: 17 * tileSize },
action: (player) => {
player.items.keys.push("1-4");
}
},
{
type: "Portal",
pos: { x: 5 * tileSize, y: 1 * tileSize },
texture: "Door_n",
action: (_player, level) => {
level.switch = { module: __dirname + "/1-2.js", pos: 1 };
},
key: ""
}
]
};
module.exports = level;

45
src/levels/1-4.js Normal file
View File

@ -0,0 +1,45 @@
const tileSize = 32;
let level = {
tiles: [
1, 2, 2, 2, 2, 2, 2, 2, 6,
4, 21, 22, 23, 21, 22, 23, 21, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
14, 15, 11, 16, 47, 12, 11, 10, 13,
0, 0, 0, 14, 50, 13, 0, 0, 0, 0,
],
size: {
w: 9 * tileSize,
h: 10 * tileSize
},
startPos: [
{ x: 5 * tileSize, y: 3 * tileSize }
],
entities: [
{
type: "Portal",
pos: { x: 4 * tileSize, y: 8 * tileSize },
texture: "Door_s",
action: (_player, level) => {
level.switch = { module: __dirname + "/1-2.js", pos: 1 };
},
key: ""
},
{
type: "Portal",
pos: { x: 4 * tileSize, y: 3 * tileSize },
texture: "Ladder",
action: (_player, level) => {
level.switch = { module: __dirname + "/2-1.js", pos: 0 };
},
key: "1-4"
}
]
};
module.exports = level;

45
src/levels/2-1.js Normal file
View File

@ -0,0 +1,45 @@
const tileSize = 32;
let level = {
tiles: [
1, 2, 2, 2, 2, 2, 2, 2, 6,
4, 21, 22, 23, 21, 22, 23, 21, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 51, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
14, 15, 11, 16, 47, 12, 11, 10, 13,
0, 0, 0, 14, 50, 13, 0, 0, 0, 0,
],
size: {
w: 9 * tileSize,
h: 10 * tileSize
},
startPos: [
{ x: 5 * tileSize, y: 3 * tileSize }
],
entities: [
{
type: "Portal",
pos: { x: 4 * tileSize, y: 8 * tileSize },
texture: "Door_s",
action: (_player, level) => {
level.switch = { module: __dirname + "/2-2.js", pos: 0 };
},
key: ""
},
{
type: "Portal",
pos: { x: 4 * tileSize, y: 3 * tileSize },
texture: "Ladder",
action: (_player, level) => {
level.switch = { module: __dirname + "/1-4.js", pos: 0 };
},
key: "1-4"
}
]
};
module.exports = level;

83
src/levels/2-2.js Normal file
View File

@ -0,0 +1,83 @@
const tileSize = 32;
let level = {
tiles: [
1, 52, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 6,
4, 21, 22, 23, 21, 22, 23, 21, 22, 23, 21, 22, 23, 21, 22, 23, 21, 22, 23, 7,
4, 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, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
14, 48, 47, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 16, 47, 12, 11, 10, 13,
0, 14, 50, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 50, 13, 0, 0, 0, 0,
],
size: {
w: 20 * tileSize,
h: 7 * tileSize
},
startPos: [
{ x: 5 * tileSize, y: 3 * tileSize }
],
entities: [
{
type: "Portal",
pos: { x: 9 * tileSize, y: 1 * tileSize },
texture: "Door_n",
action: (_player, level) => {
level.switch = { module: __dirname + "/2-1.js", pos: 0 };
},
key: "1-4"
},
{
type: "Portal",
pos: { x: 4 * tileSize, y: 1 * tileSize },
texture: "Door_n",
action: (_player, level) => {
level.switch = { module: __dirname + "/2-3.js", pos: 0 };
},
key: "2-3"
},
{
type: "Portal",
pos: { x: 2 * tileSize, y: 5 * tileSize },
texture: "Door_s",
action: (_player, level) => {
level.switch = { module: __dirname + "/2-4.js", pos: 0 };
},
key: ""
},
{
type: "Portal",
pos: { x: 15 * tileSize, y: 5 * tileSize },
texture: "Door_s",
action: (_player, level) => {
level.switch = { module: __dirname + "/2-5.js", pos: 0 };
},
key: ""
},
{
type: "Portal",
pos: { x: 17 * tileSize, y: 3 * tileSize },
texture: "Ladder",
action: (_player, level) => {
level.switch = { module: __dirname + "/3-1.js", pos: 0 };
},
key: "3-1"
},
{
type: "Portal",
pos: { x: 15 * tileSize, y: tileSize },
texture: "Door_hidden",
action: (_player, level) => {
level.switch = { module: __dirname + "/2-6.js", pos: 0 };
},
key: "2-6"
},
{
type: "Sign",
pos: { x: 14 * tileSize, y: tileSize },
text: "Many secret to the left"
}
]
};
module.exports = level;

52
src/levels/2-3.js Normal file
View File

@ -0,0 +1,52 @@
const tileSize = 32;
let level = {
tiles: [
1, 2, 5, 2, 5, 2, 5, 2, 5, 6,
4, 21, 22, 23, 21, 22, 23, 21, 22, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
14, 11, 11, 11, 11, 11, 16, 47, 49, 13,
0, 0, 0, 0, 0, 0, 14, 50, 13, 0, 0,
],
size: {
w: 10 * tileSize,
h: 11 * tileSize
},
startPos: [
{ x: 7 * tileSize, y: 6.8 * tileSize }
],
entities: [
{
type: "Portal",
pos: { x: 7 * tileSize, y: 9 * tileSize },
texture: "Door_s",
action: (_player, level) => {
level.switch = { module: __dirname + "/2-2.js", pos: 0 };
},
key: ""
},
{
type: "Chest",
pos: { x: 1 * tileSize, y: 2 * tileSize },
action: (player) => {
player.items.keys.push("3-1");
}
},
{
type: "Mage",
pos: { x: 7 * tileSize, y: 3 * tileSize }
},
{
type: "Mage",
pos: { x: 2 * tileSize, y: 7 * tileSize }
}
]
};
module.exports = level;

44
src/levels/2-4.js Normal file
View File

@ -0,0 +1,44 @@
const tileSize = 32;
let level = {
tiles: [
1, 2, 5, 2, 5, 2, 5, 2, 5, 6,
4, 21, 22, 23, 21, 22, 23, 21, 22, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
14, 11, 11, 11, 11, 11, 11, 11, 11, 13,
],
size: {
w: 10 * tileSize,
h: 7 * tileSize
},
startPos: [
{ x: 7 * tileSize, y: 2 * tileSize }
],
entities: [
{
type: "Portal",
pos: { x: 7 * tileSize, y: 1 * tileSize },
texture: "Door_n",
action: (_player, level) => {
level.switch = { module: __dirname + "/2-2.js", pos: 0 };
},
key: ""
},
{
type: "Chest",
pos: { x: 1 * tileSize, y: 2 * tileSize },
action: (player) => {
player.items.keys.push("2-3");
}
},
{
type: "Mage",
pos: { x: 2 * tileSize, y: 3 * tileSize }
},
]
};
module.exports = level;

41
src/levels/2-5.js Normal file
View File

@ -0,0 +1,41 @@
const tileSize = 32;
let level = {
tiles: [
1, 2, 5, 2, 5, 2, 5, 2, 5, 6,
4, 21, 22, 23, 21, 22, 23, 21, 22, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
14, 11, 11, 11, 11, 11, 11, 11, 11, 13,
],
size: {
w: 10 * tileSize,
h: 7 * tileSize
},
startPos: [
{ x: 7 * tileSize, y: 2 * tileSize }
],
entities: [
{
type: "Portal",
pos: { x: 7 * tileSize, y: 1 * tileSize },
texture: "Door_n",
action: (_player, level) => {
level.switch = { module: __dirname + "/2-2.js", pos: 0 };
},
key: ""
},
{
type: "Mage",
pos: { x: 2 * tileSize, y: 3 * tileSize }
},
{
type: "Mage",
pos: { x: 5 * tileSize, y: 4 * tileSize }
},
]
};
module.exports = level;

50
src/levels/2-6.js Normal file
View File

@ -0,0 +1,50 @@
const tileSize = 32;
let level = {
tiles: [
1, 2, 2, 2, 2, 2, 2, 2, 6,
4, 21, 22, 23, 21, 22, 23, 21, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 51, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
14, 15, 11, 16, 47, 12, 11, 10, 13,
0, 0, 0, 14, 50, 13, 0, 0, 0, 0,
],
size: {
w: 9 * tileSize,
h: 10 * tileSize
},
startPos: [
{ x: 5 * tileSize, y: 3 * tileSize }
],
entities: [
{
type: "Portal",
pos: { x: 4 * tileSize, y: 8 * tileSize },
texture: "Door_s",
action: (_player, level) => {
level.switch = { module: __dirname + "/2-2.js", pos: 0 };
},
key: "2-6"
},
{
type: "Portal",
pos: { x: 4 * tileSize, y: 3 * tileSize },
texture: "Ladder",
action: (_player, level) => {
level.switch = { module: __dirname + "/0-1.js", pos: 0 };
},
key: ""
},
{
type: "Sign",
pos: { x: 3 * tileSize, y: tileSize },
text: "Impressive, you're good."
}
]
};
module.exports = level;

69
src/levels/3-1.js Normal file
View File

@ -0,0 +1,69 @@
const tileSize = 32;
let level = {
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, 4, 22, 23, 21, 22, 23, 21, 22, 23, 21, 22, 23, 7,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 17, 17, 12, 11, 11, 11, 11, 11, 11, 10, 13,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 17, 17, 7, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 17, 17, 7, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 17, 17, 7, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 17, 17, 7, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 17, 17, 7, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 17, 17, 7, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 17, 17, 17, 7, 0, 0, 0, 0, 0, 0, 0, 0,
1, 52, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 17, 17, 17, 7, 0, 0, 0, 0, 0, 0, 0, 0,
4, 22, 23, 21, 22, 23, 21, 22, 23, 21, 22, 23, 21, 22, 23, 21, 22, 23, 17, 17, 17, 7, 0, 0, 0, 0, 0, 0, 0, 0,
4, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7, 0, 0, 0, 0, 0, 0, 0, 0,
4, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7, 0, 0, 0, 0, 0, 0, 0, 0,
4, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7, 0, 0, 0, 0, 0, 0, 0, 0,
14, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 13, 0, 0, 0, 0, 0, 0, 0, 0,
],
size: {
w: 30 * tileSize,
h: 20 * tileSize
},
startPos: [
{ x: 25 * tileSize, y: 3 * tileSize },
{ x: 4 * tileSize, y: 15 * tileSize }
],
entities: [
{
type: "Portal",
pos: { x: 27 * tileSize, y: 3 * tileSize },
texture: "Ladder",
action: (_player, level) => {
level.switch = { module: __dirname + "/2-2.js", pos: 0 };
},
key: "3-1"
},
{
type: "Sign",
pos: { x: 25 * tileSize, y: tileSize },
text: "Climb the ladder and walk two tiles to the left"
},
{
type: "Portal",
pos: { x: 20 * tileSize, y: tileSize },
texture: "Door_hidden",
action: (_player, level) => {
level.switch = { module: __dirname + "/3-4.js", pos: 0 };
},
key: "3-4"
},
{
type: "Portal",
pos: { x: 4 * tileSize, y: 14 * tileSize },
texture: "Door_n",
action: (_player, level) => {
level.switch = { module: __dirname + "/3-3.js", pos: 0 };
},
key: ""
}
]
};
module.exports = level;

0
src/levels/3-2.js Normal file
View File

52
src/levels/3-3.js Normal file
View File

@ -0,0 +1,52 @@
const tileSize = 32;
let level = {
tiles: [
1, 2, 5, 2, 5, 2, 5, 2, 5, 6,
4, 21, 22, 23, 21, 22, 23, 21, 22, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 17, 7,
14, 11, 16, 47, 49, 11, 11, 11, 11, 13,
0, 0, 14, 50, 13, 0, 0, 0, 0, 0, 0,
],
size: {
w: 10 * tileSize,
h: 11 * tileSize
},
startPos: [
{ x: 7 * tileSize, y: 6.8 * tileSize }
],
entities: [
{
type: "Portal",
pos: { x: 3 * tileSize, y: 9 * tileSize },
texture: "Door_s",
action: (_player, level) => {
level.switch = { module: __dirname + "/3-1.js", pos: 1 };
},
key: ""
},
{
type: "Chest",
pos: { x: 8 * tileSize, y: 2 * tileSize },
action: (player) => {
player.items.keys.push("2-6");
}
},
{
type: "Mage",
pos: { x: 7 * tileSize, y: 3 * tileSize }
},
{
type: "Mage",
pos: { x: 2 * tileSize, y: 7 * tileSize }
}
]
};
module.exports = level;

50
src/levels/3-4.js Normal file
View File

@ -0,0 +1,50 @@
const tileSize = 32;
let level = {
tiles: [
1, 2, 2, 2, 2, 2, 2, 2, 6,
4, 21, 22, 23, 21, 22, 23, 21, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
4, 17, 17, 17, 17, 17, 17, 17, 7,
14, 15, 11, 16, 47, 12, 11, 10, 13,
0, 0, 0, 14, 50, 13, 0, 0, 0, 0,
],
size: {
w: 9 * tileSize,
h: 10 * tileSize
},
startPos: [
{ x: 5 * tileSize, y: 3 * tileSize }
],
entities: [
{
type: "Portal",
pos: { x: 4 * tileSize, y: 8 * tileSize },
texture: "Door_s",
action: (_player, level) => {
level.switch = { module: __dirname + "/3-1.js", pos: 0 };
},
key: "3-4"
},
{
type: "Portal",
pos: { x: 4 * tileSize, y: tileSize },
texture: "Door_n",
action: (_player, level) => {
level.gameComplete = true;
},
key: "3-4"
},
{
type: "Sign",
pos: { x: 3 * tileSize, y: tileSize },
text: "Congrats."
}
]
};
module.exports = level;

67
src/screens/credits.js Normal file
View File

@ -0,0 +1,67 @@
const asdf = require("asdf-games");
// eslint-disable-next-line no-unused-vars
const { Text, Container, Rect, Texture, Sprite } = asdf;
const text = require(__dirname + "/../../res/lang/default.js");
const fillStyleHeadline = {fill: "#ffffff", font: "24px Minecraft"};
const fillStyleNormal = {fill: "#ffffff", font: "16px Minecraft"};
const logo = new Texture(__dirname + "/../../res/images/logo.png");
class Credits extends Container {
constructor(game, keys, onEnd) {
super();
this.game = game;
this.keys = keys;
this.onEnd = onEnd;
this.children = [];
this.debounceTime = 2;
this.add(new Rect(this.game.w, this.game.h, { fill: "#333333" }));
const logoSprite = new Sprite(logo);
logoSprite.pos = { x: 160, y: 0 };
logoSprite.scale = { x: 0.5, y: 0.5 };
this.add(logoSprite);
const creditsText = new Text(text.credits.credits, fillStyleHeadline);
creditsText.pos = { x: 260, y: 120 };
this.add(creditsText);
const arneText = new Text(text.credits.arne, fillStyleNormal);
arneText.pos = { x: 125, y: 170 };
this.add(arneText);
const jobText = new Text(text.credits.job, fillStyleNormal);
jobText.pos = { x: 125, y: 200 };
this.add(jobText);
const hannahText = new Text(text.credits.hannah, fillStyleNormal);
hannahText.pos = { x: 125, y: 230 };
this.add(hannahText);
const logoText = new Text(text.credits.font, fillStyleNormal);
logoText.pos = { x: 125, y: 260 };
this.add(logoText);
var instruction = new Text(text.gameOver.instruction, fillStyleNormal);
instruction.pos = { x: 175, y: 300 };
this.add(instruction);
}
update(dt, t) {
super.update(dt, t);
if (this.keys.action && this.debounceTime <= 0) {
this.onEnd();
}
this.debounceTime -= dt;
}
}
module.exports = Credits;

View File

@ -9,20 +9,21 @@ var Player = require(__dirname + "/../entities/player.js");
var Level = require(__dirname + "/../helpers/level.js");
class GameScreen extends Container {
constructor(game, window, keys, onGameOver) {
constructor(game, window, keys, onGameOver, onComplete) {
super();
this.game = game;
this.window = window;
this.keys = keys;
this.onGameOver = onGameOver;
this.onComplete = onComplete;
this.keys.reset();
// Initialise first level 1-1.js at startPosition 0
var player = new Player(keys, window);
var level = new Level(require(__dirname + "/../levels/1-1.js"), keys, player);
var level = new Level(require(__dirname + "/../levels/2-2.js"), keys, player);
player.pos.x = level.startPos[0].x / 1;
player.pos.y = level.startPos[0].y / 1;
player.level = level;
@ -85,7 +86,7 @@ class GameScreen extends Container {
var { camera, player, level, keys } = this;
// Debug options
if (debugMode && keys.ctrl && keys.key(66)) {
if (debugMode && keys.escape) {
console.debug(level);
console.debug(player);
}
@ -94,6 +95,10 @@ class GameScreen extends Container {
this.onGameOver();
}
if (level.gameComplete) {
this.onComplete();
}
// Switch to another level
if (level.switch) {
if (debugMode) {

View File

@ -2,6 +2,8 @@ const asdf = require("asdf-games");
// eslint-disable-next-line no-unused-vars
const { Texture, Container, TileSprite, Text, AnimManager, Rect, Sprite } = asdf;
const { shell } = require("electron");
const text = require(__dirname + "/../../res/lang/default.js");
const fillStyle = {fill: "#ffffff", font: "24px Minecraft"};
@ -85,6 +87,11 @@ class Title extends Container {
this.onQuit();
}
// Open gitea on key g
if (this.keys.key(71)) {
shell.openExternal("https://gitea.arnweb.nl/Hecc-inc./caa-game");
}
}
}