Tile Engine: Entity location wrong
Posted
by Trizicus
on Stack Overflow
See other posts from Stack Overflow
or by Trizicus
Published on 2010-04-21T21:55:11Z
Indexed on
2010/04/21
22:13 UTC
Read the original article
Hit count: 228
I've made a tile engine that has 30px by 30px. I've ran into a problem with an object for example.
I've loaded an object 20px by 20px and when I do a collision check I have to use x/y position which is top left in Java2D. How can I do collision detection based on the entire object?
This is relevant code:
boolean checkCol() {
int currentGridX = ship.getX()/30;
int currentGridY = ship.getY()/30;
if(test[currentGridX][currentGridY] == 0)
return true;
System.out.println("collision");
return false;
}
© Stack Overflow or respective owner