Skip to content
Snippets Groups Projects
Commit 56cfbbe2 authored by koz01's avatar koz01
Browse files

Initialize force and angle base on sliders.

parent 076cd319
No related merge requests found
package lab;
import javafx.animation.AnimationTimer;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.canvas.Canvas;
import javafx.scene.control.Slider;
......@@ -27,7 +25,9 @@ public class GameController {
public void startGame() {
this.world = new World(canvas.getWidth(), canvas.getHeight());
angleSlider.valueProperty().addListener( (val, oldValue, newValue) -> world.setAngle(newValue.doubleValue()));
world.setAngle(angleSlider.getValue());
forceSlider.valueProperty().addListener( (val, oldValue, newValue) -> world.setForce(newValue.doubleValue()));
world.setForce(forceSlider.getValue());
//Draw scene on a separate thread to avoid blocking UI.
animationTimer = new DrawingThread(canvas, world);
animationTimer.start();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment