SpeedBoostRectangle rect = s.getRectangle();
LinkedList<Obstacle> obs = map.getObstacles();
LinkedList<PlayerTank> tank = map.getPlayers();
LinkedList<Item> item = map.getItems();
for (PlayerTank p : tank) {
TankRectangle tRect = p.getRectangle();
if(tRect.intersects(rect)) {
return false;
}
}
for (Item p : item) {
if(p instanceof SpeedBoost) {
SpeedBoost s = (SpeedBoost)p;
SpeedBoostRectangle tRect = s.getRectangle();
if(tRect.intersects(rect)) {
return false;
}
}
if(p instanceof IceBlock) {
IceBlock s = (IceBlock)p;
IceBlockRectangle tRect = s.getRectangle();
if(tRect.intersects(rect)) {
return false;
}
}
}
for (int i = 0; i < obs.size(); i++) {
Obstacle p = obs.get(i);
if (p instanceof Crate) {// for instance of crate
Crate c = (Crate) p;
CrateRectangle tRect = c.getRectangle();
if(tRect.intersects(rect)) {
return false;
}
}
if (p instanceof ImmovableBlock) {// for instance of immovableBlock
ImmovableBlock ib = (ImmovableBlock) p;
ImmovableBlockRectangle tRect = ib.getRectangle();
if(tRect.intersects(rect)) {
return false;
}
}
if (p instanceof SpikePit) {// for instance of SpikePit
SpikePit sp = (SpikePit) p;
SpikePitRectangle tRect = sp.getRectangle();
if(tRect.intersects(rect)) {
return false;
}
}
if (p instanceof FireRing) {// for instance of fireRing
FireRing fr = (FireRing) p;
FireRingRectangle tRect = fr.getRectangle();
if(tRect.intersects(rect)) {
return false;
}
}
if (p instanceof TNT) {// for instance of TNT
TNT tnt = (TNT) p;
TNTRectangle tRect = tnt.getRectangle();
if(tRect.intersects(rect)) {
return false;
}
}