public class RandomItem
{
	private int x;

	private int y;

	private int w;

	private int h;

	private Image img;

	private static bool visible;

	private bool falling = true;

	private int turnCount;

	private int nexty;

	public RandomItem()
	{
		w = img.getWidth();
		h = img.getHeight();
	}

	public void newPos(int x, int y)
	{
		this.x = x;
		this.y = y;
		visible = true;
		falling = true;
	}

	public void update()
	{
		if (turnCount == 3)
		{
			if (visible)
			{
				visible = false;
			}
			else
			{
				newPos(CRes.random(300, 800), 400);
			}
			turnCount = 0;
		}
		if (!visible || !falling)
		{
			return;
		}
		nexty = y + 5;
		while (y < nexty)
		{
			y++;
			if (GameScr.mm.isLand(x, y))
			{
				falling = false;
				break;
			}
		}
		if (y > GameScr.HEIGHT)
		{
			visible = false;
			falling = false;
		}
	}

	public void paint(mGraphics g)
	{
		if (visible)
		{
			g.drawImage(img, x, y, mGraphics.BOTTOM | mGraphics.HCENTER, false);
		}
	}
}
