From ba626e1a54e949b209e2f5c997351487f591bc60 Mon Sep 17 00:00:00 2001
From: koz01 <koz01@PCFEIB213-100.msad.vsb.cz>
Date: Wed, 12 Oct 2022 09:14:12 +0200
Subject: [PATCH] Fixed speed of cannon and bullet

---
 src/main/java/lab/BulletAnimated.java | 4 ++--
 src/main/java/lab/Cannon.java         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/lab/BulletAnimated.java b/src/main/java/lab/BulletAnimated.java
index 4ec882b..d98b7f0 100644
--- a/src/main/java/lab/BulletAnimated.java
+++ b/src/main/java/lab/BulletAnimated.java
@@ -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) {
diff --git a/src/main/java/lab/Cannon.java b/src/main/java/lab/Cannon.java
index 92c5431..f62ad47 100644
--- a/src/main/java/lab/Cannon.java
+++ b/src/main/java/lab/Cannon.java
@@ -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;
 		}
-- 
GitLab