Browse Source

work on northern cave

tags/v0.1.4^2
Big Bad Waffle 7 years ago
parent
commit
aae84c230f
3 changed files with 220 additions and 63 deletions
  1. +31
    -40
      src/client/js/components/lightPatch.js
  2. +2
    -1
      src/client/js/rendering/renderer.js
  3. +187
    -22
      src/server/config/maps/cave/map.json

+ 31
- 40
src/client/js/components/lightPatch.js View File

@@ -12,7 +12,8 @@ define([
type: 'lightPatch',

color: 'f7ffb2',
sprites: [],
patches: [],
rays: [],

init: function(blueprint) {
this.blueprint = this.blueprint || {};
@@ -41,45 +42,22 @@ define([
sprite.blendMode = PIXI.BLEND_MODES.OVERLAY;
sprite.pluginName = 'picture';

this.sprites.push(sprite);
this.patches.push(sprite);
}
}

/*var rCount = (obj.width * obj.height) / 11;
var rCount = ((obj.width * obj.height) / 10) + ~~(Math.random() + 2);
for (var i = 0; i < rCount; i++) {
var nx = x + ~~(Math.random() * obj.width) + 2;
var ny = y + ~~(Math.random() * obj.height) - (obj.height / 3);
var nx = x + 3 + ~~(Math.random() * (obj.width - 1));
var ny = y - 4 + ~~(Math.random() * (obj.height));
var w = 1 + ~~(Math.random() * 2);
var h = (obj.height / 2) + ~~(Math.random() * obj.height * 7);
var h = 6 + ~~(Math.random() * 13);
var hm = 2;

var ray = renderer.buildObject({
x: nx,
y: ny,
cell: 0,
sheetName: 'ray',
var rContainer = renderer.buildContainer({
layerName: 'lightBeams'
});
ray.alpha = 0.1 + (Math.random() * 0.2);
ray.width = w * scaleMult;
ray.height = h * scaleMult;
//ray.position = new PIXI.Point((nx * scale), (ny * scale));
ray.pivot = new PIXI.Point(0.5, 0.5);
ray.rotation = 0.5;
ray.tint = 0xffeb38;

ray.blendMode = PIXI.BLEND_MODES.ADD;
sprite.pluginName = 'picture';

this.sprites.push(ray);
}*/

var rCount = (obj.width * obj.height) / 11;
for (var i = 0; i < rCount; i++) {
var nx = x + ~~(Math.random() * obj.width);
var ny = y + ~~(Math.random() * (obj.height)) - (obj.height / 2);
var w = 1 + ~~(Math.random() * 2);
var h = (obj.height / 4) + ~~(Math.random() * obj.height * 3);
var hm = 2;
this.rays.push(rContainer);

for (var j = 0; j < h; j++) {
var ray = renderer.buildObject({
@@ -87,30 +65,43 @@ define([
y: ny,
cell: 0,
sheetName: 'white',
layerName: 'lightBeams'
parent: rContainer
});
ray.x = ~~((nx * scale) - (scaleMult * j));
ray.y = (ny * scale) + (scaleMult * j * hm);
ray.alpha = ((1.0 - (j / h)) * 0.45) * (0.5 + (Math.random() * 0.5));
ray.alpha = ((1.0 - (j / h)) * 0.4);// * (0.5 + (Math.random() * 0.5));
ray.width = w * scaleMult;
ray.height = scaleMult * hm;
ray.tint = 0xffeb38;
ray.blendMode = PIXI.BLEND_MODES.ADD;

this.sprites.push(ray);
}
}
},

update: function() {

var rays = this.rays;
var rLen = rays.length;
for (var i = 0; i < rLen; i++) {
var r = rays[i];

r.alpha += (Math.random() * 0.03) - 0.015;
if (r.alpha < 0.3)
r.alpha = 0.3;
else if (r.alpha > 1)
r.alpha = 1;
}
},

destroy: function() {
this.sprites.forEach(function(s) {
s.parent.removeChild(s);
this.patches.forEach(function(p) {
p.parent.removeChild(p);
});
this.patches = [];

this.rays.forEach(function(r) {
r.parent.removeChild(r);
});
this.sprites = [];
this.rays = [];
}
};
});

+ 2
- 1
src/client/js/rendering/renderer.js View File

@@ -748,7 +748,8 @@ define([
else
sprite.x += scale;
}
(this.layers[obj.layerName || obj.sheetName] || this.layers.objects).addChild(sprite);

(obj.parent || this.layers[obj.layerName || obj.sheetName] || this.layers.objects).addChild(sprite);

return sprite;
},


+ 187
- 22
src/server/config/maps/cave/map.json
File diff suppressed because it is too large
View File


Loading…
Cancel
Save