示例#1
0
  public void run() {

    while (bKeepGoing) {

      ArrayList<Sprite> sprites = controller.getModel().getSpriteList();

      synchronized (sprites) {
        Iterator<Sprite> iter = sprites.iterator();
        while (iter.hasNext()) {
          Sprite s = iter.next();
          s.move();
          for (Sprite t : sprites) {
            if ((s instanceof Razorback) && (t instanceof Opponent) && t.overlaps(s)) {
              t.hit();
            } else if ((t instanceof Razorback) && (s instanceof Opponent) && s.overlaps(t)) {
              s.hit();
            }
          }

          if (s.shouldRemove()) {
            iter.remove();
          }
        }
      }

      try {
        Thread.sleep(25);
      } catch (InterruptedException e) {
      }
      view.repaint();
    }
  }
示例#2
0
 public void actionPerformed(ActionEvent e) {
   compute();
   player.move();
   repaint();
 }
示例#3
0
 public void move(int m, int n) {
   if (this.getMovable()) {
     super.move(m, n);
   }
 }