replace gameChar with this in gameChar = {}
This commit is contained in:
parent
ed0e3b8783
commit
b2b1bf06ba
85
sketch.js
85
sketch.js
@ -82,8 +82,8 @@ function startGame(full_start, update_objects) {
|
|||||||
push();
|
push();
|
||||||
strokeWeight(1);
|
strokeWeight(1);
|
||||||
stroke(1);
|
stroke(1);
|
||||||
gameChar.x_step *= gameChar.scale;
|
this.x_step *= this.scale;
|
||||||
gameChar.y_step *= gameChar.scale;
|
this.y_step *= this.scale;
|
||||||
function _drawBody(jumping = false) {
|
function _drawBody(jumping = false) {
|
||||||
fill(palette.body_color);
|
fill(palette.body_color);
|
||||||
if (jumping) {
|
if (jumping) {
|
||||||
@ -135,7 +135,7 @@ function startGame(full_start, update_objects) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Standing, facing frontwards
|
// Standing, facing frontwards
|
||||||
if (gameChar.sprite == 1) {
|
if (this.sprite == 1) {
|
||||||
// Body
|
// Body
|
||||||
_drawBody();
|
_drawBody();
|
||||||
// Head
|
// Head
|
||||||
@ -149,16 +149,16 @@ function startGame(full_start, update_objects) {
|
|||||||
_drawBody(true);
|
_drawBody(true);
|
||||||
// Hands. (Hands!)
|
// Hands. (Hands!)
|
||||||
line(
|
line(
|
||||||
gameChar.x - gameChar.x_step * 1,
|
this.x - this.x_step * 1,
|
||||||
gameChar.y - gameChar.y_step * 2.5,
|
this.y - this.y_step * 2.5,
|
||||||
gameChar.x - gameChar.x_step * 3.2,
|
this.x - this.x_step * 3.2,
|
||||||
gameChar.y - gameChar.y_step * 3.2
|
this.y - this.y_step * 3.2
|
||||||
);
|
);
|
||||||
line(
|
line(
|
||||||
gameChar.x + gameChar.x_step * 1,
|
this.x + this.x_step * 1,
|
||||||
gameChar.y - gameChar.y_step * 2.5,
|
this.y - this.y_step * 2.5,
|
||||||
gameChar.x + gameChar.x_step * 3.2,
|
this.x + this.x_step * 3.2,
|
||||||
gameChar.y - gameChar.y_step * 3.2
|
this.y - this.y_step * 3.2
|
||||||
);
|
);
|
||||||
// Head
|
// Head
|
||||||
_drawHead();
|
_drawHead();
|
||||||
@ -166,15 +166,15 @@ function startGame(full_start, update_objects) {
|
|||||||
_drawEyes(true, true, 3.8);
|
_drawEyes(true, true, 3.8);
|
||||||
}
|
}
|
||||||
// Walking right
|
// Walking right
|
||||||
else if (gameChar.sprite == 3) {
|
else if (this.sprite == 3) {
|
||||||
// Body
|
// Body
|
||||||
_drawBody();
|
_drawBody();
|
||||||
// Hand. (Hand!)
|
// Hand. (Hand!)
|
||||||
line(
|
line(
|
||||||
gameChar.x,
|
this.x,
|
||||||
gameChar.y - gameChar.y_step * 2.5,
|
this.y - this.y_step * 2.5,
|
||||||
gameChar.x + gameChar.x_step * 0.8,
|
this.x + this.x_step * 0.8,
|
||||||
gameChar.y - gameChar.y_step * 1
|
this.y - this.y_step * 1
|
||||||
);
|
);
|
||||||
// Head
|
// Head
|
||||||
_drawHead();
|
_drawHead();
|
||||||
@ -182,15 +182,15 @@ function startGame(full_start, update_objects) {
|
|||||||
_drawEyes(false, true, 4.2);
|
_drawEyes(false, true, 4.2);
|
||||||
}
|
}
|
||||||
// Walking left
|
// Walking left
|
||||||
else if (gameChar.sprite == 4) {
|
else if (this.sprite == 4) {
|
||||||
// Body
|
// Body
|
||||||
_drawBody();
|
_drawBody();
|
||||||
// Hand. (Hand!)
|
// Hand. (Hand!)
|
||||||
line(
|
line(
|
||||||
gameChar.x,
|
this.x,
|
||||||
gameChar.y - gameChar.y_step * 2.5,
|
this.y - this.y_step * 2.5,
|
||||||
gameChar.x - gameChar.x_step * 0.8,
|
this.x - this.x_step * 0.8,
|
||||||
gameChar.y - gameChar.y_step * 1
|
this.y - this.y_step * 1
|
||||||
);
|
);
|
||||||
// Head
|
// Head
|
||||||
_drawHead();
|
_drawHead();
|
||||||
@ -198,21 +198,21 @@ function startGame(full_start, update_objects) {
|
|||||||
_drawEyes(true, false, 4.2);
|
_drawEyes(true, false, 4.2);
|
||||||
}
|
}
|
||||||
// Jumping left
|
// Jumping left
|
||||||
else if (gameChar.sprite == 5) {
|
else if (this.sprite == 5) {
|
||||||
// Body
|
// Body
|
||||||
_drawBody(true);
|
_drawBody(true);
|
||||||
// Hands. (Hands!)
|
// Hands. (Hands!)
|
||||||
line(
|
line(
|
||||||
gameChar.x - gameChar.x_step * 1,
|
this.x - this.x_step * 1,
|
||||||
gameChar.y - gameChar.y_step * 2.5,
|
this.y - this.y_step * 2.5,
|
||||||
gameChar.x - gameChar.x_step * 3.2,
|
this.x - this.x_step * 3.2,
|
||||||
gameChar.y - gameChar.y_step * 3.2
|
this.y - this.y_step * 3.2
|
||||||
);
|
);
|
||||||
line(
|
line(
|
||||||
gameChar.x + gameChar.x_step * 1,
|
this.x + this.x_step * 1,
|
||||||
gameChar.y - gameChar.y_step * 2.5,
|
this.y - this.y_step * 2.5,
|
||||||
gameChar.x + gameChar.x_step * 3.2,
|
this.x + this.x_step * 3.2,
|
||||||
gameChar.y - gameChar.y_step * 3.2
|
this.y - this.y_step * 3.2
|
||||||
);
|
);
|
||||||
// Head
|
// Head
|
||||||
_drawHead();
|
_drawHead();
|
||||||
@ -220,21 +220,21 @@ function startGame(full_start, update_objects) {
|
|||||||
_drawEyes(true, false, 3.8);
|
_drawEyes(true, false, 3.8);
|
||||||
}
|
}
|
||||||
// Jumping right
|
// Jumping right
|
||||||
else if (gameChar.sprite == 6) {
|
else if (this.sprite == 6) {
|
||||||
// Body
|
// Body
|
||||||
_drawBody(true);
|
_drawBody(true);
|
||||||
// Hands. (Hands!)
|
// Hands. (Hands!)
|
||||||
line(
|
line(
|
||||||
gameChar.x - gameChar.x_step * 1,
|
this.x - this.x_step * 1,
|
||||||
gameChar.y - gameChar.y_step * 2.5,
|
this.y - this.y_step * 2.5,
|
||||||
gameChar.x - gameChar.x_step * 3.2,
|
this.x - this.x_step * 3.2,
|
||||||
gameChar.y - gameChar.y_step * 3.2
|
this.y - this.y_step * 3.2
|
||||||
);
|
);
|
||||||
line(
|
line(
|
||||||
gameChar.x + gameChar.x_step * 1,
|
this.x + this.x_step * 1,
|
||||||
gameChar.y - gameChar.y_step * 2.5,
|
this.y - this.y_step * 2.5,
|
||||||
gameChar.x + gameChar.x_step * 3.2,
|
this.x + this.x_step * 3.2,
|
||||||
gameChar.y - gameChar.y_step * 3.2
|
this.y - this.y_step * 3.2
|
||||||
);
|
);
|
||||||
// Head
|
// Head
|
||||||
_drawHead();
|
_drawHead();
|
||||||
@ -242,13 +242,12 @@ function startGame(full_start, update_objects) {
|
|||||||
_drawEyes(false, true, 3.8);
|
_drawEyes(false, true, 3.8);
|
||||||
} else {
|
} else {
|
||||||
text("Bad sprite number!", 10, 10);
|
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;
|
this.x_step /= this.scale;
|
||||||
gameChar.y_step /= gameChar.scale;
|
this.y_step /= this.scale;
|
||||||
pop();
|
pop();
|
||||||
},
|
},
|
||||||
|
|
||||||
getCurGroundPosY: function() {
|
getCurGroundPosY: function() {
|
||||||
return this.possibleGroundPosY[this.curGroundPosYIndex];
|
return this.possibleGroundPosY[this.curGroundPosYIndex];
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user