Added collision check to the right side (only implemented to the left side intially).
Bounce of the ceiling is abit less aggressive.
This commit is contained in:
parent
61d024b56d
commit
9c5252fe3b
@ -89,7 +89,7 @@ pub const Game = struct {
|
||||
self.playerVelocity.y = 0;
|
||||
} else if (self.playerVelocity.y < 0 and self.playerIsUnderTile()) {
|
||||
self.playerPosition.y = std.math.ceil(self.playerPosition.y);
|
||||
self.playerVelocity.y = -self.playerVelocity.y;
|
||||
self.playerVelocity.y = 0.1;
|
||||
}
|
||||
if (self.playerVelocity.x != 0) {
|
||||
const playerTileTop = @floatToInt(i64, std.math.floor(self.playerPosition.y));
|
||||
@ -101,7 +101,13 @@ pub const Game = struct {
|
||||
self.playerVelocity.x = 0;
|
||||
}
|
||||
}
|
||||
// const playerTileRight = @floatToInt(i64, std.math.floor(self.playerPosition.x)) + 1;
|
||||
if (self.playerVelocity.x > 0) {
|
||||
const playerTileRight = @floatToInt(i64, std.math.floor(self.playerPosition.x)) + 1;
|
||||
if (self.level.tiles.get(playerTileRight, playerTileTop) != null or self.level.tiles.get(playerTileRight, playerTileBottom) != null) {
|
||||
self.playerPosition.x = std.math.floor(self.playerPosition.x);
|
||||
self.playerVelocity.x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
self.playerDirection = if (self.playerVelocity.x == 0) self.playerDirection else if (self.playerVelocity.x > 0) Direction.Right else Direction.Left;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user