From 730bfbe56851e918e26c62c678339b116fd7c3f6 Mon Sep 17 00:00:00 2001 From: Arne van Iterson Date: Thu, 26 Mar 2020 20:09:30 +0100 Subject: [PATCH] Attempting to add some light --- src/entities/player.js | 2 +- src/game.js | 11 +++++++++-- src/levels/level.js | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/entities/player.js b/src/entities/player.js index 8328345..e906dca 100644 --- a/src/entities/player.js +++ b/src/entities/player.js @@ -12,7 +12,7 @@ class Player extends TileSprite { this.rate = { walking: 0.2, - running: 0.08 + running: 0.1 }; this.anims = new AnimManager(this); diff --git a/src/game.js b/src/game.js index a59d6bc..9c6c107 100644 --- a/src/game.js +++ b/src/game.js @@ -1,7 +1,7 @@ const { ipcRenderer, remote } = require("electron"); var asdf = require("asdf-games"); -const { Game, KeyControls, MouseControls, Camera } = asdf; +const { Game, KeyControls, MouseControls, Camera, Lighting } = asdf; const window = { w: 640, h: 320 }; @@ -18,12 +18,19 @@ const keys = new KeyControls(); var level = new Level(); var player = new Player(keys, window, level); +var lightsources = [ + { x: 100, y: 100 }, + { x: 300, y: 100 }, + { x: 500, y: 100 }, + { x: 500, y: 300 } +]; +var lighting = new Lighting(level.x, level.y, level.w, level.h, lightsources); const camera = new Camera(player, window, { w: level.w * 2, h: level.h * 2 }); scene.add(camera); camera.add(level); camera.add(player); - +camera.add(lighting); game.run(() => { if (mouseAim.isDown) { diff --git a/src/levels/level.js b/src/levels/level.js index 6b7057d..167d2e7 100644 --- a/src/levels/level.js +++ b/src/levels/level.js @@ -10,8 +10,8 @@ const levelSize = { w: 960, h: 480 }; var levelData = [ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 3, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 6, - 3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6, - 3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6, + 3, 16, 16, 16, 16, 20, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6, + 3, 16, 16, 16, 16, 20, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6, 3, 16, 16, 16, 16, 20, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6, 3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6, 3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6,