Wall collision fix.
This commit is contained in:
parent
b7f669224d
commit
5e1c7fb4dd
|
@ -97,7 +97,7 @@ function MainLoop(timestamp)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (wallLeft < lastWallLeft) {
|
if (wallLeft < lastWallLeft) {
|
||||||
mrCroc.position.x = lastWallLeft + 1;
|
mrCroc.position.x = lastWallLeft + mrCroc.getWidth() * 0.5 + 1;
|
||||||
}
|
}
|
||||||
} else if (KeyRight.isPressed()) {
|
} else if (KeyRight.isPressed()) {
|
||||||
mrCroc.moveRight(timestamp, delta);
|
mrCroc.moveRight(timestamp, delta);
|
||||||
|
@ -108,7 +108,7 @@ function MainLoop(timestamp)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (wallRight > lastWallRight) {
|
if (wallRight > lastWallRight) {
|
||||||
mrCroc.position.x = lastWallRight - 1;
|
mrCroc.position.x = lastWallRight - mrCroc.getWidth() * 0.5 - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,6 @@ function MainLoop(timestamp)
|
||||||
mrCroc.getPositionHeadLeft().draw(context);
|
mrCroc.getPositionHeadLeft().draw(context);
|
||||||
mrCroc.getPositionFootLeft().draw(context);
|
mrCroc.getPositionFootLeft().draw(context);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
lastRendered = timestamp;
|
lastRendered = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ export default class RetroArchitecture
|
||||||
|
|
||||||
while (tilePosition !== null && tilePosition.x < this.columns) {
|
while (tilePosition !== null && tilePosition.x < this.columns) {
|
||||||
if (this.matrix[tilePosition.y][tilePosition.x] !== null) {
|
if (this.matrix[tilePosition.y][tilePosition.x] !== null) {
|
||||||
return tilePosition.x * this.tileWidth - this.tileWidth * 0.5;
|
return tilePosition.x * this.tileWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
tilePosition.x++;
|
tilePosition.x++;
|
||||||
|
@ -131,7 +131,7 @@ export default class RetroArchitecture
|
||||||
|
|
||||||
while (tilePosition !== null && tilePosition.x > 0) {
|
while (tilePosition !== null && tilePosition.x > 0) {
|
||||||
if (this.matrix[tilePosition.y][tilePosition.x] !== null) {
|
if (this.matrix[tilePosition.y][tilePosition.x] !== null) {
|
||||||
return tilePosition.x * this.tileWidth + this.tileWidth * 1.5;
|
return tilePosition.x * this.tileWidth + this.tileWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
tilePosition.x--;
|
tilePosition.x--;
|
||||||
|
|
Loading…
Reference in New Issue