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

Fixed speed of cannon and bullet

parent 555cdf03
No related merge requests found
......@@ -49,10 +49,10 @@ public class BulletAnimated {
double cannonAngle = cannon.getAngle();
speed = speed
.add(new Point2D(Math.cos(cannonAngle) * strenghtOfCannon, Math.sin(cannonAngle) * strenghtOfCannon)
.multiply(1 / mass));
.multiply(1 / mass * timeStep * 10));
} else if (!hitToGround) {
accelerate = false;
Point2D acceleration = new Point2D(0, -Constants.GRAVITATIONAL_ACCELERATION*50 * mass);
Point2D acceleration = new Point2D(0, -Constants.GRAVITATIONAL_ACCELERATION*50 * mass * timeStep * 10);
speed = speed.add(acceleration.multiply(timeStep));
}
if (!hitToGround) {
......
......@@ -13,7 +13,7 @@ public class Cannon {
private Point2D size;
private World world;
private final double speed = 20;
public Cannon(World world, Point2D position, Point2D size) {
......@@ -24,7 +24,7 @@ public class Cannon {
}
public void simulate(double timeStep) {
angle = angle + direction*0.8;
angle = angle + direction*speed*timeStep;
if(angle <=-90 || angle >= 0) {
direction*=-1;
}
......
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