Skip to content

Commit

Permalink
Fixing jump
Browse files Browse the repository at this point in the history
  • Loading branch information
kopiro committed Nov 20, 2023
1 parent 6ea9cac commit 538446c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function checkForRockCollision({ x, y, z }, treshold) {
$rocks.reduce((acc, rock) => {
const quantizedX = Math.floor(rock.x / treshold);
const quantizedY = Math.floor(rock.y / treshold);
const quantizedZ = Math.floor(rock.z / treshold);
const quantizedZ = Math.floor(rock.z / (treshold * 2));
const key = `${quantizedX}-${quantizedY}-${quantizedZ}`;
acc[key] = rock;
return acc;
Expand All @@ -112,7 +112,7 @@ function checkForRockCollision({ x, y, z }, treshold) {
// Check for lookup
const quantizedX = Math.floor(x / treshold);
const quantizedY = Math.floor(y / treshold);
const quantizedZ = Math.floor(z / treshold);
const quantizedZ = Math.floor(z / (treshold * 2));
const key = `${quantizedX}-${quantizedY}-${quantizedZ}`;

return key in __rockCollisionCache[treshold];
Expand Down Expand Up @@ -249,7 +249,7 @@ function advancePlayer(key, now) {
if (game.mode === "auto") {
// Check for imminent collision
if (!game.$[key].jumpingStartTime) {
const collision = checkForRockCollision(game.$[key], IMG_SIZE * 0.8);
const collision = checkForRockCollision(game.$[key], IMG_SIZE);
if (collision) {
console.log("collision :>> ", collision);
game.$[key].jumpingStartTime = now;
Expand Down Expand Up @@ -417,7 +417,7 @@ async function main() {

KEYS.forEach((key) => {
if (e.key.toLowerCase() === key.substring(0, 1).toLowerCase()) {
game.$[key].z += COOP_ADVANCE;
game.$[key].z -= COOP_ADVANCE;
}
});
});
Expand Down

0 comments on commit 538446c

Please sign in to comment.