diff --git a/AccelerometerAndroidImpl.cs b/AccelerometerAndroidImpl.cs new file mode 100644 index 0000000..afb9e60 --- /dev/null +++ b/AccelerometerAndroidImpl.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Devices.Sensors; + +namespace WindowsPhoneSpeedyBlupi +{ + public class AccelerometerAndroidImpl : IAccelerometer + { + public event EventHandler CurrentValueChanged; + + private Accelerometer accelerometer = new Accelerometer(); + public void Start() + { + accelerometer.Start(); + } + + public void Stop() + { + accelerometer.Stop(); + } + } +} diff --git a/AccelerometerDummyImpl.cs b/AccelerometerDummyImpl.cs index 20b3294..d5036fb 100644 --- a/AccelerometerDummyImpl.cs +++ b/AccelerometerDummyImpl.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace WindowsPhoneSpeedyBlupi { - public class AccelerometerDummyImpl : Accelerometer + public class AccelerometerDummyImpl : IAccelerometer { public event EventHandler CurrentValueChanged; diff --git a/AccelerometerFactory.cs b/AccelerometerFactory.cs index b11ae26..4074e2a 100644 --- a/AccelerometerFactory.cs +++ b/AccelerometerFactory.cs @@ -8,6 +8,6 @@ namespace WindowsPhoneSpeedyBlupi { public class AccelerometerFactory { - public static Accelerometer Create() { return new AccelerometerDummyImpl(); } + public static IAccelerometer Create() { return new AccelerometerDummyImpl(); } } } diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 101a033..579292b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,6 +1,6 @@  - - + + - + diff --git a/Game1.cs b/Game1.cs index a3c4e99..89aa5e1 100644 --- a/Game1.cs +++ b/Game1.cs @@ -979,5 +979,9 @@ namespace WindowsPhoneSpeedyBlupi this.graphics.ToggleFullScreen(); } public bool IsFullScreen() { return this.graphics.IsFullScreen; } + public GraphicsDeviceManager getGraphics() + { + return graphics; + } } } \ No newline at end of file diff --git a/Accelerometer.cs b/IAccelerometer.cs similarity index 84% rename from Accelerometer.cs rename to IAccelerometer.cs index 4936fec..f5cf42d 100644 --- a/Accelerometer.cs +++ b/IAccelerometer.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace WindowsPhoneSpeedyBlupi { - public interface Accelerometer + public interface IAccelerometer { void Start(); void Stop(); diff --git a/InputPad.cs b/InputPad.cs index 07504aa..85079c6 100644 --- a/InputPad.cs +++ b/InputPad.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using Microsoft.Devices.Sensors; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input.Touch; using WindowsPhoneSpeedyBlupi; @@ -215,7 +216,7 @@ namespace WindowsPhoneSpeedyBlupi this.sound = sound; this.gameData = gameData; pressedGlyphs = new List(); - accelSensor = AccelerometerFactory.Create(); + accelSensor = new Accelerometer(); accelSensor.CurrentValueChanged += HandleAccelSensorCurrentValueChanged; accelSlider = new Slider { @@ -287,6 +288,46 @@ namespace WindowsPhoneSpeedyBlupi touchesOrClicks.Add(click); } + + float screenWidth = game1.getGraphics().GraphicsDevice.Viewport.Width; + float screenHeight = game1.getGraphics().GraphicsDevice.Viewport.Height; + float screenRatio = screenWidth / screenHeight; + + + //if (screenRatio < 1.3333333333333333 && false) + { + for (int i = 0; i < touchesOrClicks.Count; i++) + { + + //if (touchOrClick.X == -1) continue; + var touchOrClick = touchesOrClicks[i]; + + float originalX = touchOrClick.X; + float originalY = touchOrClick.Y; + + + float widthHeightRatio = screenWidth / screenHeight; + float heightRatio = 480 / screenHeight; + float widthRatio = 640 / screenWidth; + Debug.WriteLine("-----"); + Debug.WriteLine("originalX=" + originalX); + Debug.WriteLine("originalY=" + originalY); + Debug.WriteLine("heightRatio=" + heightRatio); + Debug.WriteLine("widthRatio=" + widthRatio); + Debug.WriteLine("widthHeightRatio=" + widthHeightRatio); + if (screenHeight> 480) { + touchOrClick.X = (int)(originalX * heightRatio); + touchOrClick.Y = (int)(originalY * heightRatio); + touchesOrClicks[i] = touchOrClick; + } + + Debug.WriteLine("new X" + touchOrClick.X); + Debug.WriteLine("new Y" + touchOrClick.Y); + + + } + } + KeyboardState newState = Keyboard.GetState(); { if (newState.IsKeyDown(Keys.LeftControl)) touchesOrClicks.Add(createTinyPoint(-1, Misc.keyboardPressToInt(KeyboardPress.LeftControl))); @@ -952,12 +993,13 @@ namespace WindowsPhoneSpeedyBlupi } - private void HandleAccelSensorCurrentValueChanged(object sender, AccelerometerEventArgs e) + private void HandleAccelSensorCurrentValueChanged(object sender, SensorReadingEventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) - float y = e.Y; + AccelerometerReading sensorReading = e.SensorReading; + float y = ((AccelerometerReading)(sensorReading)).Acceleration.Y; float num = (1f - (float)gameData.AccelSensitivity) * 0.06f + 0.04f; float num2 = (accelLastState ? (num * 0.6f) : num); if (y > num2) diff --git a/Misc.cs b/Misc.cs index f3ab936..a1cad8c 100644 --- a/Misc.cs +++ b/Misc.cs @@ -133,7 +133,7 @@ namespace WindowsPhoneSpeedyBlupi case 6: return KeyboardPress.Space; case 7: return KeyboardPress.Escape; case 8: return KeyboardPress.Pause; - default: throw new Exception("Unsupported number for KeyboardPress: " + i); + default: return KeyboardPress.None; //throw new Exception("Unsupported number for KeyboardPress: " + i); } } public static int keyboardPressToInt(KeyboardPress kp) diff --git a/Pixmap.cs b/Pixmap.cs index 545c35b..2a96b4f 100644 --- a/Pixmap.cs +++ b/Pixmap.cs @@ -1,6 +1,7 @@ // WindowsPhoneSpeedyBlupi, Version=1.0.0.5, Culture=neutral, PublicKeyToken=6db12cd62dbec439 // WindowsPhoneSpeedyBlupi.Pixmap using System; +using System.Diagnostics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using WindowsPhoneSpeedyBlupi; @@ -63,20 +64,23 @@ namespace WindowsPhoneSpeedyBlupi get { TinyRect result = default(TinyRect); - double num = graphics.GraphicsDevice.Viewport.Width; - double num2 = graphics.GraphicsDevice.Viewport.Height; - if (num != 0.0 && num2 != 0.0) + double screenWidth = graphics.GraphicsDevice.Viewport.Width; + double screenHeight = graphics.GraphicsDevice.Viewport.Height; + if(screenHeight > 480) { + screenWidth = screenHeight * (640f / 480f); + } + if (screenWidth != 0.0 && screenHeight != 0.0) { double num3; double num4; - if (num / num2 < 1.3333333333333333) + if (screenWidth / screenHeight < 1.3333333333333333) { num3 = 640.0; - num4 = 640.0 * (num2 / num); + num4 = 640.0 * (screenHeight / screenWidth); } else { - num3 = 480.0 * (num / num2); + num3 = 480.0 * (screenWidth / screenHeight); num4 = 480.0; } result.Left = 0; @@ -242,13 +246,19 @@ namespace WindowsPhoneSpeedyBlupi private void UpdateGeometry() { - double num = graphics.GraphicsDevice.Viewport.Width; - double num2 = graphics.GraphicsDevice.Viewport.Height; - double val = num / 640.0; - double val2 = num2 / 480.0; + double screenWidth = graphics.GraphicsDevice.Viewport.Width; + double screenHeight = graphics.GraphicsDevice.Viewport.Height; + if (screenHeight > 480) + { + screenWidth = screenHeight * (640f / 480f); + } + Debug.WriteLine("graphics.GraphicsDevice.Viewport.Width=" + graphics.GraphicsDevice.Viewport.Width); + Debug.WriteLine("graphics.GraphicsDevice.Viewport.Height=" + graphics.GraphicsDevice.Viewport.Height); + double val = screenWidth / 640.0; + double val2 = screenHeight / 480.0; zoom = Math.Min(val, val2); - originX = (num - 640.0 * zoom) / 2.0; - originY = (num2 - 480.0 * zoom) / 2.0; + originX = (screenWidth - 640.0 * zoom) / 2.0; + originY = (screenHeight - 480.0 * zoom) / 2.0; } public void BackgroundCache(string name) @@ -269,11 +279,15 @@ namespace WindowsPhoneSpeedyBlupi public void DrawBackground() { - double num = graphics.GraphicsDevice.Viewport.Width; - double num2 = graphics.GraphicsDevice.Viewport.Height; + double screenWidth = graphics.GraphicsDevice.Viewport.Width; + double screenHeight = graphics.GraphicsDevice.Viewport.Height; + if (screenHeight > 480) + { + screenWidth = screenHeight * (640f / 480f); + } Texture2D bitmap = GetBitmap(3); Rectangle srcRectangle = GetSrcRectangle(bitmap, 10, 10, 10, 10, 0, 0); - Rectangle destinationRectangle = new Rectangle(0, 0, (int)num, (int)num2); + Rectangle destinationRectangle = new Rectangle(0, 0, (int)screenWidth, (int)screenHeight); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); spriteBatch.Draw(bitmap, destinationRectangle, srcRectangle, Color.White); spriteBatch.End(); diff --git a/Resources/Values/Strings.xml b/Resources/Values/Strings.xml index 873f28e..0fd9099 100644 --- a/Resources/Values/Strings.xml +++ b/Resources/Values/Strings.xml @@ -1,4 +1,4 @@ - sb2013 + speedyblupi2013android diff --git a/Worlds.cs b/Worlds.cs index 6f00e8f..c6d0cee 100644 --- a/Worlds.cs +++ b/Worlds.cs @@ -42,8 +42,9 @@ namespace WindowsPhoneSpeedyBlupi text = streamReader.ReadToEnd(); stream.Close(); } - catch + catch (Exception e) { + Debug.Write(e.Message); Debug.Write("Fatal error. Loading world failed: " + worldFilename + "\n"); //Environment.Exit(1); } @@ -51,7 +52,7 @@ namespace WindowsPhoneSpeedyBlupi { return null; } - return text.Split('\n'); + return text.Split("\n"); } private static string GetWorldFilename(int gamer, int rank) diff --git a/sb2013.csproj b/sb2013.csproj deleted file mode 100644 index 14e1626..0000000 --- a/sb2013.csproj +++ /dev/null @@ -1,37 +0,0 @@ - - - net8.0-android - 23 - Exe - com.companyname.sb2013 - 1 - 1.0 - - - apk - True - rvrvrv - rv-alias - rvrvrv - - - false - false - ARM64 - rv.keystore - - - True - rvrvrv - rv-alias - rvrvrv - - - - - - - - - - \ No newline at end of file diff --git a/speedyblupi2013android.csproj b/speedyblupi2013android.csproj new file mode 100644 index 0000000..961582e --- /dev/null +++ b/speedyblupi2013android.csproj @@ -0,0 +1,276 @@ + + + net8.0-android34.0 + 26.0 + Exe + com.companyname.speedyblupi2013android + 1 + 1.0 + + + apk + True + rvrvrv + rv-alias + rvrvrv + Xamarin + + + false + false + ARM64 + rv.keystore + + + True + rvrvrv + rv-alias + rvrvrv + Xamarin + + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + + + + + + + + + + \ No newline at end of file diff --git a/sb2013.sln b/speedyblupi2013android.sln similarity index 81% rename from sb2013.sln rename to speedyblupi2013android.sln index dcb1f3b..9dc5c25 100644 --- a/sb2013.sln +++ b/speedyblupi2013android.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.12.35514.174 d17.12 +VisualStudioVersion = 17.12.35514.174 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sb2013", "sb2013.csproj", "{5CBF659B-BB98-4868-B40E-C318955E3BC6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "speedyblupi2013android", "speedyblupi2013android.csproj", "{5CBF659B-BB98-4868-B40E-C318955E3BC6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution