import java.awt.*; import com.genuts.gameui.*; public class CarouselTile extends GroundTile { /** * Speed of the robot shifting. */ private final static int SPEED = 2; /** * The robot to shift. */ private static Sprite colSprite = null; public CarouselTile(Sprite sprite) { super(sprite); } /** * Checks if the robot collides with the tile. */ public boolean checkCollision(Sprite sprite) { return (super.checkCollision(sprite) && (((sprite.getX() + sprite.getWidth() - sprite.getRightCollisionOffset()) > (getX() + 1)) || ((sprite.getY() + sprite.getHeight() - sprite.getBottomCollisionOffset()) == getY()))); } /** * Stores the robot to shift. */ protected boolean preCollisionWith(Sprite s) { colSprite = s; return false; } /** * Shifts the robot. */ public void tick(int ticks) { super.tick(ticks); if ((colSprite != null) && !((RobotControler) colSprite).isFlying()) { colSprite.setPosition(colSprite.getX() + SPEED, colSprite.getY()); } colSprite = null; } }