Skip to content

Commit

Permalink
Add surface collision detection
Browse files Browse the repository at this point in the history
  • Loading branch information
s-macke committed Sep 27, 2017
1 parent 26b5ac2 commit 7525222
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions VoxelSpace.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@
camera.horizon -= 2;
keypressed = true;
}

// Collision detection. Don't fly below the surface.
var mapoffset = ((Math.floor(camera.y) & 1023) << 10) + (Math.floor(camera.x) & 1023)|0;
if ((heightmap[mapoffset]+10) > camera.height) camera.height = heightmap[mapoffset] + 10;
}

// ---------------------------------------------
Expand Down

0 comments on commit 7525222

Please sign in to comment.