Axios-Tennis

Axios-Tennis Commit Details


Date:2012-05-31 22:57:00 (12 years 6 months ago)
Author:Natalie Adams
Branch:default
Commit:e0b99058d10d
Parents: cc4fc200da57
Message:Adding support for Axios Console

Changes:
Aaxios_tennis/axios_tennisContent/Console.spritefont (full)
Maxios_tennis/axios_tennis/Objects/Ball.cs (2 diffs)
Maxios_tennis/axios_tennis/TennisScreen.cs (6 diffs)
Maxios_tennis/axios_tennisContent/axios_tennisContent.contentproj (1 diff)

File differences

axios_tennis/axios_tennis/Objects/Ball.cs
7777
7878
7979
80
8081
8182
8283
......
8788
8889
8990
91
9092
9193
9294
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)
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))
axios_tennis/axios_tennis/TennisScreen.cs
22
33
44
5
5
66
77
88
......
1212
1313
1414
15
16
17
18
19
1520
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
1646
1747
1848
......
2353
2454
2555
56
2657
2758
2859
60
61
62
63
64
65
66
67
68
69
2970
3071
3172
......
75116
76117
77118
119
78120
79121
80122
......
87129
88130
89131
90
91132
92
93
94
95
133
134
135
96136
97
98
99
100
137
138
139
140
141
142
101143
102
103
104
105
106
107
108
109
110
111
112
113
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
114162
115163
116164
......
147195
148196
149197
150
151
152
153
198
199
200
201
202
154203
155204
156205
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;
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<string[]>(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;
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()
{
AddGameObject(_ppaddle);
AddGameObject(_border);
AddGameObject(_ball);
AddGameObject(new GameConsole(this));
}
void b_MouseDown(object sender, AxiosGameScreen gameScreen, InputState input)
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;
}
}
}
}
{
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;
axios_tennis/axios_tennisContent/Console.spritefont
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?xml version="1.0" encoding="utf-8"?>
<!--
This file contains an xml description of a font, and will be read by the XNA
Framework Content Pipeline. Follow the comments to customize the appearance
of the font in your game, and to change the characters which are available to draw
with.
-->
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
<Asset Type="Graphics:FontDescription">
<!--
Modify this string to change the font that will be imported.
-->
<FontName>Segoe UI Mono</FontName>
<!--
Size is a float value, measured in points. Modify this value to change
the size of the font.
-->
<Size>14</Size>
<!--
Spacing is a float value, measured in pixels. Modify this value to change
the amount of spacing in between characters.
-->
<Spacing>0</Spacing>
<!--
UseKerning controls the layout of the font. If this value is true, kerning information
will be used when placing characters.
-->
<UseKerning>true</UseKerning>
<!--
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
and "Bold, Italic", and are case sensitive.
-->
<Style>Regular</Style>
<!--
If you uncomment this line, the default character will be substituted if you draw
or measure text that contains characters which were not included in the font.
-->
<!-- <DefaultCharacter>*</DefaultCharacter> -->
<!--
CharacterRegions control what letters are available in the font. Every
character from Start to End will be built and made available for drawing. The
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
character set. The characters are ordered according to the Unicode standard.
See the documentation for more information.
-->
<CharacterRegions>
<CharacterRegion>
<Start>&#32;</Start>
<End>&#126;</End>
</CharacterRegion>
</CharacterRegions>
</Asset>
</XnaContent>
axios_tennis/axios_tennisContent/axios_tennisContent.contentproj
196196
197197
198198
199
200
201
202
203
204
205
199206
200207
201208
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Console.spritefont">
<Name>Console</Name>
<Importer>FontDescriptionImporter</Importer>
<Processor>FontDescriptionProcessor</Processor>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

Archive Download the corresponding diff file

Branches

Tags

Page rendered in 0.42908s using 14 queries.