Skip to content
Snippets Groups Projects
Commit cbe4001d authored by Sean Islas's avatar Sean Islas
Browse files

Update to Assignment 3 - Islas

parent dddd35c1
No related branches found
No related tags found
No related merge requests found
......@@ -236,20 +236,23 @@ public class ExampleSimulationProgram
Double dMinusP_X = entityStatePdu_2.getEntityLocation().getX() - entityStatePdu_1.getEntityLocation().getX();
Double dMinusP_Z = entityStatePdu_2.getEntityLocation().getZ() - entityStatePdu_1.getEntityLocation().getZ();
Double magnitudeDMinusP = Math.sqrt(dMinusP_X * dMinusP_X + dMinusP_Z * dMinusP_Z);
Double speed = 77.2; // Average speed of CH53 - meters per second
// Final velocity values
Double velocityX = dMinusP_X * speed / magnitudeDMinusP;
Double velocityZ = dMinusP_Z * speed / magnitudeDMinusP;
// Moves Entity 1 towards Entity 2
entityStatePdu_1.getEntityLocation().setX(entityStatePdu_1.getEntityLocation().getX() + velocityX);
entityStatePdu_1.getEntityLocation().setZ(entityStatePdu_1.getEntityLocation().getZ() + velocityZ);
// decide whether to fire, and then update the firePdu. Hmmm, you might want a target to shoot at!
// Calculates the total distance between the two Entities
double magnitudeX = entityStatePdu_2.getEntityLocation().getX() - entityStatePdu_1.getEntityLocation().getX();
double magnitudeY = entityStatePdu_2.getEntityLocation().getY() - entityStatePdu_1.getEntityLocation().getY();
double magnitudeZ = entityStatePdu_2.getEntityLocation().getZ() - entityStatePdu_1.getEntityLocation().getZ();
double magnitude = Math.sqrt(magnitudeX * magnitudeX + magnitudeY * magnitudeY + magnitudeZ * magnitudeZ);
// Shows an easy to identify log of Entity movement and a firing action
System.out.println("");
System.out.println(entityStatePdu_1.getEntityLocation());
if (magnitude < firePdu_1a.getRange()) {
......@@ -259,6 +262,7 @@ public class ExampleSimulationProgram
System.out.println("Fire at target");
}
System.out.println("");
// etc. etc. your code goes here for your simulation of interest
// something happens between my simulation entities, la de da de da...
......
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