Lighting is now even more broken
This commit is contained in:
parent
9b5e993062
commit
aff23993c5
24
lib/Lighting.js
Normal file
24
lib/Lighting.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
const Lightsource = require("./Lightsource.js");
|
||||||
|
const Container = require("./Container.js");
|
||||||
|
|
||||||
|
class Lighting extends Container {
|
||||||
|
constructor(x, y, mapW, mapH, sources, style = { start: "rgba(0, 0, 0, 0)", stop: "rgba(0, 0, 0, 0.5)", radius: 75 }) {
|
||||||
|
super();
|
||||||
|
this.pos = { x, y };
|
||||||
|
this.w = mapW;
|
||||||
|
this.h = mapH;
|
||||||
|
|
||||||
|
this.style = style;
|
||||||
|
if (sources.length > 1) {
|
||||||
|
this.style.stop = `rgba(0, 0, 0, ${1 - Math.round(Math.pow(0.25, 1 / sources.length) * 100) / 100})`;
|
||||||
|
console.log(this.style.stop);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let index = 0; index < sources.length; index++) {
|
||||||
|
const element = sources[index];
|
||||||
|
this.children.push(new Lightsource(element.x, element.y, x, y, mapW, mapH, this.style));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Lighting;
|
@ -1,7 +1,10 @@
|
|||||||
class Lightsource {
|
class Lightsource {
|
||||||
constructor(radius, style = { start: "rgba(255,255,255,0.5)", stop: "rgba(0,0,0,0.9)" }) {
|
constructor(x, y, mapX, mapY, mapW, mapH, style = { start: "rgba(0, 0, 0, 0)", stop: "rgba(0, 0, 0, 0.5)", radius: 100 }) {
|
||||||
this.pos = { x: 0, y: 0 };
|
this.pos = { mapX, mapY };
|
||||||
this.radius = radius;
|
this.radPos = { x, y };
|
||||||
|
this.mapW = mapW;
|
||||||
|
this.mapH = mapH;
|
||||||
|
this.radius = style.radius;
|
||||||
this.style = style;
|
this.style = style;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ var AnimManager = require("./AnimManager.js"),
|
|||||||
deadInTracks = require("./movement/deadInTracks.js"),
|
deadInTracks = require("./movement/deadInTracks.js"),
|
||||||
wallslide = require("./movement/wallslide.js"),
|
wallslide = require("./movement/wallslide.js"),
|
||||||
Rect = require("./Rect.js"),
|
Rect = require("./Rect.js"),
|
||||||
|
Lighting = require("./Lighting.js"),
|
||||||
Lightsource = require("./Lightsource.js"),
|
Lightsource = require("./Lightsource.js"),
|
||||||
KeyControls = require("./controls/KeyControls.js"),
|
KeyControls = require("./controls/KeyControls.js"),
|
||||||
MouseControls = require("./controls/MouseControls.js"),
|
MouseControls = require("./controls/MouseControls.js"),
|
||||||
@ -32,6 +33,7 @@ module.exports = {
|
|||||||
deadInTracks,
|
deadInTracks,
|
||||||
wallslide,
|
wallslide,
|
||||||
Rect,
|
Rect,
|
||||||
|
Lighting,
|
||||||
Lightsource,
|
Lightsource,
|
||||||
KeyControls,
|
KeyControls,
|
||||||
MouseControls,
|
MouseControls,
|
||||||
|
Loading…
Reference in New Issue
Block a user