Fixed some merge conflicts and moved some files

This commit is contained in:
Arne van Iterson 2020-04-11 21:12:44 +02:00
commit a57dab97ce
7 changed files with 147 additions and 9 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules
._*
.DS_Store
.DS_Store
dist

View File

@ -1 +1,17 @@
# caa-game
# caa-game
Welcome to the official repository of caa-game. Here one can track the progress of this wonderful game, and find the installation instructions.
### 🏗️ Installation
To install, clone this repo, and run npm install.
```bash
git clone https://gitea.arnweb.nl/Hecc-inc./caa-game.git && cd caa-game
npm install
```
If you want to run this game, enter `npm start` in your terminal.
### 🛠️ Building
To build this game into a distributable format,
- run `npm run build:win` on windows.
- run `npm run build:mac` on macOS.
- run `npm run build:linux` on linux.

View File

@ -1,9 +1,11 @@
const { app, BrowserWindow, ipcMain } = require("electron");
const path = require("path");
require("electron-reload")(__dirname, {
electron: path.join(__dirname, "node_modules", ".bin", "electron")
});
if (process.env.NODE_ENV === "dev") {
require("electron-reload")(__dirname, {
electron: path.join(__dirname, "node_modules", ".bin", "electron")
});
}
function createWindow () {
// Create the browser window.

52
package-lock.json generated
View File

@ -471,6 +471,58 @@
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
"dev": true
},
"cross-env": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.2.tgz",
"integrity": "sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw==",
"dev": true,
"requires": {
"cross-spawn": "^7.0.1"
},
"dependencies": {
"cross-spawn": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.2.tgz",
"integrity": "sha512-PD6G8QG3S4FK/XCGFbEQrDqO2AnMMsy0meR7lerlIOHAAbkuavGU/pOqprrlvfTNjvowivTeBsjebAL0NSoMxw==",
"dev": true,
"requires": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
}
},
"path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"dev": true
},
"shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"dev": true,
"requires": {
"shebang-regex": "^3.0.0"
}
},
"shebang-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"dev": true
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"requires": {
"isexe": "^2.0.0"
}
}
}
},
"cross-spawn": {
"version": "6.0.5",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",

View File

@ -4,8 +4,11 @@
"description": "",
"main": "main.js",
"scripts": {
"start": "npm run lint && electron .",
"lint": "eslint ."
"start": "npm run lint && cross-env NODE_ENV=dev electron .",
"lint": "eslint .",
"build:win": "electron-packager . --platform=win32 --out=dist --overwrite",
"build:mac": "electron-packager . --platform=darwin --out=dist --overwrite",
"build:linux": "electron-packager . --platform=linux --out=dist --overwrite"
},
"author": "McArn",
"license": "ISC",
@ -13,6 +16,7 @@
"asdf-games": "^1.0.12"
},
"devDependencies": {
"cross-env": "^7.0.2",
"electron": "^8.0.2",
"electron-packager": "^14.2.1",
"electron-reload": "^1.5.0",

View File

@ -14,6 +14,7 @@ const { scene } = game;
const mouseAim = new MouseControls(document.getElementById("board"));
const keys = new KeyControls();
const Stats = require("./src/helpers/stats.js");
var Player = require("./src/entities/player.js");
var Level = require("./src/helpers/level.js");
@ -26,10 +27,12 @@ player.pos.y = level.startPos[0].y / 1;
player.level = level;
const camera = new Camera(player, window, { w: level.w * 2, h: level.h * 2 });
const stats = new Stats(player);
scene.add(camera);
camera.add(level);
camera.add(player);
scene.add(stats);
function switchLevel(module, pos = 0) {
camera.map(function(e) {
@ -55,15 +58,15 @@ game.run(() => {
// Debugging tools
if (mouseAim.isDown) {
console.log("cliccccccccccc");
console.log(player.items);
console.log(player);
console.log(level);
}
// Switch to another level
if (level.switch) {
console.log("Switching level!", level);
switchLevel(require(level.switch.module), level.switch.pos);
level.switch = undefined;
console.log(player);
}
// Refocus camera to player when player is moved by a portal

60
src/helpers/stats.js Normal file
View File

@ -0,0 +1,60 @@
const { Container, TileSprite, Rect, Texture, Text } = require("asdf-games");
const tilemapFrames = require("../../res/tilemap.js");
const tilemap = new Texture("res/tilemap.png");
const tileSize = 32;
const fillStyle = {fill: "#ffffff", font: "24px Arial"};
class Stats extends Container {
constructor(player) {
super();
this.player = player;
const background = new Rect(640, 42, {fill: "rgba(0,0,0, 0.5)"});
background.pos = {x: 0, y: 280};
const livesText = new Text("LIVES:", fillStyle);
livesText.pos = {x: 10, y: 310};
const livesCounter = new Text(player.lives, fillStyle);
livesCounter.pos = {x: 90, y: 310};
const heart = new TileSprite(tilemap, tileSize, tileSize);
heart.frame = {x: tilemapFrames[42].x / tileSize, y: tilemapFrames[42].y / tileSize};
heart.pos = {x: 104, y: 284};
const staminaText = new Text("| STAMINA:", fillStyle);
staminaText.pos = {x: 140, y: 310};
this.children = [
background,
livesText,
livesCounter,
heart,
staminaText
// Stamina is added afterward
];
Array(5).fill().forEach((_val, index) => {
const sprite = new TileSprite(tilemap, tileSize, tileSize);
sprite.frame = {x: tilemapFrames[44].x / tileSize, y: tilemapFrames[44].y / tileSize};
sprite.pos = {x: index * 26 + 270, y: 286};
this.children.push(sprite);
});
}
update() {
this.children[2].text = this.player.lives;
Array(5).fill().forEach((_val, index) => {
//console.log(Math.round(this.player.stamina.current) - 1, index);
this.children[index + 5].frame =
(Math.round(this.player.stamina.current)) <= index
? {x: tilemapFrames[45].x / tileSize, y: tilemapFrames[45].y / tileSize}
: {x: tilemapFrames[44].x / tileSize, y: tilemapFrames[44].y / tileSize};
});
}
}
module.exports = Stats;