diff --git a/78gnds8jrj.js b/78gnds8jrj.js index a4373dc..859693a 100644 --- a/78gnds8jrj.js +++ b/78gnds8jrj.js @@ -165,22 +165,39 @@ GameLib.CustomCode.prototype.adjustSpeed = function(delta) { }.bind(this); -GameLib.CustomCode.prototype.adjustSnailPosition = function(diff) { +GameLib.CustomCode.prototype.adjustSnailPosition = function(delta) { - this.snail.position.z -= diff * 0.001 * this.speed; - - if (this.snail.position.z < -4.8) { - this.snail.position.z = -4.8; + var diff = 0; + var modified = false; + + if (this.movement.left) { + diff = data.delta * this.speed * 0.01; + this.snail.position.z -= diff; + this.movement.left = false; + modified = true; } - - if (this.snail.position.z > 4.8) { - this.snail.position.z = 4.8; + + if (this.movement.right) { + diff = data.delta * this.speed * 0.01; + this.snail.position.z += diff; + this.movement.right = false; + modified = true; } + + if (modified) { + if (this.snail.position.z < -4.8) { + this.snail.position.z = -4.8; + } - this.solar.position.z = this.snail.position.z; + if (this.snail.position.z > 4.8) { + this.snail.position.z = 4.8; + } - this.snail.updateInstance('position'); - this.solar.updateInstance('position'); + this.solar.position.z = this.snail.position.z; + + this.snail.updateInstance('position'); + this.solar.updateInstance('position'); + } }.bind(this); @@ -195,6 +212,13 @@ GameLib.Event.Subscribe( this.speed = 0; this.speedUp = false; + this.movement = { + left : false, + right : false, + leftAmount : 0, + rightAmount : 0 + }; + this.clouds.map( function(cloud) { cloud.geometry = null;