Skip to content

Commit

Permalink
Add packing percentage to infopanel and 'P' key to toggle packing per…
Browse files Browse the repository at this point in the history
…centage
  • Loading branch information
DaigneaultPearce committed Apr 2, 2018
1 parent d48a9b6 commit 617a97b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
17 changes: 9 additions & 8 deletions Game/Pack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,22 @@ public Pack(Stage theStage, string label, string meshFile, int nDogs, int xPos,
/// Supports leaderless and leader based "flocking"
/// </summary>
public override void Update(GameTime gameTime) {
// if (leader == null) need to determine "virtual leader from members"
float angle = 0.3f;
foreach (Object3D obj in instance) {
//Original implementation
// if (leader == null) need to determine "virtual leader from members"
float angle = 0.3f;
foreach (Object3D obj in instance) {
obj.Yaw = 0.0f;
// change direction 4 time a second 0.07 = 4/60
if ( random.NextDouble() < 0.07) {
if (random.NextDouble() < 0.5) obj.Yaw -= angle; // turn left
else obj.Yaw += angle; // turn right
}
if ( random.NextDouble() < 0.07) {
if (random.NextDouble() < 0.5) obj.Yaw -= angle; // turn left
else obj.Yaw += angle; // turn right
}
obj.updateMovableObject();
stage.setSurfaceHeight(obj);
}
base.Update(gameTime); // MovableMesh's Update();
}

//end of original implementation

public Object3D Leader {
get { return leader; }
Expand Down
21 changes: 18 additions & 3 deletions Game/Stage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public class Stage : Game {
// Custom Sage additions
private bool lerpToggle = true;//start with lerp enable

private int[] packing = new int[4] { 0, 33, 66, 99 };//add packing array corresponding to percent packing
private int percentPacking = 0;//index to choose which percent

// Number of treasures on this map
private int nTreasures = 4;

Expand Down Expand Up @@ -532,9 +535,12 @@ public class Stage : Game {
// moved from timer to reflect real-time gameplay
inspector.setInfo(11, agentLocation(player));
inspector.setInfo(12, agentLocation(npAgent));

// Process user keyboard events that relate to the render state of the the stage
KeyboardState keyboardState = Keyboard.GetState();

//percentage of packing display: DLP
inspector.setInfo(13, "Percentage packing: " + packing[percentPacking] + "%");

// Process user keyboard events that relate to the render state of the the stage
KeyboardState keyboardState = Keyboard.GetState();
if (keyboardState.IsKeyDown(Keys.Escape))
Exit();
else if (keyboardState.IsKeyDown(Keys.B) && !oldKeyboardState.IsKeyDown(Keys.B))
Expand All @@ -560,6 +566,15 @@ public class Stage : Game {
//crank up the lerp
else if (keyboardState.IsKeyDown(Keys.L) && !oldKeyboardState.IsKeyDown(Keys.L)) {
lerpToggle = !lerpToggle;
}
//cycle flocking percentages
else if (keyboardState.IsKeyDown(Keys.P) && !oldKeyboardState.IsKeyDown(Keys.P))
{
if (percentPacking == 3)//wrap index
percentPacking = 0;
else
percentPacking++;//increment pack percentage

}
// toggle update speed between FixedStep and ! FixedStep
else if (keyboardState.IsKeyDown(Keys.T) && !oldKeyboardState.IsKeyDown(Keys.T))
Expand Down

0 comments on commit 617a97b

Please sign in to comment.