An error occurred while loading the file. Please try again.
-
koz01 authored5ee57b7e
World.java 1.08 KiB
package lab;
import javafx.geometry.Point2D;
import javafx.scene.canvas.GraphicsContext;
public class World {
private double width;
private double height;
private BulletAnimated bulletAnimatted;
private Cannon cannon;
private Dragon dragon;
public World(double width, double height) {
this.width = width;
this.height = height;
cannon = new Cannon(this, new Point2D(50, 50), new Point2D(100, 20));
bulletAnimatted = new BulletAnimated(this, cannon, new Point2D(30, 60), new Point2D(0, 0), 40);
dragon = new Dragon(this, new Point2D(100, 100), new Point2D(40, 40));
}
public Point2D getCanvasPoint(Point2D worldPoint) {
return new Point2D(worldPoint.getX(), height - worldPoint.getY());
}
public void draw(GraphicsContext gc) {
gc.clearRect(0, 0, width, height);
cannon.draw(gc);
bulletAnimatted.draw(gc);
dragon.draw(gc);
}
public void simulate(double timeDelta) {
bulletAnimatted.simulate(timeDelta);
cannon.simulate(timeDelta);
dragon.simulate(timeDelta);
}
public double getWidth() {
return width;
}
public double getHeight() {
return height;
}
}