import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Random;

import javax.imageio.ImageIO;

public class Obstacle {
	int x, y;
	BufferedImage image;
	BufferedImage stone, cacti;
	int speed;

	int score = 10;

	public Obstacle() {
		try {
			stone = ImageIO.read(new File("image/石头.png"));
			cacti = ImageIO.read(new File("image/仙人掌.png"));
		} catch (IOException e) {
			e.printStackTrace();
			System.out.println("图片文件没找到");
		}
		Random r = new Random();// 随机数
		int temp = r.nextInt(2);// 0-1
		if (temp == 0) {
			image = stone;
		} else {
			image = cacti;
		}
		speed = BackgroundImgae.SPEED;
		x = 800;
		y = 200 - image.getHeight();
	}

	public void move() {
		x -= speed;
	}

	public Rectangle getBounds() {
		if (image == cacti) {
			return new Rectangle(x + 7, y, 15, image.getHeight());
		} else {
			return new Rectangle(x + 5, y + 4, 23, 21);
		}

	}

	public int getScore() {
		int tmp = score;
		score =0;
		return tmp;
	}
	


}
