package lab; import javafx.animation.AnimationTimer; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; public class DrawingThread extends AnimationTimer { private final Canvas canvas; private final GraphicsContext gc; private Level level; private long lastTime; public DrawingThread(Canvas canvas) { this.canvas = canvas; this.gc = canvas.getGraphicsContext2D(); this.level = new Level(canvas.getWidth(), canvas.getHeight()); lastTime = System.nanoTime(); } /** * Draws objects into the canvas. Put you code here. */ @Override public void handle(long now) { level.draw(gc); level.simulate(now - lastTime); lastTime = now; } }