|
|
@@ -13,6 +13,7 @@ namespace AtomicBlaster
|
|
|
static class ShipInput
|
|
|
{
|
|
|
private static bool isAimingWithMouse = false;
|
|
|
+ static IntVector2 lastTouchPos = IntVector2.Zero;
|
|
|
|
|
|
public static void Update()
|
|
|
{
|
|
|
@@ -26,6 +27,7 @@ namespace AtomicBlaster
|
|
|
|
|
|
Vector2 direction = new Vector2(0, 0);
|
|
|
|
|
|
+#if ATOMIC_DESKTOP
|
|
|
if (input.GetKeyDown((int) SDL.SDL_Keycode.SDLK_a))
|
|
|
direction.X -= 1;
|
|
|
if (input.GetKeyDown((int)SDL.SDL_Keycode.SDLK_d))
|
|
|
@@ -34,9 +36,43 @@ namespace AtomicBlaster
|
|
|
direction.Y -= 1;
|
|
|
if (input.GetKeyDown((int)SDL.SDL_Keycode.SDLK_w))
|
|
|
direction.Y += 1;
|
|
|
+#endif
|
|
|
|
|
|
+#if ATOMIC_MOBILE
|
|
|
|
|
|
+ var touchPos = lastTouchPos;
|
|
|
+
|
|
|
+ if (input.NumTouches == 1)
|
|
|
+ {
|
|
|
+ touchPos = input.GetTouchPosition(0);
|
|
|
+ lastTouchPos = touchPos;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (touchPos != IntVector2.Zero)
|
|
|
+ {
|
|
|
+ direction = new Vector2((float)touchPos.X, (float)touchPos.Y);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Vector2 shipPos = PlayerShip.Instance.Position;
|
|
|
+
|
|
|
+ shipPos.Y = GameRoot.ScreenBounds.Height - shipPos.Y;
|
|
|
+
|
|
|
+ direction -= shipPos;
|
|
|
+
|
|
|
+ direction.Y = -direction.Y;
|
|
|
+
|
|
|
+ if (touchPos == IntVector2.Zero || direction.Length < 4.0f)
|
|
|
+ direction = Vector2.Zero;
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
+#if ATOMIC_IOS
|
|
|
+ uint numJoySticks = 0;
|
|
|
+#else
|
|
|
uint numJoySticks = input.GetNumJoysticks();
|
|
|
+#endif
|
|
|
|
|
|
if (numJoySticks > 0)
|
|
|
{
|
|
|
@@ -73,7 +109,18 @@ namespace AtomicBlaster
|
|
|
{
|
|
|
var input = AtomicNET.GetSubsystem<Input>();
|
|
|
|
|
|
+ Vector2 direction = new Vector2();
|
|
|
+
|
|
|
+#if ATOMIC_DESKTOP
|
|
|
+ direction = new Vector2((float)input.GetMousePosition().X, (float)input.GetMousePosition().Y);
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
+#if ATOMIC_IOS
|
|
|
+ uint numJoySticks = 0;
|
|
|
+#else
|
|
|
uint numJoySticks = input.GetNumJoysticks();
|
|
|
+#endif
|
|
|
|
|
|
if (numJoySticks > 0)
|
|
|
{
|
|
|
@@ -102,7 +149,14 @@ namespace AtomicBlaster
|
|
|
|
|
|
}
|
|
|
|
|
|
- Vector2 direction = new Vector2((float)input.GetMousePosition().X, (float)input.GetMousePosition().Y);
|
|
|
+#if !ATOMIC_MOBILE
|
|
|
+ direction = new Vector2((float)input.GetMousePosition().X, (float)input.GetMousePosition().Y);
|
|
|
+#else
|
|
|
+ {
|
|
|
+ direction = PlayerShip.Instance.Velocity;
|
|
|
+ return Vector2.Normalize(direction);
|
|
|
+ }
|
|
|
+#endif
|
|
|
|
|
|
Vector2 shipPos = PlayerShip.Instance.Position;
|
|
|
|