Attempting to add some light

This commit is contained in:
Arne van Iterson 2020-03-26 20:09:30 +01:00
parent 1bb9448408
commit 730bfbe568
3 changed files with 12 additions and 5 deletions

View File

@ -12,7 +12,7 @@ class Player extends TileSprite {
this.rate = {
walking: 0.2,
running: 0.08
running: 0.1
};
this.anims = new AnimManager(this);

View File

@ -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) {

View File

@ -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,