Skip to content
Snippets Groups Projects
Commit 09073852 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

clamed speed to prevent ship from accerlating infinately

parent 51911457
No related branches found
No related tags found
No related merge requests found
......@@ -25,9 +25,10 @@ public class NeuroShip extends GameObject {
// define how quickly the ship will rotate
static double steerStep = 10 * Math.PI / 180;
static double maxSpeed = 3;
// this is the friction that makes the ship slow down over time
static double loss = 0.995;
static double loss = 0.99;
double releaseVelocity = 0;
double minVelocity = 2;
......@@ -109,8 +110,15 @@ public class NeuroShip extends GameObject {
v.y += gravity;
// v.x = 0.5;
v.mul(loss);
// This is fairly basic, but it'll do for now...
v.x = clamp(v.x, -maxSpeed, maxSpeed);
v.y = clamp(v.y, -maxSpeed, maxSpeed);
s.add(v);
System.out.println(v);
return this;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment