Edit: Solved it!
Hello!
Im making a a tile based game, and now im adding collision detection between player and a tile.
The collision works for only a small corner of the object and not the whole thing and i cant figure out how to fix it.
Player.java
public int tile(float i){
return (int)Math.floor(i / 16 );
}
public void update (int delta, Level level){
if(!level.solid(tile(x + + dx *delta), tile(y)))
x += dx *delta;
//else if(!level.solid(tile(x), tile(y += dy *delta)))
y += dy *delta;
}
Level.java
public boolean solid(int x,int y){
if(x < 0 || x >= getMapWidth())
return true;
if(y< 0 || y >= getMapHeight())
return true;
if(data[x][y]==1)
return true;
return false;
}
So the player checks if the next tile is solid… Its a txt based map
But as i said it only works with top left corner of the player and i cant figure out how to make the whole player(64x64)
Cheers! // Marrw