boold.java

来自「java 写的坦克大战,,里面涉及了java几乎所有的基础知识..」· Java 代码 · 共 67 行

JAVA
67
字号
package com.wuxiaohong.tank;
import java.awt.*;


public class Boold {
	private int x,y,w,h;
	TankClient tc;
	int step = 0;
	private boolean live = true;
	//指明血块运动的轨迹,
	private int[][] pos = {
	          {350, 300}, {360, 300}, {375, 275}, {400, 200}, {360, 270}, {365, 290}, {340, 280}
			  };
	
	public Boold() {
		this.x = 100;
		this.y = 100;
		this.w = 10;
		this.h = 10;
	}



	public void draw(Graphics g)
	{
		if(!live)
		{
			return ;
		}
		Color c = g.getColor();
		g.setColor(Color.MAGENTA);
		g.fillRect(x, y, w, h);
		g.setColor(c);
		move();
	}
	
	public void move()
	{
		if(step==pos.length)
		{
			step=0;
		}
		x = pos[step][0];
		y = pos[step][1];
		step++;
	}
	
	public Rectangle getRect()
	{
		return new Rectangle(x,y,w,h); 
	}



	public boolean isLive() {
		return live;
	}



	public void setLive(boolean live) {
		this.live = live;
	}
	
	
}

⌨️ 快捷键说明

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