Reworking the junkmap

This commit is contained in:
2014-06-13 01:20:35 -07:00
parent 03c61e05fe
commit 8175a46374
2 changed files with 11 additions and 25 deletions

File diff suppressed because one or more lines are too long

View File

@@ -27,12 +27,13 @@ var game = new Phaser.Game(640, 480, Phaser.AUTO, '');
// Create torch objects // Create torch objects
// Light constructor // Light constructor
var Light = function(game, x, y, key, frame, radius, fade, color_start, color_stop, flicker) { var Light = function(game, x, y, key, frame, radius, fade, color_start, color_stop, flicker, always_render) {
color_start = ( typeof color_start == undefined ? color_start : 'rgba(255, 255, 255, 1.0)'); color_start = ( typeof color_start == undefined ? color_start : 'rgba(255, 255, 255, 1.0)');
color_stop = ( typeof color_stop == undefined ? color_stop : 'rgba(255, 255, 255, 0.0)'); color_stop = ( typeof color_stop == undefined ? color_stop : 'rgba(255, 255, 255, 0.0)');
fade = ( typeof fade == undefined ? fade : 0.25); fade = ( typeof fade == undefined ? fade : 0.25);
radius = ( typeof radius == undefined ? radius : 64); radius = ( typeof radius == undefined ? radius : 64);
flicker = ( typeof flicker == undefined ? flicker : false); flicker = ( typeof flicker == undefined ? flicker : false);
always_render = ( typeof always_render == undefined ? always_render : false);
Phaser.Sprite.call(this, game, x, y, null); Phaser.Sprite.call(this, game, x, y, null);
@@ -43,6 +44,7 @@ var Light = function(game, x, y, key, frame, radius, fade, color_start, color_st
this.color_stop = color_stop; this.color_stop = color_stop;
this.radius = radius; this.radius = radius;
this.fade = radius * fade this.fade = radius * fade
this.always_render = always_render
this.rect = new Phaser.Rectangle(this.x - radius, this.y - radius, radius * 2, radius * 2) this.rect = new Phaser.Rectangle(this.x - radius, this.y - radius, radius * 2, radius * 2)
this.flicker = flicker; this.flicker = flicker;
console.log(this); console.log(this);
@@ -56,6 +58,7 @@ Light.prototype.update_new_values = function() {
this.radius = parseInt(this.radius); this.radius = parseInt(this.radius);
this.fade = this.radius * Number(this.fade); this.fade = this.radius * Number(this.fade);
this.flicker = Boolean(this.flicker); this.flicker = Boolean(this.flicker);
this.always_render = Boolean(this.always_render)
this.rect = new Phaser.Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2) this.rect = new Phaser.Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2)
} }
@@ -161,7 +164,7 @@ var moonlightSettings = {
'type': 'tiles', 'type': 'tiles',
'inject_sprites': true 'inject_sprites': true
}, },
'0 - NonCollide Overlay - Ground Objects': { '0 - NonCollide Overlay - Above Player': {
'collides': false, 'collides': false,
'collisionBetween': [0, 9999], 'collisionBetween': [0, 9999],
'type': 'tiles', 'type': 'tiles',
@@ -923,6 +926,7 @@ GameState.prototype.updateShadowTexture = function() {
// Iterate through each of the lights and draw the glow // Iterate through each of the lights and draw the glow
this.staticLights.forEach(function(light) { this.staticLights.forEach(function(light) {
// Don't draw lights that aren't on screen // Don't draw lights that aren't on screen
if ( light.always_render !== true )
var r1 = new Phaser.Rectangle(this.game.camera.x, var r1 = new Phaser.Rectangle(this.game.camera.x,
this.game.camera.y, this.game.camera.y,
this.game.camera.width, this.game.camera.width,