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(); } }
public void actionPerformed(ActionEvent e) { compute(); player.move(); repaint(); }
public void move(int m, int n) { if (this.getMovable()) { super.move(m, n); } }