AxiosEngine-old 

AxiosEngine-old Commit Details


Date:2012-04-17 23:34:00 (12 years 8 months ago)
Author:nathan@daedalus
Branch:axios-newgsm
Commit:f000cc621ad9
Parents: 1373ec33131c
Message:Initial tests are looking good, cursor seems to be the only thing that doesn't work.

Tested with Axios Tennis and the new menu looks pretty slick.
Changes:
Maxios.suo
Maxios/Axios_WP7.csproj (2 diffs)
Maxios/Axios_Windows.csproj (2 diffs)
Maxios/Axios_Windows.csproj.user (1 diff)
Maxios/Axios_Xbox_360.csproj (2 diffs)
Maxios/Engine/AxiosGameScreen.cs (2 diffs)
Maxios/ScreenSystem/BackgroundScreen.cs (1 diff)
Maxios/ScreenSystem/GameScreen.cs (2 diffs)
Maxios/ScreenSystem/InputHelper.cs (2 diffs)
Maxios/ScreenSystem/InputState.cs (2 diffs)
Maxios/ScreenSystem/MenuEntry.cs (1 diff)
Maxios/ScreenSystem/MenuScreen.cs (2 diffs)
Maxios/ScreenSystem/PhysicsGameScreen.cs (7 diffs)
Maxios/ScreenSystem/PlayerIndexEventArgs.cs (1 diff)
Maxios/ScreenSystem/ScreenManager.cs (2 diffs)
Maxios/ScreenSystem/SpriteFonts.cs (1 diff)

File differences

