Browse Source

Basic working skeleton in OpenGL and UWP.

GitOrigin-RevId: 762b683654
master
Colin McMillen 4 years ago
parent
commit
149ecf8075
  1. 4
      Jumpy.Shared/Jumpy.Shared.projitems
  2. 64
      Jumpy.Shared/JumpyGame.cs
  3. 24
      Jumpy.Shared/KeyboardInput.cs

4
Jumpy.Shared/Jumpy.Shared.projitems

@ -9,5 +9,7 @@
<Import_RootNamespace>Jumpy.Shared</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)KeyboardInput.cs" />
<Compile Include="$(MSBuildThisFileDirectory)JumpyGame.cs" />
</ItemGroup>
</Project>
</Project>

64
Jumpy.Shared/JumpyGame.cs

@ -0,0 +1,64 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Collections.Generic;
namespace Jumpy {
public class JumpyGame : Game {
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
SpriteFont font;
KeyboardInput keyboardInput = new KeyboardInput();
public JumpyGame() {
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
// Performs initialization that's needed before starting to run.
protected override void Initialize() {
base.Initialize();
}
// Called once per game. Loads all game content.
protected override void LoadContent() {
spriteBatch = new SpriteBatch(GraphicsDevice);
font = Content.Load<SpriteFont>("font");
}
// Called once per game. Unloads all game content.
protected override void UnloadContent() {
// TODO: Unload any non ContentManager content here.
}
// Updates the game world.
protected override void Update(GameTime gameTime) {
keyboardInput.Update();
List<Keys> keysDown = keyboardInput.NewKeysDown();
//if (keysDown.Contains(Keys.F12))
//{
// SetFullScreen(!fullScreen);
//}
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
keysDown.Contains(Keys.Escape)) {
Exit();
}
base.Update(gameTime);
}
// Called when the game should draw itself.
protected override void Draw(GameTime gameTime) {
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
spriteBatch.DrawString(font, "hello world", new Vector2(100, 100), Color.Black);
spriteBatch.End();
base.Draw(gameTime);
}
}
}

24
Jumpy.Shared/KeyboardInput.cs

@ -0,0 +1,24 @@
using Microsoft.Xna.Framework.Input;
using System.Collections.Generic;
namespace Jumpy {
public class KeyboardInput {
private KeyboardState oldState = Keyboard.GetState();
private List<Keys> newKeysDown = new List<Keys>();
public void Update() {
KeyboardState newState = Keyboard.GetState();
newKeysDown.Clear();
foreach (Keys k in newState.GetPressedKeys()) {
if (!oldState.IsKeyDown(k)) {
newKeysDown.Add(k);
}
}
oldState = newState;
}
public List<Keys> NewKeysDown() {
return newKeysDown;
}
}
}
Loading…
Cancel
Save