refactor: Game1 to GamePong
This commit is contained in:
parent
5ef3d491c3
commit
283556d329
|
@ -41,20 +41,20 @@ public class CameraController : BehaviourOverride
|
||||||
|
|
||||||
private void SwitchToFullScreen(IButtonInputs<Keys> inputs, Keys keys)
|
private void SwitchToFullScreen(IButtonInputs<Keys> inputs, Keys keys)
|
||||||
{
|
{
|
||||||
if (Game1.graphics.IsFullScreen)
|
if (GamePong.graphics.IsFullScreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Game1.graphics.PreferMultiSampling = false;
|
GamePong.graphics.PreferMultiSampling = false;
|
||||||
Game1.graphics.PreferredBackBufferWidth = Game1.graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Width;
|
GamePong.graphics.PreferredBackBufferWidth = GamePong.graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Width;
|
||||||
Game1.graphics.PreferredBackBufferHeight = Game1.graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Height;
|
GamePong.graphics.PreferredBackBufferHeight = GamePong.graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Height;
|
||||||
Game1.graphics.IsFullScreen = true;
|
GamePong.graphics.IsFullScreen = true;
|
||||||
Game1.graphics.ApplyChanges();
|
GamePong.graphics.ApplyChanges();
|
||||||
|
|
||||||
float previousScreenSize = Math.Sqrt(Math.Sqr(cameraBehaviour.Viewport.Width) + Math.Sqr(cameraBehaviour.Viewport.Height));
|
float previousScreenSize = Math.Sqrt(Math.Sqr(cameraBehaviour.Viewport.Width) + Math.Sqr(cameraBehaviour.Viewport.Height));
|
||||||
float currentScreenSize = Math.Sqrt(Math.Sqr(Game1.graphics.GraphicsDevice.Viewport.Width) + Math.Sqr(Game1.graphics.GraphicsDevice.Viewport.Height));
|
float currentScreenSize = Math.Sqrt(Math.Sqr(GamePong.graphics.GraphicsDevice.Viewport.Width) + Math.Sqr(GamePong.graphics.GraphicsDevice.Viewport.Height));
|
||||||
defaultZoomLevel /= previousScreenSize / currentScreenSize;
|
defaultZoomLevel /= previousScreenSize / currentScreenSize;
|
||||||
cameraBehaviour.Zoom /= previousScreenSize / currentScreenSize;
|
cameraBehaviour.Zoom /= previousScreenSize / currentScreenSize;
|
||||||
cameraBehaviour.Viewport = Game1.graphics.GraphicsDevice.Viewport;
|
cameraBehaviour.Viewport = GamePong.graphics.GraphicsDevice.Viewport;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResetCamera(IButtonInputs<Keys> inputs, Keys keys)
|
private void ResetCamera(IButtonInputs<Keys> inputs, Keys keys)
|
||||||
|
|
|
@ -14,7 +14,7 @@ using Syntriax.Engine.Physics2D.Abstract;
|
||||||
|
|
||||||
namespace Pong;
|
namespace Pong;
|
||||||
|
|
||||||
public class Game1 : Game
|
public class GamePong : Game
|
||||||
{
|
{
|
||||||
public static GraphicsDeviceManager graphics = null!;
|
public static GraphicsDeviceManager graphics = null!;
|
||||||
public static IPhysicsEngine2D engine = null!;
|
public static IPhysicsEngine2D engine = null!;
|
||||||
|
@ -25,7 +25,7 @@ public class Game1 : Game
|
||||||
private MonoGameCameraBehaviour cameraBehaviour = null!;
|
private MonoGameCameraBehaviour cameraBehaviour = null!;
|
||||||
private PongManager pongManager;
|
private PongManager pongManager;
|
||||||
|
|
||||||
public Game1()
|
public GamePong()
|
||||||
{
|
{
|
||||||
engine = new PhysicsEngine2D
|
engine = new PhysicsEngine2D
|
||||||
{
|
{
|
|
@ -1,3 +1,3 @@
|
||||||
|
|
||||||
using var game = new Pong.Game1();
|
using var game = new Pong.GamePong();
|
||||||
game.Run();
|
game.Run();
|
||||||
|
|
Loading…
Reference in New Issue