From f70ecbd2db08c57e7a175879748c40fdc137f71a Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Tue, 13 Mar 2018 13:50:39 +0100 Subject: [PATCH] Update: CC - Snake FS - Key Up (306204wy29.js) 104 bytes modified --- 306204wy29.js | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/306204wy29.js b/306204wy29.js index b1408d6..0d93190 100644 --- a/306204wy29.js +++ b/306204wy29.js @@ -3,54 +3,56 @@ if (!this.entityLoaded) { } if (!this.initialized) { - this.direction = this.entityLoaded.direction; + + this.state = this.entityLoaded.state; + this.initialized = true; } if (data.keyCode === GameLib.System.Input.KEY_UP) { - if (this.direction.y === -1) { + if (this.state.direction.y === -1) { return; } - if (this.direction.y === 1) { + if (this.state.direction.y === 1) { return; } - if (this.direction.x === 1) { - this.direction.y = 1; - this.rotation += Math.PI / 2; + if (this.state.direction.x === 1) { + this.state.direction.y = 1; + this.state.rotation += Math.PI / 2; } - if (this.direction.x === -1) { - this.direction.y = 1; - this.rotation -= Math.PI / 2; + if (this.state.direction.x === -1) { + this.state.direction.y = 1; + this.state.rotation -= Math.PI / 2; } - this.direction.x = 0; + this.state.direction.x = 0; } if (data.keyCode === GameLib.System.Input.KEY_DOWN) { - if (this.direction.y === 1) { + if (this.state.direction.y === 1) { return; } - this.direction.y = -1; - this.direction.x = 0; + this.state.direction.y = -1; + this.state.direction.x = 0; } if (data.keyCode === GameLib.System.Input.KEY_LEFT) { - if (this.direction.x === 1) { + if (this.state.direction.x === 1) { return; } - this.direction.y = 0; - this.direction.x = -1; + this.state.direction.y = 0; + this.state.direction.x = -1; } if (data.keyCode === GameLib.System.Input.KEY_RIGHT) { - if (this.direction.x === -1) { + if (this.state.direction.x === -1) { return; } - this.direction.y = 0; - this.direction.x = 1; + this.state.direction.y = 0; + this.state.direction.x = 1; }