diff --git a/sketch.js b/sketch.js index 7ac6d16..15a22f6 100644 --- a/sketch.js +++ b/sketch.js @@ -82,8 +82,8 @@ function startGame(full_start, update_objects) { push(); strokeWeight(1); stroke(1); - gameChar.x_step *= gameChar.scale; - gameChar.y_step *= gameChar.scale; + this.x_step *= this.scale; + this.y_step *= this.scale; function _drawBody(jumping = false) { fill(palette.body_color); if (jumping) { @@ -135,7 +135,7 @@ function startGame(full_start, update_objects) { } } // Standing, facing frontwards - if (gameChar.sprite == 1) { + if (this.sprite == 1) { // Body _drawBody(); // Head @@ -149,16 +149,16 @@ function startGame(full_start, update_objects) { _drawBody(true); // Hands. (Hands!) line( - gameChar.x - gameChar.x_step * 1, - gameChar.y - gameChar.y_step * 2.5, - gameChar.x - gameChar.x_step * 3.2, - gameChar.y - gameChar.y_step * 3.2 + this.x - this.x_step * 1, + this.y - this.y_step * 2.5, + this.x - this.x_step * 3.2, + this.y - this.y_step * 3.2 ); line( - gameChar.x + gameChar.x_step * 1, - gameChar.y - gameChar.y_step * 2.5, - gameChar.x + gameChar.x_step * 3.2, - gameChar.y - gameChar.y_step * 3.2 + this.x + this.x_step * 1, + this.y - this.y_step * 2.5, + this.x + this.x_step * 3.2, + this.y - this.y_step * 3.2 ); // Head _drawHead(); @@ -166,15 +166,15 @@ function startGame(full_start, update_objects) { _drawEyes(true, true, 3.8); } // Walking right - else if (gameChar.sprite == 3) { + else if (this.sprite == 3) { // Body _drawBody(); // Hand. (Hand!) line( - gameChar.x, - gameChar.y - gameChar.y_step * 2.5, - gameChar.x + gameChar.x_step * 0.8, - gameChar.y - gameChar.y_step * 1 + this.x, + this.y - this.y_step * 2.5, + this.x + this.x_step * 0.8, + this.y - this.y_step * 1 ); // Head _drawHead(); @@ -182,15 +182,15 @@ function startGame(full_start, update_objects) { _drawEyes(false, true, 4.2); } // Walking left - else if (gameChar.sprite == 4) { + else if (this.sprite == 4) { // Body _drawBody(); // Hand. (Hand!) line( - gameChar.x, - gameChar.y - gameChar.y_step * 2.5, - gameChar.x - gameChar.x_step * 0.8, - gameChar.y - gameChar.y_step * 1 + this.x, + this.y - this.y_step * 2.5, + this.x - this.x_step * 0.8, + this.y - this.y_step * 1 ); // Head _drawHead(); @@ -198,21 +198,21 @@ function startGame(full_start, update_objects) { _drawEyes(true, false, 4.2); } // Jumping left - else if (gameChar.sprite == 5) { + else if (this.sprite == 5) { // Body _drawBody(true); // Hands. (Hands!) line( - gameChar.x - gameChar.x_step * 1, - gameChar.y - gameChar.y_step * 2.5, - gameChar.x - gameChar.x_step * 3.2, - gameChar.y - gameChar.y_step * 3.2 + this.x - this.x_step * 1, + this.y - this.y_step * 2.5, + this.x - this.x_step * 3.2, + this.y - this.y_step * 3.2 ); line( - gameChar.x + gameChar.x_step * 1, - gameChar.y - gameChar.y_step * 2.5, - gameChar.x + gameChar.x_step * 3.2, - gameChar.y - gameChar.y_step * 3.2 + this.x + this.x_step * 1, + this.y - this.y_step * 2.5, + this.x + this.x_step * 3.2, + this.y - this.y_step * 3.2 ); // Head _drawHead(); @@ -220,21 +220,21 @@ function startGame(full_start, update_objects) { _drawEyes(true, false, 3.8); } // Jumping right - else if (gameChar.sprite == 6) { + else if (this.sprite == 6) { // Body _drawBody(true); // Hands. (Hands!) line( - gameChar.x - gameChar.x_step * 1, - gameChar.y - gameChar.y_step * 2.5, - gameChar.x - gameChar.x_step * 3.2, - gameChar.y - gameChar.y_step * 3.2 + this.x - this.x_step * 1, + this.y - this.y_step * 2.5, + this.x - this.x_step * 3.2, + this.y - this.y_step * 3.2 ); line( - gameChar.x + gameChar.x_step * 1, - gameChar.y - gameChar.y_step * 2.5, - gameChar.x + gameChar.x_step * 3.2, - gameChar.y - gameChar.y_step * 3.2 + this.x + this.x_step * 1, + this.y - this.y_step * 2.5, + this.x + this.x_step * 3.2, + this.y - this.y_step * 3.2 ); // Head _drawHead(); @@ -242,13 +242,12 @@ function startGame(full_start, update_objects) { _drawEyes(false, true, 3.8); } else { text("Bad sprite number!", 10, 10); - console.error("Bad gameChar sprite number: " + gameChar.sprite); + console.error("Bad gameChar sprite number: " + this.sprite); } - gameChar.x_step /= gameChar.scale; - gameChar.y_step /= gameChar.scale; + this.x_step /= this.scale; + this.y_step /= this.scale; pop(); }, - getCurGroundPosY: function() { return this.possibleGroundPosY[this.curGroundPosYIndex]; },