/** * Draws the widget. * * @param g The object that draws things. */ public void draw(Graphics2D screen) { // Animate! if (System.nanoTime() - timestamp >= CENTISECOND * 50) { timestamp = System.nanoTime(); if (image == frames.get(0)) { image = frames.get(1); } else { image = frames.get(0); } } ROVector2f position = body.getPosition(); float angle = body.getRotation(); boolean hflip = false; boolean vflip = false; if (currentDirection == Direction.WEST) { hflip = false; } else if (currentDirection == Direction.EAST) { hflip = true; } else if (currentDirection == Direction.NORTH) { angle += Math.PI / 2; vflip = false; } else if (currentDirection == Direction.SOUTH) { angle += Math.PI / 2; vflip = true; } drawImage( position.getX(), position.getY(), getWidth(), getHeight(), angle, hflip, vflip, image, screen); }
/** * Get the position of the widget. * * @return The x,y coordinates within the container. */ public Vector2f getPosition() { return new Vector2f(body.getPosition()); }