-
Jan Kožusznik authoredVerified0a347143
GameController.java 657 B
package lab;
import javafx.animation.AnimationTimer;
import javafx.scene.canvas.Canvas;
public class GameController {
private World world;
private Canvas canvas;
private AnimationTimer animationTimer;
public GameController(Canvas canvas) {
this.canvas = canvas;
}
public void startGame() {
this.world = new World(canvas.getWidth(), canvas.getHeight());
//Draw scene on a separate thread to avoid blocking UI.
animationTimer = new DrawingThread(canvas, world);
animationTimer.start();
world.setCannonAngle(-45d);
world.setCannonPower(100.);
world.fireBullet();
}
public void stopGame() {
animationTimer.stop();
}
}