axios/Axios_WP7.csproj
235235
236236
237237
238
238239
239240
240241
......
243244
244245
245246
246
247
247248
248249
249250
<Reference Include="System.Core" />
<Reference Include="system.data.linq, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e, processorArchitecture=MSIL" />
<Reference Include="System.Net" />
<Reference Include="System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, processorArchitecture=MSIL" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
<PropertyGroup>
<PostBuildEvent>if not exist "$(TargetPath)" ..\..\Combined mkdir "$(TargetPath)" ..\..\Combined
<PostBuildEvent>if not exist "$(TargetDir)"..\..\Combined mkdir "$(TargetDir)"..\..\Combined
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
</PropertyGroup>
<!--
axios/Axios_Windows.csproj
242242
243243
244244
245
246245
247246
248247
......
274273
275274
276275
277
276
278277
279278
280279
<Compile Include="ScreenSystem\GameScreen.cs" />
<Compile Include="ScreenSystem\IDemoScreen.cs" />
<Compile Include="ScreenSystem\InputAction.cs" />
<Compile Include="ScreenSystem\InputHelper.cs" />
<Compile Include="Engine\AxiosGameScreen.cs" />
<Compile Include="ScreenSystem\InputState.cs" />
<Compile Include="ScreenSystem\IScreenFactory.cs" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
<PropertyGroup>
<PostBuildEvent>if not exist "$(TargetPath)" ..\..\Combined mkdir "$(TargetPath)" ..\..\Combined
<PostBuildEvent>if not exist "$(TargeDir)"..\..\Combined mkdir "$(TargetDir)"..\..\Combined
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
</PropertyGroup>
<!--
axios/Axios_Windows.csproj.user
11
22
33
4
4
55
66
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>
axios/Axios_Xbox_360.csproj
191191
192192
193193
194
195194
196195
197196
......
238237
239238
240239
241
240
242241
243242
244243
<Compile Include="ScreenSystem\GameScreen.cs" />
<Compile Include="ScreenSystem\IDemoScreen.cs" />
<Compile Include="ScreenSystem\InputAction.cs" />
<Compile Include="ScreenSystem\InputHelper.cs" />
<Compile Include="ScreenSystem\InputState.cs" />
<Compile Include="ScreenSystem\IScreenFactory.cs" />
<Compile Include="ScreenSystem\LoadingScreen.cs" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
<PropertyGroup>
<PostBuildEvent>if not exist "$(TargetPath)" ..\..\Combined mkdir "$(TargetPath)" ..\..\Combined
<PostBuildEvent>if not exist "$(TargetDir)"..\..\Combined mkdir "$(TargetDir)"..\..\Combined
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
</PropertyGroup>
<!--
axios/Engine/AxiosGameScreen.cs
336336
337337
338338
339
339
340340
341341
342342
......
347347
348348
349349
350
350
351351
352352
353353
public override void HandleInput(GameTime gameTime, InputState input)
{
base.HandleInput(input, gameTime);
base.HandleInput(gameTime, input);
foreach (AxiosGameObject g in _gameObjects.ToList())
g.HandleInput(this, input, gameTime);
public override void Deactivate()
{
base.UnloadContent();
base.Deactivate();
//AxiosLog.Instance.AddLine("Memory usage before cleanup: " + GC.GetTotalMemory(true).ToString(), LoggingFlag.DEBUG);
foreach (AxiosGameObject g in _gameObjects)
g.UnloadContent(this);
axios/ScreenSystem/BackgroundScreen.cs
2222
2323
2424
25
25
2626
2727
2828
/// It draws a background image that remains fixed in place regardless
/// of whatever transitions the screens on top of it may be doing.
/// </summary>
class BackgroundScreen : GameScreen
public class BackgroundScreen : GameScreen
{
#region Fields
axios/ScreenSystem/GameScreen.cs
3535
3636
3737
38
39
40
41
42
43
3844
3945
4046
......
5056
5157
5258
53
59
5460
5561
5662
/// </summary>
public abstract class GameScreen
{
public GameScreen()
{
HasVirtualStick = false;
HasCursor = false;
}
protected bool HasCursor = false;
/// <summary>
/// Normally when one screen is brought up over the top of another,
}
bool isPopup = false;
public bool HasVirtualStick { get; set; }
/// <summary>
/// Indicates how long the screen takes to
axios/ScreenSystem/InputHelper.cs
11
22
3
34
45
56
7
68
79
8
10
911
1012
1113
......
147149
148150
149151
150
152
151153
152154
153
154
155
156
155157
156
158
157159
158160
159161
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using FarseerPhysics.SamplesFramework;
using GameStateManagement;
namespace FarseerPhysics.SamplesFramework
namespace FarseerPhysics.SamplesFramework2
{
/// <summary>
/// an enum of all available mouse buttons.
public void LoadContent()
{
_cursorSprite = new Sprite(_manager.Content.Load<Texture2D>("Common/cursor"));
_cursorSprite = new Sprite(_manager.Game.Content.Load<Texture2D>("Common/cursor"));
#if WINDOWS_PHONE
// virtual stick content
_phoneStick = new VirtualStick(_manager.Content.Load<Texture2D>("Common/socket"),
_manager.Content.Load<Texture2D>("Common/stick"), new Vector2(80f, 400f));
_phoneStick = new VirtualStick(_manager.Game.Content.Load<Texture2D>("Common/socket"),
_manager.Game.Content.Load<Texture2D>("Common/stick"), new Vector2(80f, 400f));
Texture2D temp = _manager.Content.Load<Texture2D>("Common/buttons");
Texture2D temp = _manager.Game.Content.Load<Texture2D>("Common/buttons");
_phoneA = new VirtualButton(temp, new Vector2(695f, 380f), new Rectangle(0, 0, 40, 40), new Rectangle(0, 40, 40, 40));
_phoneB = new VirtualButton(temp, new Vector2(745f, 360f), new Rectangle(40, 0, 40, 40), new Rectangle(40, 40, 40, 40));
#endif
axios/ScreenSystem/InputState.cs
432432
433433
434434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
435457
436458
437459
......
461483
462484
463485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
464508
465509
466510
}
}
public bool IsNewKeyRelease(Keys key, PlayerIndex? controllingPlayer, out PlayerIndex playerIndex)
{
if (controllingPlayer.HasValue)
{
// Read input from the specified player.
playerIndex = controllingPlayer.Value;
int i = (int)playerIndex;
return (CurrentKeyboardStates[i].IsKeyUp(key) &&
LastKeyboardStates[i].IsKeyDown(key));
}
else
{
// Accept input from any player.
return (IsNewKeyRelease(key, PlayerIndex.One, out playerIndex) ||
IsNewKeyRelease(key, PlayerIndex.Two, out playerIndex) ||
IsNewKeyRelease(key, PlayerIndex.Three, out playerIndex) ||
IsNewKeyRelease(key, PlayerIndex.Four, out playerIndex));
}
}
/// <summary>
/// Helper for checking if a button was newly pressed during this update.
}
}
public bool IsNewButtonRelease(Buttons button, PlayerIndex? controllingPlayer, out PlayerIndex playerIndex)
{
if (controllingPlayer.HasValue)
{
// Read input from the specified player.
playerIndex = controllingPlayer.Value;
int i = (int)playerIndex;
return (CurrentGamePadStates[i].IsButtonUp(button) &&
LastGamePadStates[i].IsButtonDown(button));
}
else
{
// Accept input from any player.
return (IsNewButtonRelease(button, PlayerIndex.One, out playerIndex) ||
IsNewButtonRelease(button, PlayerIndex.Two, out playerIndex) ||
IsNewButtonRelease(button, PlayerIndex.Three, out playerIndex) ||
IsNewButtonRelease(button, PlayerIndex.Four, out playerIndex));
}
}
public bool IsNewVirtualButtonPress(Buttons button)
{
return (_lastVirtualState.IsButtonUp(button) &&
axios/ScreenSystem/MenuEntry.cs
2222
2323
2424
25
25
2626
2727
2828
/// entries in different ways. This also provides an event that will be raised
/// when the menu entry is selected.
/// </summary>
class MenuEntry
public class MenuEntry
{
#region Fields
axios/ScreenSystem/MenuScreen.cs
2323
2424
2525
26
26
2727
2828
2929
30
30
3131
3232
3333
......
8787
8888
8989
90
91
92
93
94
95
9096
9197
9298
/// Base class for screens that contain a menu of options. The user can
/// move up and down to select an entry, or cancel to back out of the screen.
/// </summary>
abstract class MenuScreen : GameScreen
public class MenuScreen : GameScreen
{
#region Fields
List<MenuEntry> menuEntries = new List<MenuEntry>();
private List<MenuEntry> menuEntries = new List<MenuEntry>();
int selectedEntry = 0;
string menuTitle;
#endregion
public void AddMenuItem(string name)
{
menuEntries.Add(new MenuEntry(name));
}
#region Handle Input
axios/ScreenSystem/PhysicsGameScreen.cs
185185
186186
187187
188
188
189
189190
190191
191192
......
195196
196197
197198
198
199
199200
200201
201202
......
203204
204205
205206
206
207
207208
208209
209210
......
220221
221222
222223
223
224
224225
225226
226227
......
234235
235236
236237
237
238
238239
239240
240241
241242
242
243
243244
244245
245246
246
247
247248
248249
249250
250
251
251252
252253
253254
254
255
255256
256257
257258
258
259
259260
260261
261262
262
263
263264
264265
265266
......
267268
268269
269270
270
271
272
271273
272274
273275
274276
275277
276278
277
279
278280
279281
280
281
282
282
283
284
283285
284286
285287
......
289291
290292
291293
292
294
293295
294296
295297
296
298
297299
298300
299301
300
302
301303
302304
303305
304
306
305307
306308
307309
308
310
309311
310312
311313
312
314
313315
314316
315317
HandleCursor(input);
}
if (input.IsNewButtonPress(Buttons.Back) || input.IsNewKeyPress(Keys.Escape))
PlayerIndex i;
if (input.IsNewButtonPress(Buttons.Back, PlayerIndex.One, out i) || input.IsNewKeyPress(Keys.Escape, PlayerIndex.One, out i))
{
if (this.ScreenState == GameStateManagement.ScreenState.Active && this.TransitionPosition == 0 && this.TransitionAlpha == 1)
{ //Give the screens a chance to transition
}
}
base.HandleInput(input, gameTime);
base.HandleInput(gameTime, input);
}
public virtual void HandleCursor(InputState input)
PlayerIndex player;
Vector2 position = Camera.ConvertScreenToWorld(input.Cursor);
if ((input.IsNewButtonPress(Buttons.A) ||
if ((input.IsNewButtonPress(Buttons.A, PlayerIndex.One, out player) ||
input.IsNewMouseButtonPress(MouseButtons.LeftButton)) &&
_fixedMouseJoint == null)
{
if ((input.IsNewButtonRelease(Buttons.A, ControllingPlayer.Value, out player) ||
input.IsNewMouseButtonRelease(MouseButtons.LeftButton, ControllingPlayer.Value, out player)) &&
input.IsNewMouseButtonRelease(MouseButtons.LeftButton)) &&
_fixedMouseJoint != null)
{
World.RemoveJoint(_fixedMouseJoint);
}
private void HandleCamera(InputHelper input, GameTime gameTime)
private void HandleCamera(InputState input, GameTime gameTime)
{
Vector2 camMove = Vector2.Zero;
if (input.KeyboardState.IsKeyDown(Keys.Up))
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Up))
{
camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
}
if (input.KeyboardState.IsKeyDown(Keys.Down))
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Down))
{
camMove.Y += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
}
if (input.KeyboardState.IsKeyDown(Keys.Left))
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Left))
{
camMove.X -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
}
if (input.KeyboardState.IsKeyDown(Keys.Right))
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Right))
{
camMove.X += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
}
if (input.KeyboardState.IsKeyDown(Keys.PageUp))
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.PageUp))
{
Camera.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
}
if (input.KeyboardState.IsKeyDown(Keys.PageDown))
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.PageDown))
{
Camera.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
}
{
Camera.MoveCamera(camMove);
}
if (input.IsNewKeyPress(Keys.Home))
PlayerIndex i;
if (input.IsNewKeyPress(Keys.Home, PlayerIndex.One, out i))
{
Camera.ResetCamera();
}
}
private void HandleUserAgent(InputHelper input)
private void HandleUserAgent(InputState input)
{
Vector2 force = _agentForce * new Vector2(input.GamePadState.ThumbSticks.Right.X,
-input.GamePadState.ThumbSticks.Right.Y);
float torque = _agentTorque * (input.GamePadState.Triggers.Right - input.GamePadState.Triggers.Left);
Vector2 force = _agentForce * new Vector2(input.CurrentGamePadStates[0].ThumbSticks.Right.X,
-input.CurrentGamePadStates[0].ThumbSticks.Right.Y);
float torque = _agentTorque * (input.CurrentGamePadStates[0].Triggers.Right - input.CurrentGamePadStates[0].Triggers.Left);
_userAgent.ApplyForce(force);
_userAgent.ApplyTorque(torque);
force = Vector2.Zero;
torque = 0;
if (input.KeyboardState.IsKeyDown(Keys.A))
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.A))
{
force += new Vector2(-forceAmount, 0);
}
if (input.KeyboardState.IsKeyDown(Keys.S))
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.S))
{
force += new Vector2(0, forceAmount);
}
if (input.KeyboardState.IsKeyDown(Keys.D))
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.D))
{
force += new Vector2(forceAmount, 0);
}
if (input.KeyboardState.IsKeyDown(Keys.W))
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.W))
{
force += new Vector2(0, -forceAmount);
}
if (input.KeyboardState.IsKeyDown(Keys.Q))
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Q))
{
torque -= _agentTorque;
}
if (input.KeyboardState.IsKeyDown(Keys.E))
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.E))
{
torque += _agentTorque;
}
axios/ScreenSystem/PlayerIndexEventArgs.cs
1818
1919
2020
21
21
2222
2323
2424
/// Custom event argument which includes the index of the player who
/// triggered the event. This is used by the MenuEntry.Selected event.
/// </summary>
class PlayerIndexEventArgs : EventArgs
public class PlayerIndexEventArgs : EventArgs
{
/// <summary>
/// Constructor.
axios/ScreenSystem/ScreenManager.cs
139139
140140
141141
142
143
142
143
144144
145145
146
146
147147
148148
149149
......
177177
178178
179179
180
180
181181
182182
183183
protected override void LoadContent()
{
// Load content belonging to the screen manager.
ContentManager content = Game.Content;
ContentManager content = new ContentManager(this.Game.Services, "Content/Fonts");
_spriteFonts = new SpriteFonts(content);
spriteBatch = new SpriteBatch(GraphicsDevice);
font = content.Load<SpriteFont>("menufont");
blankTexture = content.Load<Texture2D>("blank");
blankTexture = Game.Content.Load<Texture2D>("Materials/blank");
// Tell each of the screens to load their content.
foreach (GameScreen screen in screens)
public override void Update(GameTime gameTime)
{
// Read the keyboard and gamepad.
input.Update();
input.Update(gameTime);
// Make a copy of the master screen list, to avoid confusion if
// the process of updating one screen adds or removes others.
axios/ScreenSystem/SpriteFonts.cs
1111
1212
1313
14
15
16
14
15
16
1717
1818
1919
public SpriteFonts(ContentManager contentManager)
{
MenuSpriteFont = contentManager.Load<SpriteFont>("Fonts/menuFont");
FrameRateCounterFont = contentManager.Load<SpriteFont>("Fonts/frameRateCounterFont");
DetailsFont = contentManager.Load<SpriteFont>("Fonts/detailsFont");
MenuSpriteFont = contentManager.Load<SpriteFont>("menuFont");
FrameRateCounterFont = contentManager.Load<SpriteFont>("frameRateCounterFont");
DetailsFont = contentManager.Load<SpriteFont>("detailsFont");
}
}
}

Archive Download the corresponding diff file

Page rendered in 0.76910s using 13 queries.