Skip to content

Commit 0e19500

Browse files
Patch
1 parent bc08054 commit 0e19500

File tree

7 files changed

+683
-6
lines changed

7 files changed

+683
-6
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
#----------------------------- Global Properties ----------------------------#
3+
4+
/outputDir:bin/$(Platform)
5+
/intermediateDir:obj/$(Platform)
6+
/platform:Android
7+
/config:
8+
/profile:Reach
9+
/compress:False
10+
11+
#-------------------------------- References --------------------------------#
12+
13+
14+
#---------------------------------- Content ---------------------------------#
15+
16+
#begin Fonts/Hud.spritefont
17+
/importer:FontDescriptionImporter
18+
/processor:FontDescriptionProcessor
19+
/processorParam:PremultiplyAlpha=True
20+
/processorParam:TextureFormat=Compressed
21+
/build:Fonts/Hud.spritefont
22+
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
This file contains an xml description of a font, and will be read by the XNA
4+
Framework Content Pipeline. Follow the comments to customize the appearance
5+
of the font in your game, and to change the characters which are available to draw
6+
with.
7+
-->
8+
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
9+
<Asset Type="Graphics:FontDescription">
10+
11+
<!--
12+
Modify this string to change the font that will be imported.
13+
-->
14+
<FontName>Roboto-Bold</FontName>
15+
16+
<!--
17+
Size is a float value, measured in points. Modify this value to change
18+
the size of the font.
19+
-->
20+
<Size>32</Size>
21+
22+
<!--
23+
Spacing is a float value, measured in pixels. Modify this value to change
24+
the amount of spacing in between characters.
25+
-->
26+
<Spacing>0</Spacing>
27+
28+
<!--
29+
UseKerning controls the layout of the font. If this value is true, kerning information
30+
will be used when placing characters.
31+
-->
32+
<UseKerning>true</UseKerning>
33+
34+
<!--
35+
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
36+
and "Bold, Italic", and are case sensitive.
37+
-->
38+
<Style>Regular</Style>
39+
40+
<!--
41+
If you uncomment this line, the default character will be substituted if you draw
42+
or measure text that contains characters which were not included in the font.
43+
-->
44+
<!-- <DefaultCharacter>*</DefaultCharacter> -->
45+
46+
<!--
47+
CharacterRegions control what letters are available in the font. Every
48+
character from Start to End will be built and made available for drawing. The
49+
default range is from 32, (ASCII space), to 254, ('■'), covering the basic Latin
50+
character set as well as extended character set.
51+
The characters are ordered according to the Unicode standard.
52+
See the documentation for more information.
53+
-->
54+
<CharacterRegions>
55+
<!-- Latin Character and Extended Set -->
56+
<CharacterRegion>
57+
<Start>&#32;</Start>
58+
<End>&#254;</End>
59+
</CharacterRegion>
60+
61+
<!-- Hiragana (U+3040 - U+309F) -->
62+
<CharacterRegion>
63+
<Start>&#12352;</Start>
64+
<End>&#12447;</End>
65+
</CharacterRegion>
66+
67+
<!-- Katakana (U+30A0 - U+30FF) -->
68+
<CharacterRegion>
69+
<Start>&#12448;</Start>
70+
<End>&#12543;</End>
71+
</CharacterRegion>
72+
73+
<!-- Common Kanji (CJK Unified Ideographs - typically U+4E00 to U+9FFF) -->
74+
<CharacterRegion>
75+
<Start>&#19968;</Start>
76+
<End>&#40879;</End>
77+
</CharacterRegion>
78+
79+
<!-- Cyrillic Character Set -->
80+
<CharacterRegion>
81+
<Start>&#1040;</Start>
82+
<End>&#1103;</End>
83+
</CharacterRegion>
84+
</CharacterRegions>
85+
</Asset>
86+
</XnaContent>
163 KB
Binary file not shown.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
using Microsoft.Xna.Framework;
2+
using Microsoft.Xna.Framework.Graphics;
3+
using Microsoft.Xna.Framework.Input;
4+
using myStartkit.Core.Inputs;
5+
6+
namespace AutoPong;
7+
8+
public class Game1 : Game
9+
{
10+
private GraphicsDeviceManager _graphics;
11+
private SpriteBatch _spriteBatch;
12+
private readonly InputState inputState = new InputState();
13+
private SpriteFont hudFont;
14+
private int playerIndex = (int)PlayerIndex.One;
15+
private Color textDrawColour = Color.White;
16+
private int textStartPosition = 20;
17+
private int positionSpacing = 40;
18+
19+
public Game1()
20+
{
21+
_graphics = new GraphicsDeviceManager(this);
22+
Content.RootDirectory = "Content";
23+
IsMouseVisible = true;
24+
_graphics.IsFullScreen = true;
25+
_graphics.PreferredBackBufferWidth = 2560;
26+
_graphics.PreferredBackBufferHeight = 1440;
27+
}
28+
29+
protected override void Initialize()
30+
{
31+
// TODO: Add your initialization logic here
32+
33+
base.Initialize();
34+
}
35+
36+
protected override void LoadContent()
37+
{
38+
_spriteBatch = new SpriteBatch(GraphicsDevice);
39+
40+
// TODO: use this.Content to load your game content here
41+
hudFont = Content.Load<SpriteFont>("Fonts/Hud");
42+
}
43+
44+
protected override void Update(GameTime gameTime)
45+
{
46+
inputState.Update(gameTime, GraphicsDevice.Viewport);
47+
48+
base.Update(gameTime);
49+
}
50+
51+
protected override void Draw(GameTime gameTime)
52+
{
53+
GraphicsDevice.Clear(Color.CornflowerBlue);
54+
55+
string state = inputState.CurrentGamePadStates[playerIndex].IsConnected ? "Connected" : "Disconnected";
56+
57+
string connectedValue = $"GamePad: {state}";
58+
string AbuttonValue = $"A Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.A)}";
59+
string BbuttonValue = $"B Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.B)}";
60+
string XbuttonValue = $"X Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.X)}";
61+
string YbuttonValue = $"Y Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.Y)}";
62+
63+
string StartbuttonValue = $"Start Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.Start)}";
64+
string BackbuttonValue = $"Back Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.Back)}";
65+
string BigbuttonValue = $"Big Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.BigButton)}";
66+
67+
string DPadLbuttonValue = $"DPadL Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.DPadLeft)}";
68+
string DPadRbuttonValue = $"DPadR Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.DPadRight)}";
69+
string DPadUbuttonValue = $"DPadU Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.DPadUp)}";
70+
string DPadDbuttonValue = $"DPadD Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.DPadDown)}";
71+
72+
string RBumperbuttonValue = $"RBumper Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.RightShoulder)}";
73+
string RThumbstickbuttonValue = $"RThumbstick Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.RightThumbstickDown)}";
74+
string RThumbstickStateValue = $"RThumbstick State: {inputState.CurrentGamePadStates[playerIndex].ThumbSticks.Right}";
75+
string RTriggerValue = $"RTrigger Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.RightTrigger)}";
76+
string RTriggerStateValue = $"RTrigger State: {inputState.CurrentGamePadStates[playerIndex].Triggers.Right}";
77+
78+
string LBumperbuttonValue = $"LBumper Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.LeftShoulder)}";
79+
string LThumbstickbuttonValue = $"LThumbstick Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.LeftThumbstickDown)}";
80+
string LThumbstickStateValue = $"LThumbstick State: {inputState.CurrentGamePadStates[playerIndex].ThumbSticks.Left}";
81+
string LTriggerValue = $"LTrigger Button: {inputState.CurrentGamePadStates[playerIndex].IsButtonDown(Buttons.LeftTrigger)}";
82+
string LTriggerStateValue = $"LTrigger State: {inputState.CurrentGamePadStates[playerIndex].Triggers.Left}";
83+
_spriteBatch.Begin();
84+
// TODO: Add your drawing code here
85+
_spriteBatch.DrawString(hudFont, connectedValue, new Vector2(20, textStartPosition), textDrawColour);
86+
DrawInputValue(AbuttonValue, 1);
87+
DrawInputValue(BbuttonValue, 2);
88+
DrawInputValue(XbuttonValue, 3);
89+
DrawInputValue(YbuttonValue, 4);
90+
91+
DrawInputValue(StartbuttonValue, 5);
92+
DrawInputValue(BackbuttonValue, 6);
93+
DrawInputValue(BigbuttonValue, 7);
94+
95+
DrawInputValue(DPadLbuttonValue, 8);
96+
DrawInputValue(DPadRbuttonValue, 9);
97+
DrawInputValue(DPadUbuttonValue, 10);
98+
DrawInputValue(DPadDbuttonValue, 11);
99+
100+
DrawInputValue(LBumperbuttonValue, 12);
101+
DrawInputValue(LThumbstickbuttonValue, 13);
102+
DrawInputValue(LThumbstickStateValue, 14);
103+
DrawInputValue(LTriggerValue, 15);
104+
DrawInputValue(LTriggerStateValue, 16);
105+
106+
DrawInputValue(RBumperbuttonValue, 17);
107+
DrawInputValue(RThumbstickbuttonValue, 18);
108+
DrawInputValue(RThumbstickStateValue, 19);
109+
DrawInputValue(RTriggerValue, 20);
110+
DrawInputValue(RTriggerStateValue, 21);
111+
112+
_spriteBatch.End();
113+
114+
base.Draw(gameTime);
115+
}
116+
117+
private void DrawInputValue(string AbuttonValue, int index)
118+
{
119+
_spriteBatch.DrawString(hudFont, AbuttonValue, new Vector2(20, GetTextPositionForIndex(index)), textDrawColour);
120+
}
121+
122+
private int GetTextPositionForIndex(int index)
123+
{
124+
return textStartPosition + positionSpacing * index;
125+
}
126+
}

0 commit comments

Comments
 (0)