diff -r cc4fc200da5770c721cb1beed043128fa679b83c -r e0b99058d10d1f07e5b6ef46647e075a9feb32cf axios_tennis/axios_tennis/Objects/Ball.cs --- a/axios_tennis/axios_tennis/Objects/Ball.cs Thu May 31 22:27:37 2012 -0500 +++ b/axios_tennis/axios_tennis/Objects/Ball.cs Thu May 31 22:57:40 2012 -0500 @@ -77,6 +77,7 @@ ConstantVelocity = new Vector2(7f, 7f); this.BodyPart.Position = Vector2.Zero; this.BodyPart.LinearVelocity = Vector2.Zero; + BodyPart.AngularVelocity = 0f; this.BodyPart.Inertia = 0f; } public override void HandleInput(AxiosGameScreen gameScreen, InputState input, GameTime gameTime) @@ -87,6 +88,7 @@ if (input.IsNewKeyPress(Keys.Space, PlayerIndex.One, out i) || input.IsNewVirtualButtonPress(Buttons.A) || input.IsNewButtonPress(Buttons.A, PlayerIndex.One, out i)) { KickBall(); + ((TennisScreen)gameScreen).Play = true; } if (input.IsNewVirtualButtonPress(Buttons.B) || input.IsNewButtonPress(Buttons.B, PlayerIndex.One, out i)) diff -r cc4fc200da5770c721cb1beed043128fa679b83c -r e0b99058d10d1f07e5b6ef46647e075a9feb32cf axios_tennis/axios_tennis/TennisScreen.cs --- a/axios_tennis/axios_tennis/TennisScreen.cs Thu May 31 22:27:37 2012 -0500 +++ b/axios_tennis/axios_tennis/TennisScreen.cs Thu May 31 22:57:40 2012 -0500 @@ -2,7 +2,7 @@ using FarseerPhysics.SamplesFramework; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Axios.Engine.Extenions; +using Axios.Engine.Extensions; using Axios.Engine.UI; using Axios; using System; @@ -12,7 +12,37 @@ namespace axios_tennis { + class GameConsole : AxiosCommandConsole + { + public GameConsole(AxiosGameScreen gameScreen) + : base(gameScreen) + { + } + + public override void InitializeCustomCommands() + { + base.InitializeCustomCommands(); + + CmdObject reset = new CmdObject(); + reset.Command = "reset"; + reset.CommandHelp = "Resets the game"; + reset.CommandHelpDetailed = "reset"; + reset.CmdEvent += new Action(reset_CmdEvent); + AddCommand(reset); + } + + void reset_CmdEvent(string[] obj) + { + ((TennisScreen)GameScreen).ResetGame(); + } + + protected override void LoadContent() + { + LoadDefault(); + base.LoadContent(); + } + } class TennisScreen : AxiosGameScreen { private Ball _ball; @@ -23,9 +53,20 @@ private Wall _ewall; private int _pscore = 0; private int _escore = 0; + public bool Play = false; private SpriteFont _sf; + public void ResetGame() + { + _ball.ResetBall(); + _pscore = 0; + _escore = 0; + _epaddle.BodyPart.Position = Vector2.Zero; + _epaddle.PaddleJoint.MotorSpeed = 0f; + Play = false; + + } public TennisScreen() { @@ -75,6 +116,7 @@ AddGameObject(_ppaddle); AddGameObject(_border); AddGameObject(_ball); + AddGameObject(new GameConsole(this)); } void b_MouseDown(object sender, AxiosGameScreen gameScreen, InputState input) @@ -87,30 +129,36 @@ public override void HandleInput(GameTime gameTime, InputState input) { - base.HandleInput(gameTime, input); - - //This must be handled in the screen because there are multiple paddles - - if (_ppaddle != null) +#if WINDOWS + if (Console == null || !AxiosCommandConsole.Active || (AllowKeyboardWhileConsoleIsActive && AxiosCommandConsole.Active)) +#endif { - if (input.VirtualState.ThumbSticks.Left.Y > 0 || - input.CurrentGamePadStates[0].ThumbSticks.Left.Y > 0 || - input.CurrentKeyboardStates[0].IsKeyDown(Keys.Down) - ) + base.HandleInput(gameTime, input); + + + //This must be handled in the screen because there are multiple paddles + + if (_ppaddle != null) { - _ppaddle.PaddleJoint.MotorSpeed = -40f; - } - else if (input.VirtualState.ThumbSticks.Left.Y < 0 || - input.CurrentGamePadStates[0].ThumbSticks.Left.Y < 0 || - input.CurrentKeyboardStates[0].IsKeyDown(Keys.Up) - ) - { - _ppaddle.PaddleJoint.MotorSpeed = 40f; - } - else - { - _ppaddle.PaddleJoint.MotorSpeed = 0f; + if (input.VirtualState.ThumbSticks.Left.Y > 0 || + input.CurrentGamePadStates[0].ThumbSticks.Left.Y > 0 || + input.CurrentKeyboardStates[0].IsKeyDown(Keys.Up) + ) + { + _ppaddle.PaddleJoint.MotorSpeed = -40f; + } + else if (input.VirtualState.ThumbSticks.Left.Y < 0 || + input.CurrentGamePadStates[0].ThumbSticks.Left.Y < 0 || + input.CurrentKeyboardStates[0].IsKeyDown(Keys.Down) + ) + { + _ppaddle.PaddleJoint.MotorSpeed = 40f; + } + else + { + _ppaddle.PaddleJoint.MotorSpeed = 0f; + } } } } @@ -147,10 +195,11 @@ { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); - if (_epaddle.BodyPart.Position.Y < _ball.BodyPart.Position.Y && _epaddle.PaddleJoint.MotorSpeed != 40f) - _epaddle.PaddleJoint.MotorSpeed += 5f; - else if (_epaddle.BodyPart.Position.Y > _ball.BodyPart.Position.Y && _epaddle.PaddleJoint.MotorSpeed != -40f) - _epaddle.PaddleJoint.MotorSpeed -= 5f; + if (Play) + if (_epaddle.BodyPart.Position.Y < _ball.BodyPart.Position.Y && _epaddle.PaddleJoint.MotorSpeed != 40f) + _epaddle.PaddleJoint.MotorSpeed += 5f; + else if (_epaddle.BodyPart.Position.Y > _ball.BodyPart.Position.Y && _epaddle.PaddleJoint.MotorSpeed != -40f) + _epaddle.PaddleJoint.MotorSpeed -= 5f; /*else if (_epaddle.PaddleJoint.MotorSpeed == 40f) _epaddle.PaddleJoint.MotorSpeed -= 1f; diff -r cc4fc200da5770c721cb1beed043128fa679b83c -r e0b99058d10d1f07e5b6ef46647e075a9feb32cf axios_tennis/axios_tennisContent/Console.spritefont --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/axios_tennis/axios_tennisContent/Console.spritefont Thu May 31 22:57:40 2012 -0500 @@ -0,0 +1,60 @@ + + + + + + + Segoe UI Mono + + + 14 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + diff -r cc4fc200da5770c721cb1beed043128fa679b83c -r e0b99058d10d1f07e5b6ef46647e075a9feb32cf axios_tennis/axios_tennisContent/axios_tennisContent.contentproj --- a/axios_tennis/axios_tennisContent/axios_tennisContent.contentproj Thu May 31 22:27:37 2012 -0500 +++ b/axios_tennis/axios_tennisContent/axios_tennisContent.contentproj Thu May 31 22:57:40 2012 -0500 @@ -196,6 +196,13 @@ TextureProcessor + + + Console + FontDescriptionImporter + FontDescriptionProcessor + +