Okay, so now that my jump is working it’s breaking my collision detection. I need to figure out how to properly do it, so could someone please take a look at my code and tell me whats wrong?
public void update(Map m, Enemy[] e1, int max_enemies, Item[] i1, int max_Items){
//System.out.println("x: "+(int) (x/m.tileWidth));
//System.out.println("y: "+(int) ((y/m.tileHeight) - 0.1));
if(state != 2)
{
if(jumping){
if(m.tiles[(int) (x/m.tileWidth)][(int) ((y/m.tileHeight))] == 0 &&
m.tiles[(int) (x/m.tileWidth)][(int) ((y + height)/m.tileHeight)] == 0 &&
m.tiles[(int) ((x + width)/m.tileWidth)][(int) ((y/m.tileHeight))] == 0 &&
m.tiles[(int) ((x + width)/m.tileWidth)][(int) ((y + height)/m.tileHeight)] == 0 &&
!colbottom(i1, max_Items)){
velo = -jumpspeed;
y -= velo;
jumping = false;
}
else
velo = jumpspeed;
}
if(m.tiles[(int) ((x/m.tileWidth) + 0.1)][(int) (((y/m.tileHeight) - 0) - 0.0005)] == 0 &&
m.tiles[(int) ((((x + width)/m.tileWidth)) - 0.1)][(int) (((y/m.tileHeight) - 0) - 0.0005)] == 0 &&
!coltop(i1, max_Items) && !jumping){
falling = true;
velo += jumpangle;
}
else {
falling = false;
velo = 0;
}
//max fall speed
if(velo > 4)
velo = 4;
System.out.println("velo: " + velo + " " + falling);
y -= velo;
if(m.tiles[(int) ((x/m.tileWidth))][(int) (y/m.tileHeight)] == 1)
{
y = (((y) + m.tileHeight) - 0.0005f);
falling = false;
}
if(collision(e1,max_enemies))
{
state = 2;
frame = 0;
}
}
}