public boolean collisionJump(float x, float y, float z) { boolean collision = false; for (Cube cube : cubes) { if (cube.collision(-x, -y, -z, controller.playerHeight, controller.playerBox)) { collision = true; controller.jumping = false; break; } } return collision; }
public boolean collision(float x, float y, float z) { // collision detection for a player walking into a cube boolean collision = false; for (Cube cube : cubes) { // a slightly larger bounding box is given to the player // this makes it seem like the player is 3D if (cube.collision(-x, -y, -z, controller.playerHeight, controller.playerBox)) { collision = true; break; } } return collision; }
public boolean collision(float x, float y, float z, Cube cube) { // collision detection for a given cube return cube.collision(-x, -y, -z, controller.playerHeight, controller.playerBox); }