Skip to content

Commit

Permalink
Enter now Pauses the simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
pampersrocker committed Feb 7, 2017
1 parent 3ce7043 commit 1392655
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
9 changes: 6 additions & 3 deletions EvoNet/Controls/EvoSimControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,13 @@ protected override void Update(GameTime gameTime)

foreach (var module in modules)
{
module.NotifyTick((float)gameTime.ElapsedGameTime.TotalSeconds);
if (!inputManager.Paused || !module.WantsFastForward)
{
module.NotifyTick((float)gameTime.ElapsedGameTime.TotalSeconds);
}
}

if (inputManager.EnableFastForward)
if (!inputManager.Paused && inputManager.EnableFastForward)
{
DateTime startFastForward = DateTime.UtcNow;
double clampedElapsedTime = Math.Min(gameTime.ElapsedGameTime.TotalSeconds, 0.033);
Expand Down
3 changes: 0 additions & 3 deletions EvoNet/EvoNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@
<StartupObject>EvoNet.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Build.Engine, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
Expand Down
10 changes: 10 additions & 0 deletions EvoNet/Input/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class InputManager : UpdateModule

bool rightMouseDown = false;
bool oldSpaceDown = false;
bool oldEnterDown = false;
Vector2 oldMousePosition = Vector2.Zero;
int scrollWheelValue;

Expand All @@ -25,6 +26,7 @@ public class InputManager : UpdateModule
SimulationRenderer renderer;

public bool EnableFastForward { get; private set; }
public bool Paused { get; private set; }

public override bool WantsFastForward
{
Expand Down Expand Up @@ -76,6 +78,13 @@ protected override void Update(float gameTime)
EnableFastForward = !EnableFastForward;
}

bool enterDown = keyboardState.IsKeyDown(Keys.Enter);

if (!oldEnterDown && enterDown)
{
Paused = !Paused;
}

if (keyboardState.IsKeyDown(Keys.R))
{
float viewportWidth = renderer.GraphicsDevice.Viewport.Width;
Expand All @@ -88,6 +97,7 @@ protected override void Update(float gameTime)
}

oldSpaceDown = spaceDown;
oldEnterDown = enterDown;
scrollWheelValue = mouseState.ScrollWheelValue;

oldMousePosition = new Vector2(mouseState.X, mouseState.Y);
Expand Down

0 comments on commit 1392655

Please sign in to comment.