package lab; import javafx.geometry.Point2D; import javafx.scene.canvas.GraphicsContext; import javafx.scene.image.Image; public class Dragon { private static final int SIZE_OF_DRAGON = 50; private final World world; private Point2D position; private final Point2D velocity; private final Point2D dimension; private final Image image; public Dragon(World world, Point2D position, Point2D velocity) { this(world, position, velocity, new Point2D(SIZE_OF_DRAGON, SIZE_OF_DRAGON)); } public Dragon(World world, Point2D position, Point2D velocity, Point2D dimension) { this.world = world; this.position = position; this.velocity = velocity; this.dimension = dimension; this.image = Constants.DRAGON_IMAGE; } public void draw(GraphicsContext gc) { Point2D p = world.getCanvasPoint(position); gc.drawImage(image, p.getX(), p.getY(), dimension.getX(), dimension.getY()); } public void simulate(double deltaT) { position = position.add(velocity.multiply(deltaT)); } }