⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bullet.java

📁 小时候经常玩的坦克游戏
💻 JAVA
字号:
import java.awt.*;

public class bullet{
	private int xPos;
	private int yPos;
	private Rectangle bullet;
	private int direction;
	private int Speed;
	private int bulletpower;

	public bullet(int a, int b, int c, int d, int e){
		xPos = a;
		yPos = b;
		direction = c;
		Speed = d;
		bulletpower = e;
	}

	public void draw(Graphics g) {
		g.setColor(Color.lightGray);
		if(direction == 0 || direction == 1)
			g.fillRect(xPos-1, yPos-4, 3, 9);
		if(direction == 2 || direction == 3)
			g.fillRect(xPos-4, yPos-1, 9, 3);
	}

	public void move(){
		if(direction == 0)
			yPos = yPos - Speed;
		if(direction == 1)
			yPos = yPos + Speed;
		if(direction == 2)
			xPos = xPos - Speed;
		if(direction == 3)
			xPos = xPos + Speed;
	}

	public Rectangle getbulletborder(){
		if(direction == 0)
			bullet = new Rectangle(xPos-2, yPos-5, 5, 11);
		if(direction == 1)
			bullet = new Rectangle(xPos-2, yPos-5, 5, 11);
		if(direction == 2)
			bullet = new Rectangle(xPos-5, yPos-2, 11, 5);
		if(direction == 3)
			bullet = new Rectangle(xPos-5, yPos-2, 11, 5);
		return bullet;
	}

	public Point getbulletposition(){
		return new Point(xPos, yPos);
	}

	public int getbulletpower(){
		return bulletpower;
	}

	public int getbulletdirection(){
		return direction;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -