Taking out hard coded debug statements
Adding field to allow/disallow automated mouse joints
This commit is contained in:
parent
4755ff6b87
commit
0c2172e2b2
@ -18,6 +18,13 @@ namespace Axios.Engine
|
|||||||
public bool ApplyConstantVelocity = false;
|
public bool ApplyConstantVelocity = false;
|
||||||
public Vector2 ConstantVelocity;
|
public Vector2 ConstantVelocity;
|
||||||
|
|
||||||
|
private bool _allowmousejoint = false;
|
||||||
|
public bool AllowAutomaticMouseJoint
|
||||||
|
{
|
||||||
|
get { return _allowmousejoint; }
|
||||||
|
set { _allowmousejoint = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public SimpleAxiosGameObject()
|
public SimpleAxiosGameObject()
|
||||||
{
|
{
|
||||||
AxiosLog.Instance.AddLine("[Axios Engine] - Creating SimpleAxiosGameObject " + Name, LoggingFlag.DEBUG);
|
AxiosLog.Instance.AddLine("[Axios Engine] - Creating SimpleAxiosGameObject " + Name, LoggingFlag.DEBUG);
|
||||||
|
@ -6,6 +6,7 @@ using FarseerPhysics.Dynamics.Joints;
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
using Axios.Engine;
|
||||||
|
|
||||||
namespace FarseerPhysics.SamplesFramework
|
namespace FarseerPhysics.SamplesFramework
|
||||||
{
|
{
|
||||||
@ -17,17 +18,20 @@ namespace FarseerPhysics.SamplesFramework
|
|||||||
|
|
||||||
private float _agentForce;
|
private float _agentForce;
|
||||||
private float _agentTorque;
|
private float _agentTorque;
|
||||||
#if DEBUG
|
|
||||||
private FixedMouseJoint _fixedMouseJoint;
|
private FixedMouseJoint _fixedMouseJoint;
|
||||||
#endif
|
|
||||||
private Body _userAgent;
|
private Body _userAgent;
|
||||||
|
|
||||||
protected PhysicsGameScreen()
|
protected PhysicsGameScreen()
|
||||||
{
|
{
|
||||||
TransitionOnTime = TimeSpan.FromSeconds(0.75);
|
TransitionOnTime = TimeSpan.FromSeconds(0.75);
|
||||||
TransitionOffTime = TimeSpan.FromSeconds(0.75);
|
TransitionOffTime = TimeSpan.FromSeconds(0.75);
|
||||||
HasCursor = true;
|
#if DEBUG
|
||||||
EnableCameraControl = true;
|
EnableCameraControl = true;
|
||||||
|
HasCursor = true;
|
||||||
|
#else
|
||||||
|
EnableCameraControl = false;
|
||||||
|
HasCursor = false;
|
||||||
|
#endif
|
||||||
_userAgent = null;
|
_userAgent = null;
|
||||||
World = null;
|
World = null;
|
||||||
Camera = null;
|
Camera = null;
|
||||||
@ -157,21 +161,7 @@ namespace FarseerPhysics.SamplesFramework
|
|||||||
EnableOrDisableFlag(DebugViewFlags.AABB);
|
EnableOrDisableFlag(DebugViewFlags.AABB);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsNewButtonPress(Buttons.Back) || input.IsNewKeyPress(Keys.Escape))
|
#endif
|
||||||
{
|
|
||||||
if (this.ScreenState == SamplesFramework.ScreenState.Active && this.TransitionPosition == 0 && this.TransitionAlpha == 1)
|
|
||||||
{ //Give the screens a chance to transition
|
|
||||||
|
|
||||||
CleanUp();
|
|
||||||
ExitScreen();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HasCursor)
|
|
||||||
{
|
|
||||||
HandleCursor(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_userAgent != null)
|
if (_userAgent != null)
|
||||||
{
|
{
|
||||||
@ -182,14 +172,28 @@ namespace FarseerPhysics.SamplesFramework
|
|||||||
{
|
{
|
||||||
HandleCamera(input, gameTime);
|
HandleCamera(input, gameTime);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
if (HasCursor)
|
||||||
|
{
|
||||||
|
HandleCursor(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input.IsNewButtonPress(Buttons.Back) || input.IsNewKeyPress(Keys.Escape))
|
||||||
|
{
|
||||||
|
if (this.ScreenState == SamplesFramework.ScreenState.Active && this.TransitionPosition == 0 && this.TransitionAlpha == 1)
|
||||||
|
{ //Give the screens a chance to transition
|
||||||
|
|
||||||
|
CleanUp();
|
||||||
|
ExitScreen();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
base.HandleInput(input, gameTime);
|
base.HandleInput(input, gameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void HandleCursor(InputHelper input)
|
public virtual void HandleCursor(InputHelper input)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
|
||||||
Vector2 position = Camera.ConvertScreenToWorld(input.Cursor);
|
Vector2 position = Camera.ConvertScreenToWorld(input.Cursor);
|
||||||
|
|
||||||
if ((input.IsNewButtonPress(Buttons.A) ||
|
if ((input.IsNewButtonPress(Buttons.A) ||
|
||||||
@ -197,7 +201,7 @@ namespace FarseerPhysics.SamplesFramework
|
|||||||
_fixedMouseJoint == null)
|
_fixedMouseJoint == null)
|
||||||
{
|
{
|
||||||
Fixture savedFixture = World.TestPoint(position);
|
Fixture savedFixture = World.TestPoint(position);
|
||||||
if (savedFixture != null)
|
if (savedFixture != null && savedFixture.UserData is SimpleAxiosGameObject && ((SimpleAxiosGameObject)(savedFixture.UserData)).AllowAutomaticMouseJoint)
|
||||||
{
|
{
|
||||||
Body body = savedFixture.Body;
|
Body body = savedFixture.Body;
|
||||||
_fixedMouseJoint = new FixedMouseJoint(body, position);
|
_fixedMouseJoint = new FixedMouseJoint(body, position);
|
||||||
@ -219,14 +223,14 @@ namespace FarseerPhysics.SamplesFramework
|
|||||||
{
|
{
|
||||||
_fixedMouseJoint.WorldAnchorB = position;
|
_fixedMouseJoint.WorldAnchorB = position;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleCamera(InputHelper input, GameTime gameTime)
|
private void HandleCamera(InputHelper input, GameTime gameTime)
|
||||||
{
|
{
|
||||||
Vector2 camMove = Vector2.Zero;
|
Vector2 camMove = Vector2.Zero;
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
if (input.KeyboardState.IsKeyDown(Keys.Up))
|
if (input.KeyboardState.IsKeyDown(Keys.Up))
|
||||||
{
|
{
|
||||||
camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||||
@ -259,12 +263,12 @@ namespace FarseerPhysics.SamplesFramework
|
|||||||
{
|
{
|
||||||
Camera.ResetCamera();
|
Camera.ResetCamera();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleUserAgent(InputHelper input)
|
private void HandleUserAgent(InputHelper input)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
|
||||||
Vector2 force = _agentForce * new Vector2(input.GamePadState.ThumbSticks.Right.X,
|
Vector2 force = _agentForce * new Vector2(input.GamePadState.ThumbSticks.Right.X,
|
||||||
-input.GamePadState.ThumbSticks.Right.Y);
|
-input.GamePadState.ThumbSticks.Right.Y);
|
||||||
float torque = _agentTorque * (input.GamePadState.Triggers.Right - input.GamePadState.Triggers.Left);
|
float torque = _agentTorque * (input.GamePadState.Triggers.Right - input.GamePadState.Triggers.Left);
|
||||||
@ -304,7 +308,7 @@ namespace FarseerPhysics.SamplesFramework
|
|||||||
|
|
||||||
_userAgent.ApplyForce(force);
|
_userAgent.ApplyForce(force);
|
||||||
_userAgent.ApplyTorque(torque);
|
_userAgent.ApplyTorque(torque);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnableOrDisableFlag(DebugViewFlags flag)
|
private void EnableOrDisableFlag(DebugViewFlags flag)
|
||||||
|
Loading…
Reference in New Issue
Block a user