准备工作
理解java中的面向对象
理解GUI编程
理解多线程的使用
java中集合的使用
实体类
public class BackGround {
private int x;
private int y;
private int width;
private int height;
private ImageIcon icon= new ImageIcon ( "src\\image\\bg.jpg" ) ;
public BackGround ( int x, int y) {
this . x = x;
this . y = y;
this . width = icon. getIconWidth ( ) ;
this . height = icon. getIconHeight ( ) ;
}
public int getX ( ) {
return x;
}
public int getY ( ) {
return y;
}
public ImageIcon getIcon ( ) {
return icon;
}
public void move ( ) {
this . y+= 1 ;
}
}
public class Bomb {
private int x;
private int y;
public int time;
private ImageIcon icon= new ImageIcon ( "src\\image\\bomb.png" ) ;
public void setTime ( int time) {
this . time = time;
}
public Bomb ( int x, int y, int time) {
this . x = x;
this . y = y;
this . time= time;
}
public int getX ( ) {
return x;
}
public int getY ( ) {
return y;
}
public ImageIcon getIcon ( ) {
return icon;
}
}
public class Bullet {
private int x;
private int y;
private int width;
private int height;
private ImageIcon icon= new ImageIcon ( "src\\image\\bullet.png" ) ;
public Bullet ( int x, int y) {
this . x = x;
this . y = y;
this . width = icon. getIconWidth ( ) ;
this . height = icon. getIconHeight ( ) ;
}
public int getX ( ) {
return x;
}
public int getY ( ) {
return y;
}
public int getWidth ( ) {
return width;
}
public int getHeight ( ) {
return height;
}
public ImageIcon getIcon ( ) {
return icon;
}
public void move ( ) {
this . y-= 3 ;
}
}
public class Enemy {
private int x;
private int y;
private int width;
private int height;
private ImageIcon icon= new ImageIcon ( "src\\image\\enemy.png" ) ;
public Enemy ( int x, int y) {
this . x = x;
this . y = y;
this . width = icon. getIconWidth ( ) ;
this . height = icon. getIconHeight ( ) ;
}
public int getX ( ) {
return x;
}
public int getY ( ) {
return y;
}
public int getWidth ( ) {
return width;
}
public int getHeight ( ) {
return height;
}
public ImageIcon getIcon ( ) {
return icon;
}
public void move ( ) {
this . y+= 4 ;
}
}
public class HeroDestroy