package com.bjsxt.tank; import java.awt.*; public class Blood { int x, y, w, h; int step = 0; TankClient tc; private boolean live = true; public Blood() { x = pos[0][0]; y = pos[0][1]; w = h = 15; } public int[][] pos = {{400, 300}, {320, 300}, {370, 250}, {340, 280}, {365, 290}, {340, 280}}; 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(); } private void move() { step++; if(step == pos.length) { step = 0; }else { x = pos[step][0]; y = pos[step][1]; } } public Rectangle getRect() { return new Rectangle(x, y, w, h); } public boolean isLive() { return live; } public void setLive(boolean life) { this.live = life; } }