From 95d7601b7742ed560a9d8e00269217f62fc7ce32 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Sun, 10 Nov 2013 22:11:08 -0600 Subject: Chubas's House happened. --- Super Polarity/InputController.cs | 118 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 Super Polarity/InputController.cs (limited to 'Super Polarity/InputController.cs') diff --git a/Super Polarity/InputController.cs b/Super Polarity/InputController.cs new file mode 100644 index 0000000..405b3ab --- /dev/null +++ b/Super Polarity/InputController.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework.Input; + +namespace SuperPolarity +{ + static class InputController + { + static Dictionary>> Listeners; + static Dictionary> RegisteredKeys; + static Dictionary> RegisteredButtons; + + static GamePadState InputGamePadState; + static KeyboardState InputKeyboardState; + + /* + * Registered Events. + * + * You register: name of the event (ie. attack) and a key associated with it. + * or button... Left Stick /always/ dispatches move event. + */ + + static InputController() + { + Listeners = new Dictionary>>(); + InputKeyboardState = new KeyboardState(); + InputGamePadState = new GamePadState(); + } + + public static void UpdateInput() + { + Poll(); + DispatchMoveEvents(); + DispatchRegisteredEvents(); + } + + private static void Poll() + { + InputGamePadState = GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One); + InputKeyboardState = Keyboard.GetState(); + } + + private static void DispatchRegisteredEvents() + { + } + + private static void DispatchMoveEvents() + { + float xMovement = 0.0f; + float yMovement = 0.0f; + // Dispatch the moveX / MoveY events every frame. + + xMovement = InputGamePadState.ThumbSticks.Left.X; + yMovement = -InputGamePadState.ThumbSticks.Left.Y; + + Console.WriteLine("Dispatching Input {0}", InputKeyboardState.IsKeyDown(Keys.Left)); + + if (InputKeyboardState.IsKeyDown(Keys.Left)) + { + xMovement = -1.0f; + } + + if (InputKeyboardState.IsKeyDown(Keys.Right)) + { + xMovement = 1.0f; + } + + if (InputKeyboardState.IsKeyDown(Keys.Up)) + { + yMovement = -1.0f; + } + + if (InputKeyboardState.IsKeyDown(Keys.Down)) + { + yMovement = 1.0f; + } + + Dispatch("moveX", xMovement); + Dispatch("moveY", yMovement); + } + + public static void Bind(string eventName, Action listener) + { + List> newListenerList; + List> listenerList; + bool foundListeners; + + if (!Listeners.ContainsKey(eventName)) { + newListenerList = new List>(); + Listeners.Add(eventName, newListenerList); + } + + foundListeners = Listeners.TryGetValue(eventName, out listenerList); + + listenerList.Add(listener); + } + + public static void Dispatch(string eventName, float value) + { + List> listenerList; + bool foundListeners; + + foundListeners = Listeners.TryGetValue(eventName, out listenerList); + + if (!foundListeners) + { + return; + } + + foreach (Action method in listenerList) + { + method(value); + } + } + } +} -- cgit From 2af83e98005a14c439b360a5b9ac636f594d9f0c Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Tue, 12 Nov 2013 06:44:55 -0600 Subject: Implements polarity system --- .../Graphics/negative-ship.png | Bin 0 -> 824 bytes .../Super Polarity ContentContent.contentproj | 7 + Super Polarity.suo | Bin 31744 -> 38400 bytes Super Polarity/Actor.cs | 154 ------------------- Super Polarity/ActorFactory.cs | 36 ++++- Super Polarity/ActorManager.cs | 41 ++++++ Super Polarity/Actors/Actor.cs | 161 ++++++++++++++++++++ Super Polarity/Actors/MainShip.cs | 163 +++++++++++++++++++++ Super Polarity/Actors/Ship.cs | 91 ++++++++++++ Super Polarity/Actors/StandardShip.cs | 114 ++++++++++++++ Super Polarity/Content/Graphics/negative-ship.xnb | Bin 0 -> 11707 bytes Super Polarity/Content/Graphics/player.xnb | Bin 32203 -> 0 bytes Super Polarity/InputController.cs | 82 ++++++++++- Super Polarity/MainShip.cs | 66 --------- Super Polarity/ParticleEngine.cs | 7 +- Super Polarity/Ship.cs | 38 ----- Super Polarity/Super Polarity.csproj | 10 +- Super Polarity/SuperPolarity.cs | 10 +- .../WindowsGL/Debug/Content/Graphics/player.xnb | Bin 32203 -> 0 bytes .../bin/WindowsGL/Debug/Super Polarity.exe | Bin 47104 -> 53248 bytes .../bin/WindowsGL/Debug/Super Polarity.pdb | Bin 50688 -> 58880 bytes .../DesignTimeResolveAssemblyReferencesInput.cache | Bin 8028 -> 8150 bytes .../Super Polarity.csproj.FileListAbsolute.txt | 1 + Super Polarity/obj/x86/Debug/Super Polarity.exe | Bin 47104 -> 53248 bytes Super Polarity/obj/x86/Debug/Super Polarity.pdb | Bin 50688 -> 58880 bytes 25 files changed, 708 insertions(+), 273 deletions(-) create mode 100644 Super Polarity Content/Super Polarity ContentContent/Graphics/negative-ship.png delete mode 100644 Super Polarity/Actor.cs create mode 100644 Super Polarity/Actors/Actor.cs create mode 100644 Super Polarity/Actors/MainShip.cs create mode 100644 Super Polarity/Actors/Ship.cs create mode 100644 Super Polarity/Actors/StandardShip.cs create mode 100644 Super Polarity/Content/Graphics/negative-ship.xnb delete mode 100644 Super Polarity/Content/Graphics/player.xnb delete mode 100644 Super Polarity/MainShip.cs delete mode 100644 Super Polarity/Ship.cs delete mode 100644 Super Polarity/bin/WindowsGL/Debug/Content/Graphics/player.xnb (limited to 'Super Polarity/InputController.cs') diff --git a/Super Polarity Content/Super Polarity ContentContent/Graphics/negative-ship.png b/Super Polarity Content/Super Polarity ContentContent/Graphics/negative-ship.png new file mode 100644 index 0000000..1407d5d Binary files /dev/null and b/Super Polarity Content/Super Polarity ContentContent/Graphics/negative-ship.png differ diff --git a/Super Polarity Content/Super Polarity ContentContent/Super Polarity ContentContent.contentproj b/Super Polarity Content/Super Polarity ContentContent/Super Polarity ContentContent.contentproj index 4e7a9f0..f86c49e 100644 --- a/Super Polarity Content/Super Polarity ContentContent/Super Polarity ContentContent.contentproj +++ b/Super Polarity Content/Super Polarity ContentContent/Super Polarity ContentContent.contentproj @@ -129,6 +129,13 @@ TextureProcessor + + + negative-ship + TextureImporter + TextureProcessor + +