Skip to content
Snippets Groups Projects
Verified Commit beea69a8 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

Fix speed

parent 03979e13
No related merge requests found
...@@ -5,7 +5,7 @@ import javafx.geometry.Rectangle2D; ...@@ -5,7 +5,7 @@ import javafx.geometry.Rectangle2D;
import javafx.scene.canvas.GraphicsContext; import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image; import javafx.scene.image.Image;
public class BulletAnimated { public class BulletAnimated {
private Point2D position; private Point2D position;
private Point2D start; private Point2D start;
...@@ -13,7 +13,7 @@ public class BulletAnimated { ...@@ -13,7 +13,7 @@ public class BulletAnimated {
private Point2D initialSpeed; private Point2D initialSpeed;
private double size; private double size;
private double mass = 2; private double mass = 2;
private double strenghtOfCannon = .1; private double strenghtOfCannon = 2;
private double cannonLength = 100; private double cannonLength = 100;
private boolean accelerate = true; private boolean accelerate = true;
private boolean hitToGround = false; private boolean hitToGround = false;
...@@ -54,7 +54,7 @@ public class BulletAnimated { ...@@ -54,7 +54,7 @@ public class BulletAnimated {
double cannonAngle = cannon.getAngle(); double cannonAngle = cannon.getAngle();
speed = speed speed = speed
.add(new Point2D(Math.cos(cannonAngle) * strenghtOfCannon, Math.sin(cannonAngle) * strenghtOfCannon) .add(new Point2D(Math.cos(cannonAngle) * strenghtOfCannon, Math.sin(cannonAngle) * strenghtOfCannon)
.multiply(1 / mass).multiply(timeStep)); .multiply(1 / mass));
} else if (!hitToGround) { } else if (!hitToGround) {
accelerate = false; accelerate = false;
Point2D airResistanceforce = new Point2D( Point2D airResistanceforce = new Point2D(
...@@ -85,6 +85,7 @@ public class BulletAnimated { ...@@ -85,6 +85,7 @@ public class BulletAnimated {
return getBoundingBox().intersects(dragon.getBoundingBox()); return getBoundingBox().intersects(dragon.getBoundingBox());
} }
public void reload() { public void reload() {
position = start; position = start;
speed = initialSpeed; speed = initialSpeed;
......
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