public void render(Graphics2D g) { for (int i = 0; i < TeamObjects.size() && i != findSelected(); i++) TeamObjects.get(i).render(g); if (findSelected() != -1) { for (MovingObject O : TeamObjects) O.render(g); TeamObjects.get(findSelected()).render(g); } }
private boolean isMoved() { boolean somebody_moved = false; for (MovingObject O : TeamObjects) { if (O.is_moved) { O.is_moved = false; somebody_moved = true; } } return somebody_moved; }
@Override public void updateState() { // Update movement if (moveLeft) { setX((int) (getX() - (getVx() * getDirectionX()))); } if (moveRight) { setX((int) (getX() + (getVx() * getDirectionX()))); } if (moveUp) { setY((int) (getY() - (getVy() * getDirectionY()))); } if (moveDown) { setY((int) (getY() + (getVy() * getDirectionY()))); } // Spaceship is hit if (hit) { setAnimationPointer(1); counter = 0; hit = false; } if (getAnimationPointer() == 1) { if (counter == 2) { setAnimationPointer(0); } else { counter++; } } // Calls the superclass method that updates the rectangle automatically. super.updateState(); }
@Override public void draw(Canvas canvas) { super.draw(canvas); }