Skip to content

Commit 0298367

Browse files
committed
Changes so it runs better on mobiles devices.
1 parent 7d20773 commit 0298367

File tree

6 files changed

+30
-3
lines changed

6 files changed

+30
-3
lines changed

ShipGame/ShipGame.Android/ShipGame.Android.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<ItemGroup>
1414
<MonoGameContentReference Include="..\ShipGame.Core\Content\ShipGame.mgcb">
1515
<Link>Content\ShipGame.mgcb</Link>
16+
<Platform>Android</Platform>
1617
</MonoGameContentReference>
1718
</ItemGroup>
1819
<ItemGroup>

ShipGame/ShipGame.Core/ShipGame.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#region Using Statements
1111
using Microsoft.Xna.Framework;
12+
using System;
1213
#endregion
1314

1415
namespace ShipGame
@@ -32,13 +33,21 @@ public ShipGameGame()
3233
{
3334
graphics = new GraphicsDeviceManager(this);
3435
Content.RootDirectory = "Content";
35-
Window.Title = "ShipGame";
36+
Window.Title = "ShipGame";
3637

3738
soundManager = new SoundManager();
3839
game = new GameManager(soundManager);
3940

41+
// On desktop, use the preferred resolution from GameOptions
42+
// On mobile/consoles, these values will be overridden by the device's native resolution
43+
#if WINDOWS || WINDOWS_UAP || DESKTOPGL
4044
graphics.PreferredBackBufferWidth = GameOptions.ScreenWidth;
4145
graphics.PreferredBackBufferHeight = GameOptions.ScreenHeight;
46+
#else
47+
// On mobile platforms, use native resolution
48+
graphics.IsFullScreen = true;
49+
graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
50+
#endif
4251

4352
IsFixedTimeStep = renderVsync;
4453
graphics.SynchronizeWithVerticalRetrace = renderVsync;
@@ -54,6 +63,20 @@ public ShipGameGame()
5463
protected override void Initialize()
5564
{
5665
base.Initialize();
66+
67+
// Update GameOptions with actual screen dimensions after device is created
68+
// This ensures resolution-dependent code uses the correct values on all platforms
69+
GameOptions.ScreenWidth = GraphicsDevice.PresentationParameters.BackBufferWidth;
70+
GameOptions.ScreenHeight = GraphicsDevice.PresentationParameters.BackBufferHeight;
71+
72+
// Scale glow resolution proportionally for lower-res devices
73+
// Keep at 512 for devices with width >= 1280, scale down for smaller screens
74+
if (GameOptions.ScreenWidth < 1280)
75+
{
76+
GameOptions.GlowResolution = (int)(512 * (GameOptions.ScreenWidth / 1280.0f));
77+
// Ensure minimum glow resolution of 256 for quality
78+
GameOptions.GlowResolution = Math.Max(256, GameOptions.GlowResolution);
79+
}
5780
}
5881

5982

ShipGame/ShipGame.DesktopGL/ShipGame.DesktopGL.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<ItemGroup>
1717
<MonoGameContentReference Include="..\ShipGame.Core\Content\ShipGame.mgcb">
1818
<Link>Content\ShipGame.mgcb</Link>
19+
<Platform>DesktopGL</Platform>
1920
</MonoGameContentReference>
2021
</ItemGroup>
2122
<ItemGroup>

ShipGame/ShipGame.WindowsDX/ShipGame.WindowsDX.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<ItemGroup>
2424
<MonoGameContentReference Include="..\ShipGame.Core\Content\ShipGame.mgcb">
2525
<Link>Content\ShipGame.mgcb</Link>
26+
<Platform>Windows</Platform>
2627
</MonoGameContentReference>
2728
</ItemGroup>
2829
<ItemGroup>

ShipGame/ShipGame.iOS/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<key>CFBundleIdentifier</key>
1212
<string>project.MonoGame.ShipGame.iOS</string>
1313
<key>MinimumOSVersion</key>
14-
<string>11.2</string>
14+
<string>12.2</string>
1515
<key>UISupportedInterfaceOrientations</key>
1616
<array>
1717
<string>UIInterfaceOrientationLandscapeLeft</string>

ShipGame/ShipGame.iOS/ShipGame.iOS.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFramework>net9.0-ios</TargetFramework>
44
<OutputType>Exe</OutputType>
5-
<SupportedOSPlatformVersion>11.2</SupportedOSPlatformVersion>
5+
<SupportedOSPlatformVersion>12.2</SupportedOSPlatformVersion>
66
<CodesignKey>iPhone Developer</CodesignKey>
77
</PropertyGroup>
88
<ItemGroup>
@@ -11,6 +11,7 @@
1111
<ItemGroup>
1212
<MonoGameContentReference Include="..\ShipGame.Core\Content\ShipGame.mgcb">
1313
<Link>Content\ShipGame.mgcb</Link>
14+
<Platform>iOS</Platform>
1415
</MonoGameContentReference>
1516
</ItemGroup>
1617
<ItemGroup>

0 commit comments

Comments
 (0)