Permalink
Browse files

Make glitched-out platforms more visible.

  • Loading branch information...
kevadsett committed Sep 13, 2016
1 parent 26de34d commit 3b24b240b6ca5148fc2566c00ee0a83f9fec1999
Showing with 21 additions and 20 deletions.
  1. +1 −1 src/js/controllers/LevelTileController.js
  2. +20 −19 src/js/views/LevelTileView.js
@@ -16,7 +16,7 @@ LevelTileController.prototype = {
update: function(dt) {
if (this.model.isGlitching) {
if (!this.model.isShowingGlitch) {
if (Math.random() > 0.99) {
if (Math.random() > 0.9) {
this.model.isShowingGlitch = true;
this.model.glitchStartTime = Date.now();
this.generateGlitchParameters();
@@ -9,15 +9,20 @@ LevelTileView.prototype = {
if (layer !== "level" && layer !== "background") return;
if (layer === "level" && this.model.type.name === "blocker") return;
if (layer === "background" && this.model.type.name !== "blocker") return;
this.scaledPosition = this.model.position.scale(window.gameScale);
this.scaledSize = TILE_SIZE * window.gameScale;
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;
this.drawRect("cyan", 1, this.glitchOffsets[0], this.model.isShowingGlitch);
this.drawRect("magenta", 1, this.glitchOffsets[1], this.model.isShowingGlitch);
this.drawRect("yellow", 1, this.glitchOffsets[2]), this.model.isShowingGlitch;
ctx.globalCompositeOperation = "source-over";
ctx.strokeStyle = "white";
ctx.globalAlpha = 0.5;
ctx.strokeRect(this.scaledPosition.x, this.scaledPosition.y, this.scaledSize, this.scaledSize);
} else {
this.drawRect(this.model.type.colour, 1);
}
@@ -36,14 +41,11 @@ LevelTileView.prototype = {
}
if (DRAW_DEBUG) {
var scaledPosition = this.model.position.scale(window.gameScale);
ctx.fillStyle = "white";
ctx.font = "12px sans-serif";
ctx.textAlign = "left";
ctx.fillText(this.model.index, scaledPosition.x + 6, scaledPosition.y + 18);
ctx.fillText(this.model.index, this.scaledPosition.x + 6, this.scaledPosition.y + 18);
}
ctx.globalCompositeOperation = "source-over";
},
changeGlitchDisplay: function() {
this.glitchOffsets[0].x = (Math.random() * 20) - 10;
@@ -60,24 +62,23 @@ LevelTileView.prototype = {
if (!offset) {
offset = new Vector2(0, 0);
}
var scaledPosition = this.model.position.scale(window.gameScale).add(offset);
var scaledSize = TILE_SIZE * window.gameScale;
if (randomiseCanvas) {
ctx.drawImage(
ctx.canvas,
scaledPosition.x + this.model.canvasGrabSourcePosition.x,
scaledPosition.y + this.model.canvasGrabSourcePosition.y,
scaledSize + this.model.canvasGrabSize.x,
scaledSize + this.model.canvasGrabSize.y,
scaledPosition.x + this.model.canvasGrabDestPosition.x,
scaledPosition.y + this.model.canvasGrabDestPosition.y,
scaledSize + this.model.canvasGrabSize.x,
scaledSize + this.model.canvasGrabSize.y
this.scaledPosition.x + this.model.canvasGrabSourcePosition.x + offset.x,
this.scaledPosition.y + this.model.canvasGrabSourcePosition.y + offset.y,
this.scaledSize + this.model.canvasGrabSize.x,
this.scaledSize + this.model.canvasGrabSize.y,
this.scaledPosition.x + this.model.canvasGrabDestPosition.x + offset.x,
this.scaledPosition.y + this.model.canvasGrabDestPosition.y + offset.y,
this.scaledSize + this.model.canvasGrabSize.x,
this.scaledSize + this.model.canvasGrabSize.y
);
}
ctx.globalAlpha = alpha;
ctx.fillStyle = colour;
ctx.fillRect(scaledPosition.x, scaledPosition.y, scaledSize * this.model.relativeSize, scaledSize * this.model.relativeSize);
ctx.fillRect(this.scaledPosition.x + offset.x, this.scaledPosition.y + offset.y, this.scaledSize * this.model.relativeSize, this.scaledSize * this.model.relativeSize);
},
destroy: function() {
GameEvents.off('draw', this.draw, this);

0 comments on commit 3b24b24

Please sign in to comment.