collidesX = false;
collidesY = false;
grounded = false;
Tilemap tm = Tilemap.getInstance();
// Kollision des Akteurs mit der Tilemap
// Tile links oben
int x = getHitbox().newX;
int y = getHitbox().newY;
Collidable tile = tm.getTilefromCoord(x, y);
synchronized (tile) {
tile.getHitbox().setLocation(x - x % tm.getTilesizeX(), y - y % tm.getTilesizeY());
if (tile.isBlocked()) {
tile.handleCollisionWith(this);
}
}
// Tile rechts oben
x = getHitbox().newX + getHitbox().width - 1;
y = getHitbox().newY;
tile = tm.getTilefromCoord(x, y);
synchronized (tile) {
tile.getHitbox().setLocation(x - x % tm.getTilesizeX(), y - y % tm.getTilesizeY());
if (tile.isBlocked()) {
tile.handleCollisionWith(this);
}
}
// Tile links
x = getHitbox().newX;
y = getHitbox().newY + getHitbox().height / 2;
tile = tm.getTilefromCoord(x, y);
synchronized (tile) {
tile.getHitbox().setLocation(x - x % tm.getTilesizeX(), y - y % tm.getTilesizeY());
if (tile.isBlocked()) {
tile.handleCollisionWith(this);
}
}
// Tile rechts
x = getHitbox().newX + getHitbox().width - 1;
y = getHitbox().newY + getHitbox().height / 2;
tile = tm.getTilefromCoord(x, y);
synchronized (tile) {
tile.getHitbox().setLocation(x - x % tm.getTilesizeX(), y - y % tm.getTilesizeY());
if (tile.isBlocked()) {
tile.handleCollisionWith(this);
}
}
// Tile links unten
x = getHitbox().newX;
y = getHitbox().newY + getHitbox().height;
tile = tm.getTilefromCoord(x, y);
synchronized (tile) {
tile.getHitbox().setLocation(x - x % tm.getTilesizeX(), y - y % tm.getTilesizeY());
if (tile.isBlocked()) {
tile.handleCollisionWith(this);
}
}
// Tile rechts unten
x = getHitbox().newX + getHitbox().width - 1;
y = getHitbox().newY + getHitbox().height;
tile = tm.getTilefromCoord(x, y);
synchronized (tile) {
tile.getHitbox().setLocation(x - x % tm.getTilesizeX(), y - y % tm.getTilesizeY());
if (tile.isBlocked()) {
tile.handleCollisionWith(this);
}
}