package cn.skyour.tank;
import java.awt.*;
public class Tank {
public static void main(String[] args) {
Frame w = new Frame();
w.setSize(1024, 768);
// w.setBackground(Color.BLACK);
MyPanel mp = new MyPanel();
w.add(mp);
Thread t = new Thread(mp);
t.start();
w.show();
}
}
class MyPanel extends Panel implements Runnable{
int x[] = new int[3];
int y[] = new int[3];
public MyPanel(){
for(int i=0;i<1;i++){
x[i]=505;
y[i]=500;
}
}
public void paint(Graphics g){
int x1=480;
int y1=510;
//坦克
g.fillRect(x1+20, y1+0, 20, 20);
//炮筒
g.fillRect(x1+0,y1+20 , 60, 20);
//身体
g.fillRect(x1+0,y1+40, 20, 20);
//左腿
g.fillRect(x1+40, y1+40, 20, 20);
//右腿
for(int i=0;i<1;i++){
g.drawString("●", x[i], y[i]);
}
}
public void run(){
while(true){
try{
for(int i=0; i<1;i++){
y[i]--;
if(y[i]<0){
y[i]=510;
}
}
Thread.sleep(300);
}catch(Exception e){
}
repaint();
}
}
}