Obstacle p = obstacleList.get(i);
if (p instanceof Crate) {// for instance of crate
Crate c = (Crate) p;
CrateRectangle cRect = c.getRectangle();
g.drawImage(cRect.getImage(), cRect.xCoord(), cRect.yCoord(),
null);
}
if (p instanceof ImmovableBlock) {// for instance of immovableBlock
ImmovableBlock ib = (ImmovableBlock) p;
ImmovableBlockRectangle ibRect = ib.getRectangle();