// brute force collisions, compare every entity against
// every other entity. If any of them collide notify
// both entities that the collision has occured
for (int p=0;p<entities.size();p++) {
for (int s=p+1;s<entities.size();s++) {
Entity me = (Entity) entities.get(p);
Entity him = (Entity) entities.get(s);
if (me.collidesWith(him)) {
me.collidedWith(him);
him.collidedWith(me);
}
}
}
// draw the appropriate section of the tilemap based on the centre (hence the -(TANK_SIZE/2)) of
// the player
int playerTileX = (int) gigi.getX();
int playerTileY = (int) gigi.getY();
// caculate the offset of the player from the edge of the tile. As the player moves around this
// varies and this tells us how far to offset the tile based rendering to give the smooth
// motion of scrolling
int playerTileOffsetX = (int) ((playerTileX - gigi.getX()) * mappa.getTileSize());
int playerTileOffsetY = (int) ((playerTileY - gigi.getY()) * mappa.getTileSize());
// render the section of the map that should be visible. Notice the -1 and +3 which renders
// a little extra map around the edge of the screen to cope with tiles scrolling on and off
// the screen
mappa.render(playerTileOffsetX - (gigi.ENTITY_SPRITE_SIZE / 2), playerTileOffsetY - (gigi.ENTITY_SPRITE_SIZE / 2),
playerTileX - leftOffsetInTiles - 1,
playerTileY - topOffsetInTiles - 1,
widthInTiles + 3, heightInTiles + 3);
// draw entities relative to the player that must appear in the centre of the screen
g.translate(400 - (int) (gigi.getX() * 32), 300 - (int) (gigi.getY() * 32));
// elimino le entit� segnalate per la rimozione
removeEntity();
// disegno entit�
for (int i = 0; i < entities.size(); i++) {
Entity ent = entities.get(i);
// l'eroe deve essere animato in modo diverso (in base all'input dell'utente)
ent.draw(g);
/*
if ( ent instanceof Gigi){
((Gigi)ent).draw(g);
} else {