Permalink
Browse files

Make start and end points much more obvious.

  • Loading branch information...
kevadsett committed Sep 10, 2016
1 parent ba295f8 commit c8d2579ac4c5bd4fb4c8f342b62807132f7cbe5c
View
@@ -29,12 +29,12 @@ var TILE_TYPES = [
{
name: "floor",
value: 3,
colour: "#fff"
colour: "rgb(122, 143, 164)"
},
{
name: "antifloor",
value: 4,
colour: "#fff"
colour: "rgb(22, 43, 54)"
},
{
name: "blocker",
@@ -16,7 +16,7 @@ LevelContainerController.prototype = {
var x = width * c;
var y = height * r;
var type = TILE_TYPES[columnValue];
var tile = new LevelTileController(new Vector2(x, y), width, height, type, 10 * r + c);
var tile = new LevelTileController(new Vector2(x, y), width, height, type, 10 * r + c, type.name === "spawnPoint" ? 0.5 : 1);
if (columnValue == 1) {
this.model.spawnPoint = tile;
@@ -1,5 +1,5 @@
function LevelTileController(position, width, height, type, index) {
this.model = new LevelTileModel(position, width, height, type, index);
function LevelTileController(position, width, height, type, index, startSize) {
this.model = new LevelTileModel(position, width, height, type, index, startSize);
this.view = new LevelTileView(this.model);
GameEvents.on("glitchModeChanged", this.onGlitchModeChanged, this);
GameEvents.on("update", this.update, this);
@@ -31,6 +31,12 @@ LevelTileController.prototype = {
}
}
}
if (this.model.type.name === "spawnPoint") {
this.model.relativeSize = (this.model.relativeSize + dt) % 1;
}
if (this.model.type.name === "exit") {
this.model.relativeSize = (1 + (this.model.relativeSize - dt)) % 1;
}
},
generateGlitchParameters: function() {
this.model.glitchTime = Math.random() * 2000;
@@ -1,9 +1,10 @@
function LevelTileModel(position, width, height, type, index) {
function LevelTileModel(position, width, height, type, index, startSize) {
this.position = position;
this.width = width;
this.height = height;
this.type = type;
this.index = index;
this.relativeSize = startSize;
this.bounds = {
top: this.position.y,
@@ -10,19 +10,29 @@ LevelTileView.prototype = {
if (layer === "level" && this.model.type.name === "blocker") return;
if (layer === "background" && this.model.type.name !== "blocker") return;
if (this.model.type.name === "floor" || this.model.type.name === "antifloor") {
if (this.model.isGlitching) {
ctx.globalCompositeOperation = "multiply";
this.drawRect("cyan", 0.1, this.glitchOffsets[0], this.model.isShowingGlitch);
this.drawRect("magenta", 0.1, this.glitchOffsets[1], this.model.isShowingGlitch);
this.drawRect("yellow", 0.1, this.glitchOffsets[2]), this.model.isShowingGlitch;
} else {
this.drawRect("white", 1);
}
} else {
this.drawRect(this.model.type.colour, 1);
switch (this.model.type.name) {
case "floor":
case "antifloor":
if (this.model.isGlitching) {
ctx.globalCompositeOperation = "multiply";
this.drawRect("cyan", 0.1, this.glitchOffsets[0], this.model.isShowingGlitch);
this.drawRect("magenta", 0.1, this.glitchOffsets[1], this.model.isShowingGlitch);
this.drawRect("yellow", 0.1, this.glitchOffsets[2]), this.model.isShowingGlitch;
} else {
this.drawRect(this.model.type.colour, 1);
}
break;
case "spawnPoint":
var colour = Math.floor((255 * this.model.relativeSize)).toString(16);
this.drawRect("#" + colour + colour + colour, 1);
break;
case "exit":
var colour = Math.floor((255 * this.model.relativeSize)).toString(16);
this.drawRect("#" + colour + colour + colour, 1);
break;
default:
this.drawRect(this.model.type.colour, 1);
break;
}
if (window.drawDebug) {
@@ -65,10 +75,7 @@ LevelTileView.prototype = {
}
ctx.globalAlpha = alpha;
ctx.fillStyle = colour;
ctx.fillRect(scaledPosition.x, scaledPosition.y, scaledSize, scaledSize);
ctx.fillRect(scaledPosition.x, scaledPosition.y, scaledSize * this.model.relativeSize, scaledSize * this.model.relativeSize);
},
destroy: function() {
GameEvents.off('draw', this.draw, this);

0 comments on commit c8d2579

Please sign in to comment.