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

fix movement equation

parent 77a6e259
Branches
No related merge requests found
......@@ -7,7 +7,7 @@ import javafx.scene.image.Image;
public class BulletAnimated implements DrawableSimulable, Collisionable{
private static final double STRENGTH_CANNON_COEFICIENT = 4.;
private static final double STRENGTH_CANNON_COEFICIENT = 1.;
private Point2D position;
private Point2D start;
......@@ -58,7 +58,7 @@ public class BulletAnimated implements DrawableSimulable, Collisionable{
}
if (accelerate && start.distance(position) < cannonLength) {
double cannonAngle = cannon.getAngle();
double strenghtOfCannon = cannon.getStrength() * STRENGTH_CANNON_COEFICIENT/100.;
double strenghtOfCannon = cannon.getStrength() * STRENGTH_CANNON_COEFICIENT;
speed = speed
.add(new Point2D(Math.cos(cannonAngle) * strenghtOfCannon, Math.sin(cannonAngle) * strenghtOfCannon)
.multiply(deltaT / mass));
......@@ -68,11 +68,11 @@ public class BulletAnimated implements DrawableSimulable, Collisionable{
-1. / 2 * crossSectionalArea * Constants.AIR_DENSITY * dragCoefficient * Math.pow(speed.getX(), 2),
-1. / 2 * crossSectionalArea * Constants.AIR_DENSITY * 0.47 * Math.pow(speed.getY(), 2));
Point2D acceleration = new Point2D(-airResistanceforce.getX() * mass,
(-Constants.GRAVITATIONAL_ACCELERATION/30 + airResistanceforce.getY()) * mass);
(-Constants.GRAVITATIONAL_ACCELERATION + airResistanceforce.getY()) * mass);
speed = speed.add(acceleration.multiply(deltaT));
}
if (!hitToGround) {
position = position.add(speed.multiply(deltaT*1000));
position = position.add(speed.multiply(deltaT*100));
if (!accelerate && position.getY() <= size / 2) {
hitToGround = true;
position = new Point2D(position.getX(), size / 2);
......@@ -84,7 +84,7 @@ public class BulletAnimated implements DrawableSimulable, Collisionable{
}
public Rectangle2D getBoundingBox() {
return new Rectangle2D(position.getX(), position.getY(), size, size);
return new Rectangle2D(position.getX() - size, position.getY(), size, size);
}
public boolean overlaps(Dragon dragon) {
......
......@@ -37,7 +37,7 @@ public class Dragon implements DrawableSimulable, Collisionable{
public Rectangle2D getBoundingBox() {
return new Rectangle2D(position.getX(), position.getY(), size, size);
return new Rectangle2D(position.getX() - size, position.getY(), size, size);
}
......
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