chore: updated engine
This commit is contained in:
		
							
								
								
									
										0
									
								
								Game/.gitignore → .gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										0
									
								
								Game/.gitignore → .gitignore
									
									
									
									
										vendored
									
									
								
							
							
								
								
									
										2
									
								
								Engine
									
									
									
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								Engine
									
									
									
									
									
								
							 Submodule Engine updated: ef21cdf213...c135035d5b
									
								
							
							
								
								
									
										27
									
								
								Game/.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										27
									
								
								Game/.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							@@ -1,27 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
  // Use IntelliSense to learn about possible attributes.
 | 
					 | 
				
			||||||
  // Hover to view descriptions of existing attributes.
 | 
					 | 
				
			||||||
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
 | 
					 | 
				
			||||||
  "version": "0.2.0",
 | 
					 | 
				
			||||||
  "configurations": [
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      "name": ".NET Core Launch (console)",
 | 
					 | 
				
			||||||
      "type": "coreclr",
 | 
					 | 
				
			||||||
      "request": "launch",
 | 
					 | 
				
			||||||
      "preLaunchTask": "build",
 | 
					 | 
				
			||||||
      // If you have changed target frameworks, make sure to update the program path.
 | 
					 | 
				
			||||||
      "program": "${workspaceFolder}/bin/Debug/net8.0/${workspaceFolderBasename}.dll",
 | 
					 | 
				
			||||||
      "args": [],
 | 
					 | 
				
			||||||
      "cwd": "${workspaceFolder}",
 | 
					 | 
				
			||||||
      // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
 | 
					 | 
				
			||||||
      "console": "internalConsole",
 | 
					 | 
				
			||||||
      "stopAtEntry": false
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      "name": ".NET Core Attach",
 | 
					 | 
				
			||||||
      "type": "coreclr",
 | 
					 | 
				
			||||||
      "request": "attach",
 | 
					 | 
				
			||||||
      "processId": "${command:pickProcess}"
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  ]
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										7
									
								
								Game/.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								Game/.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							@@ -1,7 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
    "cSpell.words": [
 | 
					 | 
				
			||||||
        "AABB",
 | 
					 | 
				
			||||||
        "DAABB",
 | 
					 | 
				
			||||||
        "Syntriax"
 | 
					 | 
				
			||||||
    ]
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										15
									
								
								Game/.vscode/tasks.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								Game/.vscode/tasks.json
									
									
									
									
										vendored
									
									
								
							@@ -1,15 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
  "version": "2.0.0",
 | 
					 | 
				
			||||||
  "tasks": [
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      "type": "dotnet",
 | 
					 | 
				
			||||||
      "task": "build",
 | 
					 | 
				
			||||||
      "problemMatcher": ["$msCompile"],
 | 
					 | 
				
			||||||
      "group": {
 | 
					 | 
				
			||||||
        "kind": "build",
 | 
					 | 
				
			||||||
        "isDefault": true
 | 
					 | 
				
			||||||
      },
 | 
					 | 
				
			||||||
      "label": "build"
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  ]
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										168
									
								
								Game/GamePong.cs
									
									
									
									
									
								
							
							
						
						
									
										168
									
								
								Game/GamePong.cs
									
									
									
									
									
								
							@@ -1,168 +0,0 @@
 | 
				
			|||||||
using System;
 | 
					 | 
				
			||||||
using Microsoft.Xna.Framework;
 | 
					 | 
				
			||||||
using Microsoft.Xna.Framework.Graphics;
 | 
					 | 
				
			||||||
using Microsoft.Xna.Framework.Input;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using Pong.Behaviours;
 | 
					 | 
				
			||||||
using Apos.Shapes;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using Syntriax.Engine.Core;
 | 
					 | 
				
			||||||
using Syntriax.Engine.Core.Abstract;
 | 
					 | 
				
			||||||
using Syntriax.Engine.Physics2D;
 | 
					 | 
				
			||||||
using Syntriax.Engine.Physics2D.Primitives;
 | 
					 | 
				
			||||||
using Syntriax.Engine.Physics2D.Abstract;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace Pong;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class GamePong : Game
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    private readonly GraphicsDeviceManager graphics = null!;
 | 
					 | 
				
			||||||
    private IPhysicsEngine2D physicsEngine = null!;
 | 
					 | 
				
			||||||
    private SpriteBatch spriteBatch = null!;
 | 
					 | 
				
			||||||
    private ShapeBatch shapeBatch = null!;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private GameManager gameManager = null!;
 | 
					 | 
				
			||||||
    private BehaviourCollector<IDisplayableSprite> displayableCollector = null!;
 | 
					 | 
				
			||||||
    private BehaviourCollector<IDisplayableShape> displayableShapeCollector = null!;
 | 
					 | 
				
			||||||
    private MonoGameCamera2DBehaviour cameraBehaviour = null!;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private PongManagerBehaviour pongManager = null!;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private float physicsTimer = 0f;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public GamePong()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        graphics = new GraphicsDeviceManager(this)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            PreferredBackBufferWidth = 1024,
 | 
					 | 
				
			||||||
            PreferredBackBufferHeight = 576,
 | 
					 | 
				
			||||||
            GraphicsProfile = GraphicsProfile.HiDef
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Content.RootDirectory = "Content";
 | 
					 | 
				
			||||||
        IsMouseVisible = true;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    protected override void Initialize()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        // TODO: Add your initialization logic here
 | 
					 | 
				
			||||||
        gameManager = new();
 | 
					 | 
				
			||||||
        displayableCollector = new(gameManager);
 | 
					 | 
				
			||||||
        displayableShapeCollector = new(gameManager);
 | 
					 | 
				
			||||||
        physicsEngine = new PhysicsEngine2DCollector(gameManager) { IterationPerStep = 3 };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        gameManager.Initialize();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        base.Initialize();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    protected override void LoadContent()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        spriteBatch = new SpriteBatch(GraphicsDevice);
 | 
					 | 
				
			||||||
        shapeBatch = new ShapeBatch(GraphicsDevice, Content);
 | 
					 | 
				
			||||||
        SpriteFont spriteFont = Content.Load<SpriteFont>("UbuntuMono");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ////////////////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IGameObject gameObjectCamera = gameManager.InstantiateGameObject<GameObject>().SetGameObject("Camera"); ;
 | 
					 | 
				
			||||||
        gameObjectCamera.BehaviourController.AddBehaviour<CameraController>();
 | 
					 | 
				
			||||||
        cameraBehaviour = gameObjectCamera.BehaviourController.AddBehaviour<MonoGameCamera2DBehaviour>(graphics);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ////////////////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IGameObject gameObjectPongManager = gameManager.InstantiateGameObject<GameObject>().SetGameObject("Pong Game Manager");
 | 
					 | 
				
			||||||
        pongManager = gameObjectPongManager.BehaviourController.AddBehaviour<PongManagerBehaviour>(5);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ////////////////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IGameObject gameObjectBall = gameManager.InstantiateGameObject<GameObject>().SetGameObject("Ball");
 | 
					 | 
				
			||||||
        gameObjectBall.Transform.SetTransform(position: new Vector2D(0, 0f), scale: new Vector2D(10f, 10f));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        gameObjectBall.BehaviourController.AddBehaviour<CircleBehaviour>(new Circle(Vector2D.Zero, 1f));
 | 
					 | 
				
			||||||
        gameObjectBall.BehaviourController.AddBehaviour<BallBehaviour>();
 | 
					 | 
				
			||||||
        gameObjectBall.BehaviourController.AddBehaviour<RigidBody2D>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ////////////////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IGameObject gameObjectLeftPaddle = gameManager.InstantiateGameObject<GameObject>().SetGameObject("Left Paddle");
 | 
					 | 
				
			||||||
        gameObjectLeftPaddle.Transform.SetTransform(position: new Vector2D(-468f, 0f), scale: new Vector2D(15f, 60f));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        gameObjectLeftPaddle.BehaviourController.AddBehaviour<PaddleBehaviour>(Keys.W, Keys.S, 228f, -228f, 400f);
 | 
					 | 
				
			||||||
        gameObjectLeftPaddle.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape.Box);
 | 
					 | 
				
			||||||
        gameObjectLeftPaddle.BehaviourController.AddBehaviour<RigidBody2D>().IsStatic = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IGameObject gameObjectRightPaddle = gameManager.InstantiateGameObject<GameObject>().SetGameObject("Right Paddle");
 | 
					 | 
				
			||||||
        gameObjectRightPaddle.Transform.SetTransform(position: new Vector2D(468f, 0f), scale: new Vector2D(15f, 60f));
 | 
					 | 
				
			||||||
        gameObjectRightPaddle.BehaviourController.AddBehaviour<PaddleBehaviour>(Keys.Up, Keys.Down, 228f, -228f, 400f);
 | 
					 | 
				
			||||||
        gameObjectRightPaddle.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape.Box);
 | 
					 | 
				
			||||||
        gameObjectRightPaddle.BehaviourController.AddBehaviour<RigidBody2D>().IsStatic = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ////////////////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IGameObject gameObjectWallTop = gameManager.InstantiateGameObject<GameObject>().SetGameObject("Wall Top");
 | 
					 | 
				
			||||||
        gameObjectWallTop.Transform.SetTransform(position: new Vector2D(0f, 308f), scale: new Vector2D(552f, 20f));
 | 
					 | 
				
			||||||
        gameObjectWallTop.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape.Box);
 | 
					 | 
				
			||||||
        gameObjectWallTop.BehaviourController.AddBehaviour<RigidBody2D>().IsStatic = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IGameObject gameObjectWallBottom = gameManager.InstantiateGameObject<GameObject>().SetGameObject("Wall Bottom");
 | 
					 | 
				
			||||||
        gameObjectWallBottom.Transform.SetTransform(position: new Vector2D(0f, -308f), scale: new Vector2D(552f, 20f));
 | 
					 | 
				
			||||||
        gameObjectWallBottom.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape.Box);
 | 
					 | 
				
			||||||
        gameObjectWallBottom.BehaviourController.AddBehaviour<RigidBody2D>().IsStatic = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IGameObject gameObjectWallRight = gameManager.InstantiateGameObject<GameObject>().SetGameObject("Wall Right");
 | 
					 | 
				
			||||||
        gameObjectWallRight.Transform.SetTransform(position: new Vector2D(532f, 0f), scale: new Vector2D(20f, 328f));
 | 
					 | 
				
			||||||
        gameObjectWallRight.BehaviourController.AddBehaviour<WallScoreBehaviour>((Action)pongManager.ScoreToLeft);
 | 
					 | 
				
			||||||
        gameObjectWallRight.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape.Box);
 | 
					 | 
				
			||||||
        gameObjectWallRight.BehaviourController.AddBehaviour<RigidBody2D>().IsStatic = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IGameObject gameObjectWallLeft = gameManager.InstantiateGameObject<GameObject>().SetGameObject("Wall Left");
 | 
					 | 
				
			||||||
        gameObjectWallLeft.Transform.SetTransform(position: new Vector2D(-532f, 0f), scale: new Vector2D(20f, 328f));
 | 
					 | 
				
			||||||
        gameObjectWallLeft.BehaviourController.AddBehaviour<WallScoreBehaviour>((Action)pongManager.ScoreToRight);
 | 
					 | 
				
			||||||
        gameObjectWallLeft.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape.Box);
 | 
					 | 
				
			||||||
        gameObjectWallLeft.BehaviourController.AddBehaviour<RigidBody2D>().IsStatic = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ////////////////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IGameObject gameObjectLeftScoreText = gameManager.InstantiateGameObject<GameObject>().SetGameObject("Score Left");
 | 
					 | 
				
			||||||
        gameObjectLeftScoreText.Transform.SetTransform(position: new Vector2D(-250f, 250f), scale: Vector2D.One * .25f);
 | 
					 | 
				
			||||||
        gameObjectLeftScoreText.BehaviourController.AddBehaviour<TextScoreBehaviour>(true, spriteFont);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IGameObject gameObjectRightScoreText = gameManager.InstantiateGameObject<GameObject>().SetGameObject("Score Right");
 | 
					 | 
				
			||||||
        gameObjectRightScoreText.Transform.SetTransform(position: new Vector2D(250f, 250f), scale: Vector2D.One * .25f);
 | 
					 | 
				
			||||||
        gameObjectRightScoreText.BehaviourController.AddBehaviour<TextScoreBehaviour>(false, spriteFont);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    protected override void Update(GameTime gameTime)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
 | 
					 | 
				
			||||||
            Exit();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        gameManager.Update(gameTime.ToEngineTime());
 | 
					 | 
				
			||||||
        while (physicsTimer + 0.01f < gameTime.TotalGameTime.TotalMilliseconds * .001f)//seconds)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            physicsTimer += 0.01f;
 | 
					 | 
				
			||||||
            physicsEngine.Step(.01f);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        base.Update(gameTime);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    protected override void Draw(GameTime gameTime)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        GraphicsDevice.Clear(new Color() { R = 32, G = 32, B = 32 });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // TODO: Add your drawing code here
 | 
					 | 
				
			||||||
        gameManager.PreDraw();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        spriteBatch.Begin(SpriteSortMode.Deferred, transformMatrix: cameraBehaviour.MatrixTransform);
 | 
					 | 
				
			||||||
        foreach (var displayable in displayableCollector)
 | 
					 | 
				
			||||||
            displayable.Draw(spriteBatch);
 | 
					 | 
				
			||||||
        spriteBatch.End();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        shapeBatch.Begin(cameraBehaviour.MatrixTransform);
 | 
					 | 
				
			||||||
        foreach (var displayableShape in displayableShapeCollector)
 | 
					 | 
				
			||||||
            displayableShape.Draw(shapeBatch);
 | 
					 | 
				
			||||||
        shapeBatch.End();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        base.Draw(gameTime);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,3 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
using var game = new Pong.GamePong();
 | 
					 | 
				
			||||||
game.Run();
 | 
					 | 
				
			||||||
@@ -3,31 +3,31 @@
 | 
				
			|||||||
  "isRoot": true,
 | 
					  "isRoot": true,
 | 
				
			||||||
  "tools": {
 | 
					  "tools": {
 | 
				
			||||||
    "dotnet-mgcb": {
 | 
					    "dotnet-mgcb": {
 | 
				
			||||||
      "version": "3.8.1.303",
 | 
					      "version": "3.8.2.1105",
 | 
				
			||||||
      "commands": [
 | 
					      "commands": [
 | 
				
			||||||
        "mgcb"
 | 
					        "mgcb"
 | 
				
			||||||
      ]
 | 
					      ]
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "dotnet-mgcb-editor": {
 | 
					    "dotnet-mgcb-editor": {
 | 
				
			||||||
      "version": "3.8.1.303",
 | 
					      "version": "3.8.2.1105",
 | 
				
			||||||
      "commands": [
 | 
					      "commands": [
 | 
				
			||||||
        "mgcb-editor"
 | 
					        "mgcb-editor"
 | 
				
			||||||
      ]
 | 
					      ]
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "dotnet-mgcb-editor-linux": {
 | 
					    "dotnet-mgcb-editor-linux": {
 | 
				
			||||||
      "version": "3.8.1.303",
 | 
					      "version": "3.8.2.1105",
 | 
				
			||||||
      "commands": [
 | 
					      "commands": [
 | 
				
			||||||
        "mgcb-editor-linux"
 | 
					        "mgcb-editor-linux"
 | 
				
			||||||
      ]
 | 
					      ]
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "dotnet-mgcb-editor-windows": {
 | 
					    "dotnet-mgcb-editor-windows": {
 | 
				
			||||||
      "version": "3.8.1.303",
 | 
					      "version": "3.8.2.1105",
 | 
				
			||||||
      "commands": [
 | 
					      "commands": [
 | 
				
			||||||
        "mgcb-editor-windows"
 | 
					        "mgcb-editor-windows"
 | 
				
			||||||
      ]
 | 
					      ]
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "dotnet-mgcb-editor-mac": {
 | 
					    "dotnet-mgcb-editor-mac": {
 | 
				
			||||||
      "version": "3.8.1.303",
 | 
					      "version": "3.8.2.1105",
 | 
				
			||||||
      "commands": [
 | 
					      "commands": [
 | 
				
			||||||
        "mgcb-editor-mac"
 | 
					        "mgcb-editor-mac"
 | 
				
			||||||
      ]
 | 
					      ]
 | 
				
			||||||
							
								
								
									
										15
									
								
								Platforms/Desktop/Content/Content.mgcb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								Platforms/Desktop/Content/Content.mgcb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					#----------------------------- Global Properties ----------------------------#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/outputDir:bin/$(Platform)
 | 
				
			||||||
 | 
					/intermediateDir:obj/$(Platform)
 | 
				
			||||||
 | 
					/platform:DesktopGL
 | 
				
			||||||
 | 
					/config:
 | 
				
			||||||
 | 
					/profile:Reach
 | 
				
			||||||
 | 
					/compress:False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#-------------------------------- References --------------------------------#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#---------------------------------- Content ---------------------------------#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -6,6 +6,7 @@
 | 
				
			|||||||
    <PublishReadyToRun>false</PublishReadyToRun>
 | 
					    <PublishReadyToRun>false</PublishReadyToRun>
 | 
				
			||||||
    <TieredCompilation>false</TieredCompilation>
 | 
					    <TieredCompilation>false</TieredCompilation>
 | 
				
			||||||
    <Nullable>enable</Nullable>
 | 
					    <Nullable>enable</Nullable>
 | 
				
			||||||
 | 
					    <RootNamespace>Pong.Platforms.Desktop</RootNamespace>
 | 
				
			||||||
  </PropertyGroup>
 | 
					  </PropertyGroup>
 | 
				
			||||||
  <PropertyGroup>
 | 
					  <PropertyGroup>
 | 
				
			||||||
    <ApplicationManifest>app.manifest</ApplicationManifest>
 | 
					    <ApplicationManifest>app.manifest</ApplicationManifest>
 | 
				
			||||||
@@ -16,18 +17,28 @@
 | 
				
			|||||||
    <None Remove="Icon.bmp" />
 | 
					    <None Remove="Icon.bmp" />
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
    <EmbeddedResource Include="Icon.ico" />
 | 
					    <EmbeddedResource Include="Icon.ico">
 | 
				
			||||||
    <EmbeddedResource Include="Icon.bmp" />
 | 
					      <LogicalName>Icon.ico</LogicalName>
 | 
				
			||||||
 | 
					    </EmbeddedResource>
 | 
				
			||||||
 | 
					    <EmbeddedResource Include="Icon.bmp">
 | 
				
			||||||
 | 
					      <LogicalName>Icon.bmp</LogicalName>
 | 
				
			||||||
 | 
					    </EmbeddedResource>
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
    <PackageReference Include="Apos.Shapes" Version="0.2.3" />
 | 
					    <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.2.1105" />
 | 
				
			||||||
    <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303" />
 | 
					    <PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.2.1105" />
 | 
				
			||||||
    <PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.303" />
 | 
					 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
    <ProjectReference Include="..\Engine\Engine.Core\Engine.Core.csproj" />
 | 
					    <ProjectReference Include="../../Shared/Shared.csproj" />
 | 
				
			||||||
    <ProjectReference Include="..\Engine\Engine.Input\Engine.Input.csproj" />
 | 
					  </ItemGroup>
 | 
				
			||||||
    <ProjectReference Include="..\Engine\Engine.Physics2D\Engine.Physics2D.csproj" />
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <MonoGameContentReference Include="../../Shared/Content/Content.mgcb">
 | 
				
			||||||
 | 
					      <Link>Content/Content.mgcb</Link>
 | 
				
			||||||
 | 
					    </MonoGameContentReference>
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <ProjectReference Include="../../Shared/Shared.csproj" />
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
  <Target Name="RestoreDotnetTools" BeforeTargets="Restore">
 | 
					  <Target Name="RestoreDotnetTools" BeforeTargets="Restore">
 | 
				
			||||||
    <Message Text="Restoring dotnet tools" Importance="High" />
 | 
					    <Message Text="Restoring dotnet tools" Importance="High" />
 | 
				
			||||||
| 
		 Before Width: | Height: | Size: 256 KiB After Width: | Height: | Size: 256 KiB  | 
| 
		 Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 144 KiB  | 
@@ -4,14 +4,14 @@ using System.Collections.Generic;
 | 
				
			|||||||
using Microsoft.Xna.Framework.Input;
 | 
					using Microsoft.Xna.Framework.Input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using Syntriax.Engine.Core;
 | 
					using Syntriax.Engine.Core;
 | 
				
			||||||
using Syntriax.Engine.Input;
 | 
					using Syntriax.Engine.Systems.Input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Pong.Behaviours;
 | 
					namespace Pong.Platforms.Desktop;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class KeyboardInputsBehaviour : BehaviourOverride, IButtonInputs<Keys>
 | 
					public class KeyboardInputsBehaviour : Behaviour, IButtonInputs<Keys>
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    private readonly Dictionary<Keys, Action<IButtonInputs<Keys>, Keys>> OnPressed = new(256);
 | 
					    private readonly Dictionary<Keys, IButtonInputs<Keys>.ButtonCallbackEventHandler> OnPressed = new(256);
 | 
				
			||||||
    private readonly Dictionary<Keys, Action<IButtonInputs<Keys>, Keys>> OnReleased = new(256);
 | 
					    private readonly Dictionary<Keys, IButtonInputs<Keys>.ButtonCallbackEventHandler> OnReleased = new(256);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private int cachePressedCurrentlyCount = 0;
 | 
					    private int cachePressedCurrentlyCount = 0;
 | 
				
			||||||
    private readonly Keys[] cachePressedCurrently = new Keys[256];
 | 
					    private readonly Keys[] cachePressedCurrently = new Keys[256];
 | 
				
			||||||
@@ -19,7 +19,10 @@ public class KeyboardInputsBehaviour : BehaviourOverride, IButtonInputs<Keys>
 | 
				
			|||||||
    private int cachePressedPreviouslyCount = 0;
 | 
					    private int cachePressedPreviouslyCount = 0;
 | 
				
			||||||
    private readonly Keys[] cachePressedPreviously = new Keys[256];
 | 
					    private readonly Keys[] cachePressedPreviously = new Keys[256];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void RegisterOnPress(Keys key, Action<IButtonInputs<Keys>, Keys> callback)
 | 
					    public event IButtonInputs<Keys>.ButtonCallbackEventHandler? OnAnyButtonPressed = null;
 | 
				
			||||||
 | 
					    public event IButtonInputs<Keys>.ButtonCallbackEventHandler? OnAnyButtonReleased = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void RegisterOnPress(Keys key, IButtonInputs<Keys>.ButtonCallbackEventHandler callback)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (OnPressed.TryGetValue(key, out var action))
 | 
					        if (OnPressed.TryGetValue(key, out var action))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -30,13 +33,13 @@ public class KeyboardInputsBehaviour : BehaviourOverride, IButtonInputs<Keys>
 | 
				
			|||||||
        OnPressed.Add(key, callback);
 | 
					        OnPressed.Add(key, callback);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void UnregisterOnPress(Keys key, Action<IButtonInputs<Keys>, Keys> callback)
 | 
					    public void UnregisterOnPress(Keys key, IButtonInputs<Keys>.ButtonCallbackEventHandler callback)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (OnPressed.TryGetValue(key, out var action))
 | 
					        if (OnPressed.TryGetValue(key, out var action))
 | 
				
			||||||
            action -= callback;
 | 
					            action -= callback;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void RegisterOnRelease(Keys key, Action<IButtonInputs<Keys>, Keys> callback)
 | 
					    public void RegisterOnRelease(Keys key, IButtonInputs<Keys>.ButtonCallbackEventHandler callback)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (OnReleased.TryGetValue(key, out var action))
 | 
					        if (OnReleased.TryGetValue(key, out var action))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -47,7 +50,7 @@ public class KeyboardInputsBehaviour : BehaviourOverride, IButtonInputs<Keys>
 | 
				
			|||||||
        OnReleased.Add(key, callback);
 | 
					        OnReleased.Add(key, callback);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void UnregisterOnRelease(Keys key, Action<IButtonInputs<Keys>, Keys> callback)
 | 
					    public void UnregisterOnRelease(Keys key, IButtonInputs<Keys>.ButtonCallbackEventHandler callback)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (OnReleased.TryGetValue(key, out var action))
 | 
					        if (OnReleased.TryGetValue(key, out var action))
 | 
				
			||||||
            action -= callback;
 | 
					            action -= callback;
 | 
				
			||||||
@@ -70,6 +73,7 @@ public class KeyboardInputsBehaviour : BehaviourOverride, IButtonInputs<Keys>
 | 
				
			|||||||
                continue;
 | 
					                continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            action.Invoke(this, currentlyPressedKey);
 | 
					            action.Invoke(this, currentlyPressedKey);
 | 
				
			||||||
 | 
					            OnAnyButtonPressed?.Invoke(this, currentlyPressedKey);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < cachePressedPreviouslyCount; i++)
 | 
					        for (int i = 0; i < cachePressedPreviouslyCount; i++)
 | 
				
			||||||
@@ -83,6 +87,7 @@ public class KeyboardInputsBehaviour : BehaviourOverride, IButtonInputs<Keys>
 | 
				
			|||||||
                continue;
 | 
					                continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            action.Invoke(this, previouslyPressedKey);
 | 
					            action.Invoke(this, previouslyPressedKey);
 | 
				
			||||||
 | 
					            OnAnyButtonReleased?.Invoke(this, previouslyPressedKey);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Array.Copy(cachePressedCurrently, cachePressedPreviously, cachePressedCurrentlyCount);
 | 
					        Array.Copy(cachePressedCurrently, cachePressedPreviously, cachePressedCurrentlyCount);
 | 
				
			||||||
							
								
								
									
										7
									
								
								Platforms/Desktop/Program.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								Platforms/Desktop/Program.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					using Pong.Platforms.Desktop;
 | 
				
			||||||
 | 
					using Syntriax.Engine.Core;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Syntriax.Engine.Core.Abstract.IHierarchyObject hierarchyObject = Syntriax.Engine.Core.Factory.HierarchyObjectFactory.Instantiate().SetHierarchyObject("Desktop HO");
 | 
				
			||||||
 | 
					hierarchyObject.BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
 | 
				
			||||||
 | 
					using var game = new Pong.GamePong(hierarchyObject);
 | 
				
			||||||
 | 
					game.Run();
 | 
				
			||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="utf-8"?>
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
 | 
					<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
 | 
				
			||||||
  <assemblyIdentity version="1.0.0.0" name="Game"/>
 | 
					  <assemblyIdentity version="1.0.0.0" name="Desktop"/>
 | 
				
			||||||
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
 | 
					  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
 | 
				
			||||||
    <security>
 | 
					    <security>
 | 
				
			||||||
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
 | 
					      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
 | 
				
			||||||
							
								
								
									
										48
									
								
								Pong.sln
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								Pong.sln
									
									
									
									
									
								
							@@ -7,41 +7,57 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engine", "Engine", "{F7F626
 | 
				
			|||||||
EndProject
 | 
					EndProject
 | 
				
			||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Core", "Engine\Engine.Core\Engine.Core.csproj", "{990CA10C-1EBB-4395-A43A-456B7029D8C9}"
 | 
					Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Core", "Engine\Engine.Core\Engine.Core.csproj", "{990CA10C-1EBB-4395-A43A-456B7029D8C9}"
 | 
				
			||||||
EndProject
 | 
					EndProject
 | 
				
			||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Game", "Game\Game.csproj", "{500E1B05-39D7-4232-8051-E7351D745306}"
 | 
					 | 
				
			||||||
EndProject
 | 
					 | 
				
			||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Input", "Engine\Engine.Input\Engine.Input.csproj", "{7EED4EC3-79D5-4C6C-A54D-1B396213C0E4}"
 | 
					 | 
				
			||||||
EndProject
 | 
					 | 
				
			||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Physics2D", "Engine\Engine.Physics2D\Engine.Physics2D.csproj", "{0D97F83C-B043-48B1-B155-7354C4E84FC0}"
 | 
					Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Physics2D", "Engine\Engine.Physics2D\Engine.Physics2D.csproj", "{0D97F83C-B043-48B1-B155-7354C4E84FC0}"
 | 
				
			||||||
EndProject
 | 
					EndProject
 | 
				
			||||||
 | 
					Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine", "Engine\Engine\Engine.csproj", "{2F6B1E26-1217-4EFD-874C-05ADEE4C7969}"
 | 
				
			||||||
 | 
					EndProject
 | 
				
			||||||
 | 
					Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}"
 | 
				
			||||||
 | 
					EndProject
 | 
				
			||||||
 | 
					Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platforms", "Platforms", "{FECFFD54-338F-4060-9161-1E5770D1DC33}"
 | 
				
			||||||
 | 
					EndProject
 | 
				
			||||||
 | 
					Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Desktop", "Platforms\Desktop\Desktop.csproj", "{2B627F66-5A61-4F69-B479-62EEAB603D01}"
 | 
				
			||||||
 | 
					EndProject
 | 
				
			||||||
 | 
					Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Systems", "Engine\Engine.Systems\Engine.Systems.csproj", "{8863A1BA-2E83-419F-BACB-D4A4156EC71C}"
 | 
				
			||||||
 | 
					EndProject
 | 
				
			||||||
Global
 | 
					Global
 | 
				
			||||||
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
						GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
				
			||||||
		Debug|Any CPU = Debug|Any CPU
 | 
							Debug|Any CPU = Debug|Any CPU
 | 
				
			||||||
		Release|Any CPU = Release|Any CPU
 | 
							Release|Any CPU = Release|Any CPU
 | 
				
			||||||
	EndGlobalSection
 | 
						EndGlobalSection
 | 
				
			||||||
	GlobalSection(SolutionProperties) = preSolution
 | 
					 | 
				
			||||||
		HideSolutionNode = FALSE
 | 
					 | 
				
			||||||
	EndGlobalSection
 | 
					 | 
				
			||||||
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 | 
						GlobalSection(ProjectConfigurationPlatforms) = postSolution
 | 
				
			||||||
		{990CA10C-1EBB-4395-A43A-456B7029D8C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
							{990CA10C-1EBB-4395-A43A-456B7029D8C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
				
			||||||
		{990CA10C-1EBB-4395-A43A-456B7029D8C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
							{990CA10C-1EBB-4395-A43A-456B7029D8C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
				
			||||||
		{990CA10C-1EBB-4395-A43A-456B7029D8C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
							{990CA10C-1EBB-4395-A43A-456B7029D8C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
				
			||||||
		{990CA10C-1EBB-4395-A43A-456B7029D8C9}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
							{990CA10C-1EBB-4395-A43A-456B7029D8C9}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
				
			||||||
		{500E1B05-39D7-4232-8051-E7351D745306}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
					 | 
				
			||||||
		{500E1B05-39D7-4232-8051-E7351D745306}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
					 | 
				
			||||||
		{500E1B05-39D7-4232-8051-E7351D745306}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
					 | 
				
			||||||
		{500E1B05-39D7-4232-8051-E7351D745306}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
					 | 
				
			||||||
		{7EED4EC3-79D5-4C6C-A54D-1B396213C0E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
					 | 
				
			||||||
		{7EED4EC3-79D5-4C6C-A54D-1B396213C0E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
					 | 
				
			||||||
		{7EED4EC3-79D5-4C6C-A54D-1B396213C0E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
					 | 
				
			||||||
		{7EED4EC3-79D5-4C6C-A54D-1B396213C0E4}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
					 | 
				
			||||||
		{0D97F83C-B043-48B1-B155-7354C4E84FC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
							{0D97F83C-B043-48B1-B155-7354C4E84FC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
				
			||||||
		{0D97F83C-B043-48B1-B155-7354C4E84FC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
							{0D97F83C-B043-48B1-B155-7354C4E84FC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
				
			||||||
		{0D97F83C-B043-48B1-B155-7354C4E84FC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
							{0D97F83C-B043-48B1-B155-7354C4E84FC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
				
			||||||
		{0D97F83C-B043-48B1-B155-7354C4E84FC0}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
							{0D97F83C-B043-48B1-B155-7354C4E84FC0}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
				
			||||||
 | 
							{2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
				
			||||||
 | 
							{2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
				
			||||||
 | 
							{2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
				
			||||||
 | 
							{2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
				
			||||||
 | 
							{590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
				
			||||||
 | 
							{590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
				
			||||||
 | 
							{590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
				
			||||||
 | 
							{590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
				
			||||||
 | 
							{2B627F66-5A61-4F69-B479-62EEAB603D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
				
			||||||
 | 
							{2B627F66-5A61-4F69-B479-62EEAB603D01}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
				
			||||||
 | 
							{2B627F66-5A61-4F69-B479-62EEAB603D01}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
				
			||||||
 | 
							{2B627F66-5A61-4F69-B479-62EEAB603D01}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
				
			||||||
 | 
							{8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
				
			||||||
 | 
							{8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
				
			||||||
 | 
							{8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
				
			||||||
 | 
							{8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
				
			||||||
 | 
						EndGlobalSection
 | 
				
			||||||
 | 
						GlobalSection(SolutionProperties) = preSolution
 | 
				
			||||||
 | 
							HideSolutionNode = FALSE
 | 
				
			||||||
	EndGlobalSection
 | 
						EndGlobalSection
 | 
				
			||||||
	GlobalSection(NestedProjects) = preSolution
 | 
						GlobalSection(NestedProjects) = preSolution
 | 
				
			||||||
		{990CA10C-1EBB-4395-A43A-456B7029D8C9} = {F7F62670-237A-4C93-A30E-CE661C6FC401}
 | 
							{990CA10C-1EBB-4395-A43A-456B7029D8C9} = {F7F62670-237A-4C93-A30E-CE661C6FC401}
 | 
				
			||||||
		{7EED4EC3-79D5-4C6C-A54D-1B396213C0E4} = {F7F62670-237A-4C93-A30E-CE661C6FC401}
 | 
					 | 
				
			||||||
		{0D97F83C-B043-48B1-B155-7354C4E84FC0} = {F7F62670-237A-4C93-A30E-CE661C6FC401}
 | 
							{0D97F83C-B043-48B1-B155-7354C4E84FC0} = {F7F62670-237A-4C93-A30E-CE661C6FC401}
 | 
				
			||||||
 | 
							{2F6B1E26-1217-4EFD-874C-05ADEE4C7969} = {F7F62670-237A-4C93-A30E-CE661C6FC401}
 | 
				
			||||||
 | 
							{2B627F66-5A61-4F69-B479-62EEAB603D01} = {FECFFD54-338F-4060-9161-1E5770D1DC33}
 | 
				
			||||||
 | 
							{8863A1BA-2E83-419F-BACB-D4A4156EC71C} = {F7F62670-237A-4C93-A30E-CE661C6FC401}
 | 
				
			||||||
	EndGlobalSection
 | 
						EndGlobalSection
 | 
				
			||||||
EndGlobal
 | 
					EndGlobal
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										36
									
								
								Shared/.config/dotnet-tools.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								Shared/.config/dotnet-tools.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "version": 1,
 | 
				
			||||||
 | 
					  "isRoot": true,
 | 
				
			||||||
 | 
					  "tools": {
 | 
				
			||||||
 | 
					    "dotnet-mgcb": {
 | 
				
			||||||
 | 
					      "version": "3.8.2.1105",
 | 
				
			||||||
 | 
					      "commands": [
 | 
				
			||||||
 | 
					        "mgcb"
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "dotnet-mgcb-editor": {
 | 
				
			||||||
 | 
					      "version": "3.8.2.1105",
 | 
				
			||||||
 | 
					      "commands": [
 | 
				
			||||||
 | 
					        "mgcb-editor"
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "dotnet-mgcb-editor-linux": {
 | 
				
			||||||
 | 
					      "version": "3.8.2.1105",
 | 
				
			||||||
 | 
					      "commands": [
 | 
				
			||||||
 | 
					        "mgcb-editor-linux"
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "dotnet-mgcb-editor-windows": {
 | 
				
			||||||
 | 
					      "version": "3.8.2.1105",
 | 
				
			||||||
 | 
					      "commands": [
 | 
				
			||||||
 | 
					        "mgcb-editor-windows"
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "dotnet-mgcb-editor-mac": {
 | 
				
			||||||
 | 
					      "version": "3.8.2.1105",
 | 
				
			||||||
 | 
					      "commands": [
 | 
				
			||||||
 | 
					        "mgcb-editor-mac"
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -6,7 +6,7 @@ using Syntriax.Engine.Physics2D.Abstract;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Pong.Behaviours;
 | 
					namespace Pong.Behaviours;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class BallBehaviour : BehaviourOverride
 | 
					public class BallBehaviour : Behaviour2D
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public Vector2D StartDirection { get; private set; } = Vector2D.Zero;
 | 
					    public Vector2D StartDirection { get; private set; } = Vector2D.Zero;
 | 
				
			||||||
    public float Speed { get; set; } = 500f;
 | 
					    public float Speed { get; set; } = 500f;
 | 
				
			||||||
@@ -18,15 +18,15 @@ public class BallBehaviour : BehaviourOverride
 | 
				
			|||||||
    protected override void OnFirstActiveFrame()
 | 
					    protected override void OnFirstActiveFrame()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (!BehaviourController.TryGetBehaviour(out IRigidBody2D? foundRigidBody))
 | 
					        if (!BehaviourController.TryGetBehaviour(out IRigidBody2D? foundRigidBody))
 | 
				
			||||||
            throw new Exception($"{nameof(IRigidBody2D)} is missing on {GameObject.Name}.");
 | 
					            throw new Exception($"{nameof(IRigidBody2D)} is missing on {HierarchyObject.Name}.");
 | 
				
			||||||
        if (!BehaviourController.TryGetBehaviour(out ICollider2D? foundCollider))
 | 
					        if (!BehaviourController.TryGetBehaviour(out ICollider2D? foundCollider))
 | 
				
			||||||
            throw new Exception($"{nameof(ICollider2D)} is missing on {GameObject.Name}.");
 | 
					            throw new Exception($"{nameof(ICollider2D)} is missing on {HierarchyObject.Name}.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foundCollider.OnCollisionDetected += OnCollisionDetected;
 | 
					        foundCollider.OnCollisionDetected += OnCollisionDetected;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        rigidBody = foundRigidBody;
 | 
					        rigidBody = foundRigidBody;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (GameObject.GameManager.TryFindBehaviour(out PongManagerBehaviour? pongManager))
 | 
					        if (HierarchyObject.GameManager.TryFindBehaviour(out PongManagerBehaviour? pongManager))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            pongManager.OnReset += ResetBall;
 | 
					            pongManager.OnReset += ResetBall;
 | 
				
			||||||
            pongManager.OnScored += ResetBall;
 | 
					            pongManager.OnScored += ResetBall;
 | 
				
			||||||
@@ -36,14 +36,14 @@ public class BallBehaviour : BehaviourOverride
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private void DisableBall(PongManagerBehaviour pongManager)
 | 
					    private void DisableBall(PongManagerBehaviour pongManager)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        BehaviourController.GameObject.Transform.Position = Vector2D.Zero;
 | 
					        Transform.Position = Vector2D.Zero;
 | 
				
			||||||
        rigidBody.Velocity = Vector2D.Zero;
 | 
					        rigidBody.Velocity = Vector2D.Zero;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void ResetBall(PongManagerBehaviour pongManager)
 | 
					    private void ResetBall(PongManagerBehaviour pongManager)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        StateEnable.Enabled = true;
 | 
					        StateEnable.Enabled = true;
 | 
				
			||||||
        BehaviourController.GameObject.Transform.Position = Vector2D.Zero;
 | 
					        Transform.Position = Vector2D.Zero;
 | 
				
			||||||
        rigidBody.Velocity = GetRandomDirection() * Speed;
 | 
					        rigidBody.Velocity = GetRandomDirection() * Speed;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -60,14 +60,14 @@ public class BallBehaviour : BehaviourOverride
 | 
				
			|||||||
        if (rigidBody.Velocity.MagnitudeSquared <= 0.01f)
 | 
					        if (rigidBody.Velocity.MagnitudeSquared <= 0.01f)
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Vector2D speedUp = rigidBody.Velocity.Normalized * Time.DeltaTimeFrame;
 | 
					        Vector2D speedUp = rigidBody.Velocity.Normalized * GameManager.Time.DeltaTime;
 | 
				
			||||||
        rigidBody.Velocity += speedUp * SpeedUpMultiplier;
 | 
					        rigidBody.Velocity += speedUp * SpeedUpMultiplier;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void OnCollisionDetected(ICollider2D collider2D, CollisionDetectionInformation information)
 | 
					    private void OnCollisionDetected(ICollider2D collider2D, CollisionDetectionInformation information)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (Syntriax.Engine.Core.Math.Abs(information.Normal.Dot(Vector2D.Right)) > .25)
 | 
					        if (Syntriax.Engine.Core.Math.Abs(information.Normal.Dot(Vector2D.Right)) > .25)
 | 
				
			||||||
            rigidBody.Velocity = information.Left.Transform.Position.FromTo(information.Right.Transform.Position).Normalized * rigidBody.Velocity.Magnitude;
 | 
					            rigidBody.Velocity = information.Detected.Transform.Position.FromTo(information.Detector.Transform.Position).Normalized * rigidBody.Velocity.Magnitude;
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            rigidBody.Velocity = rigidBody.Velocity.Reflect(information.Normal);
 | 
					            rigidBody.Velocity = rigidBody.Velocity.Reflect(information.Normal);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -1,11 +1,11 @@
 | 
				
			|||||||
using Microsoft.Xna.Framework.Input;
 | 
					using Microsoft.Xna.Framework.Input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using Syntriax.Engine.Core;
 | 
					using Syntriax.Engine.Core;
 | 
				
			||||||
using Syntriax.Engine.Input;
 | 
					using Syntriax.Engine.Systems.Input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Pong.Behaviours;
 | 
					namespace Pong.Behaviours;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class CameraController : BehaviourOverride
 | 
					public class CameraController : Behaviour
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    private MonoGameCamera2DBehaviour cameraBehaviour = null!;
 | 
					    private MonoGameCamera2DBehaviour cameraBehaviour = null!;
 | 
				
			||||||
    private IButtonInputs<Keys> buttonInputs = null!;
 | 
					    private IButtonInputs<Keys> buttonInputs = null!;
 | 
				
			||||||
@@ -19,10 +19,7 @@ public class CameraController : BehaviourOverride
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        cameraBehaviour ??= BehaviourController.AddBehaviour<MonoGameCamera2DBehaviour>();
 | 
					        cameraBehaviour ??= BehaviourController.AddBehaviour<MonoGameCamera2DBehaviour>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (BehaviourController.TryGetBehaviour(out IButtonInputs<Keys>? foundButtonInputs))
 | 
					        buttonInputs = GameManager.FindBehaviour<IButtonInputs<Keys>>() ?? throw new("Unable to find inputs");
 | 
				
			||||||
            buttonInputs = foundButtonInputs;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        buttonInputs ??= BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
 | 
					 | 
				
			||||||
        buttonInputs.RegisterOnPress(Keys.F, SwitchToFullScreen);
 | 
					        buttonInputs.RegisterOnPress(Keys.F, SwitchToFullScreen);
 | 
				
			||||||
        buttonInputs.RegisterOnPress(Keys.R, ResetCamera);
 | 
					        buttonInputs.RegisterOnPress(Keys.R, ResetCamera);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -30,21 +27,21 @@ public class CameraController : BehaviourOverride
 | 
				
			|||||||
    protected override void OnUpdate()
 | 
					    protected override void OnUpdate()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (buttonInputs.IsPressed(Keys.U))
 | 
					        if (buttonInputs.IsPressed(Keys.U))
 | 
				
			||||||
            cameraBehaviour.Zoom += Time.Elapsed.Nanoseconds * 0.00025f;
 | 
					            cameraBehaviour.Zoom += GameManager.Time.DeltaTime * 5f;
 | 
				
			||||||
        if (buttonInputs.IsPressed(Keys.J))
 | 
					        if (buttonInputs.IsPressed(Keys.J))
 | 
				
			||||||
            cameraBehaviour.Zoom -= Time.Elapsed.Nanoseconds * 0.00025f;
 | 
					            cameraBehaviour.Zoom -= GameManager.Time.DeltaTime * 5f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (buttonInputs.IsPressed(Keys.NumPad8)) cameraBehaviour.BehaviourController.GameObject.Transform.Position += Vector2D.Up.Rotate(Transform.Rotation * Math.DegreeToRadian) * Time.DeltaTimeFrame;
 | 
					        if (buttonInputs.IsPressed(Keys.NumPad8)) cameraBehaviour.Transform.LocalPosition += Vector2D.Up * GameManager.Time.DeltaTime * 500f;
 | 
				
			||||||
        if (buttonInputs.IsPressed(Keys.NumPad2)) cameraBehaviour.BehaviourController.GameObject.Transform.Position -= Vector2D.Up.Rotate(Transform.Rotation * Math.DegreeToRadian) * Time.DeltaTimeFrame;
 | 
					        if (buttonInputs.IsPressed(Keys.NumPad2)) cameraBehaviour.Transform.LocalPosition -= Vector2D.Up * GameManager.Time.DeltaTime * 500f;
 | 
				
			||||||
        if (buttonInputs.IsPressed(Keys.NumPad6)) cameraBehaviour.BehaviourController.GameObject.Transform.Position += Vector2D.Right.Rotate(Transform.Rotation * Math.DegreeToRadian) * Time.DeltaTimeFrame;
 | 
					        if (buttonInputs.IsPressed(Keys.NumPad6)) cameraBehaviour.Transform.LocalPosition += Vector2D.Right * GameManager.Time.DeltaTime * 500f;
 | 
				
			||||||
        if (buttonInputs.IsPressed(Keys.NumPad4)) cameraBehaviour.BehaviourController.GameObject.Transform.Position -= Vector2D.Right.Rotate(Transform.Rotation * Math.DegreeToRadian) * Time.DeltaTimeFrame;
 | 
					        if (buttonInputs.IsPressed(Keys.NumPad4)) cameraBehaviour.Transform.LocalPosition -= Vector2D.Right * GameManager.Time.DeltaTime * 500f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (buttonInputs.IsPressed(Keys.Q))
 | 
					        if (buttonInputs.IsPressed(Keys.Q))
 | 
				
			||||||
            cameraBehaviour.BehaviourController.GameObject.Transform.Rotation += Time.Elapsed.Nanoseconds * 0.0025f;
 | 
					            cameraBehaviour.Transform.Rotation += GameManager.Time.DeltaTime * 45f;
 | 
				
			||||||
        if (buttonInputs.IsPressed(Keys.E))
 | 
					        if (buttonInputs.IsPressed(Keys.E))
 | 
				
			||||||
            cameraBehaviour.BehaviourController.GameObject.Transform.Rotation -= Time.Elapsed.Nanoseconds * 0.0025f;
 | 
					            cameraBehaviour.Transform.Rotation -= GameManager.Time.DeltaTime * 45f;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void SwitchToFullScreen(IButtonInputs<Keys> inputs, Keys keys)
 | 
					    private void SwitchToFullScreen(IButtonInputs<Keys> inputs, Keys keys)
 | 
				
			||||||
@@ -68,7 +65,7 @@ public class CameraController : BehaviourOverride
 | 
				
			|||||||
    private void ResetCamera(IButtonInputs<Keys> inputs, Keys keys)
 | 
					    private void ResetCamera(IButtonInputs<Keys> inputs, Keys keys)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        cameraBehaviour.Zoom = defaultZoomLevel;
 | 
					        cameraBehaviour.Zoom = defaultZoomLevel;
 | 
				
			||||||
        Transform.Position = Vector2D.Zero;
 | 
					        cameraBehaviour.Transform.LocalPosition = Vector2D.Zero;
 | 
				
			||||||
        Transform.Rotation = 0f;
 | 
					        cameraBehaviour.Transform.LocalRotation = 0f;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -2,8 +2,8 @@ using Microsoft.Xna.Framework;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
using Apos.Shapes;
 | 
					using Apos.Shapes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using Syntriax.Engine.Core;
 | 
				
			||||||
using Syntriax.Engine.Core.Abstract;
 | 
					using Syntriax.Engine.Core.Abstract;
 | 
				
			||||||
using Syntriax.Engine.Physics2D.Primitives;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Pong.Behaviours;
 | 
					namespace Pong.Behaviours;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -6,7 +6,7 @@ using Syntriax.Engine.Core.Abstract;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Pong.Behaviours;
 | 
					namespace Pong.Behaviours;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class MonoGameCamera2DBehaviour(GraphicsDeviceManager Graphics) : BehaviourOverride, ICamera2D
 | 
					public class MonoGameCamera2DBehaviour(GraphicsDeviceManager Graphics) : Behaviour2D, ICamera2D
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public event OnMatrixTransformChangedDelegate? OnMatrixTransformChanged = null;
 | 
					    public event OnMatrixTransformChangedDelegate? OnMatrixTransformChanged = null;
 | 
				
			||||||
    public event OnViewportChangedDelegate? OnViewportChanged = null;
 | 
					    public event OnViewportChangedDelegate? OnViewportChanged = null;
 | 
				
			||||||
@@ -72,10 +72,6 @@ public class MonoGameCamera2DBehaviour(GraphicsDeviceManager Graphics) : Behavio
 | 
				
			|||||||
        set => Transform.Rotation = value;
 | 
					        set => Transform.Rotation = value;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public event IAssignableTransform.OnTransformAssignedDelegate? OnTransformAssigned { add => GameObject.OnTransformAssigned += value; remove => GameObject.OnTransformAssigned -= value; }
 | 
					 | 
				
			||||||
    ITransform IAssignableTransform.Transform => GameObject.Transform;
 | 
					 | 
				
			||||||
    bool IAssignableTransform.Assign(ITransform transform) => GameObject.Assign(transform);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // TODO This causes delay since OnPreDraw calls assuming this is called in in Update 
 | 
					    // TODO This causes delay since OnPreDraw calls assuming this is called in in Update 
 | 
				
			||||||
    public Vector2D ScreenToWorldPosition(Vector2D screenPosition)
 | 
					    public Vector2D ScreenToWorldPosition(Vector2D screenPosition)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -6,7 +6,7 @@ using Syntriax.Engine.Physics2D.Abstract;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Pong.Behaviours;
 | 
					namespace Pong.Behaviours;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class MovementBallBehaviour : BehaviourOverride
 | 
					public class MovementBallBehaviour : Behaviour2D
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public Vector2D StartDirection { get; private set; } = Vector2D.Zero;
 | 
					    public Vector2D StartDirection { get; private set; } = Vector2D.Zero;
 | 
				
			||||||
    public float Speed { get; set; } = 500f;
 | 
					    public float Speed { get; set; } = 500f;
 | 
				
			||||||
@@ -17,9 +17,9 @@ public class MovementBallBehaviour : BehaviourOverride
 | 
				
			|||||||
    protected override void OnFirstActiveFrame()
 | 
					    protected override void OnFirstActiveFrame()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (!BehaviourController.TryGetBehaviour(out IRigidBody2D? foundRigidBody))
 | 
					        if (!BehaviourController.TryGetBehaviour(out IRigidBody2D? foundRigidBody))
 | 
				
			||||||
            throw new Exception($"{nameof(IRigidBody2D)} is missing on {GameObject.Name}.");
 | 
					            throw new Exception($"{nameof(IRigidBody2D)} is missing on {HierarchyObject.Name}.");
 | 
				
			||||||
        if (!BehaviourController.TryGetBehaviour(out ICollider2D? foundCollider))
 | 
					        if (!BehaviourController.TryGetBehaviour(out ICollider2D? foundCollider))
 | 
				
			||||||
            throw new Exception($"{nameof(ICollider2D)} is missing on {GameObject.Name}.");
 | 
					            throw new Exception($"{nameof(ICollider2D)} is missing on {HierarchyObject.Name}.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foundRigidBody.Velocity = StartDirection * Speed;
 | 
					        foundRigidBody.Velocity = StartDirection * Speed;
 | 
				
			||||||
        foundCollider.OnCollisionDetected += OnCollisionDetected;
 | 
					        foundCollider.OnCollisionDetected += OnCollisionDetected;
 | 
				
			||||||
@@ -32,14 +32,14 @@ public class MovementBallBehaviour : BehaviourOverride
 | 
				
			|||||||
        if (rigidBody.Velocity.MagnitudeSquared <= 0.01f)
 | 
					        if (rigidBody.Velocity.MagnitudeSquared <= 0.01f)
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Vector2D speedUp = rigidBody.Velocity.Normalized * Time.DeltaTimeFrame;
 | 
					        Vector2D speedUp = rigidBody.Velocity.Normalized * GameManager.Time.DeltaTime;
 | 
				
			||||||
        rigidBody.Velocity += speedUp * SpeedUpMultiplier;
 | 
					        rigidBody.Velocity += speedUp * SpeedUpMultiplier;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void OnCollisionDetected(ICollider2D collider2D, CollisionDetectionInformation information)
 | 
					    private void OnCollisionDetected(ICollider2D collider2D, CollisionDetectionInformation information)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (Syntriax.Engine.Core.Math.Abs(information.Normal.Dot(Vector2D.Right)) > .25)
 | 
					        if (Syntriax.Engine.Core.Math.Abs(information.Normal.Dot(Vector2D.Right)) > .25)
 | 
				
			||||||
            rigidBody.Velocity = information.Left.Transform.Position.FromTo(information.Right.Transform.Position).Normalized * rigidBody.Velocity.Magnitude;
 | 
					            rigidBody.Velocity = information.Detector.Transform.Position.FromTo(information.Detected.Transform.Position).Normalized * rigidBody.Velocity.Magnitude;
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            rigidBody.Velocity = rigidBody.Velocity.Reflect(information.Normal);
 | 
					            rigidBody.Velocity = rigidBody.Velocity.Reflect(information.Normal);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -3,11 +3,11 @@ using System;
 | 
				
			|||||||
using Microsoft.Xna.Framework.Input;
 | 
					using Microsoft.Xna.Framework.Input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using Syntriax.Engine.Core;
 | 
					using Syntriax.Engine.Core;
 | 
				
			||||||
using Syntriax.Engine.Input;
 | 
					using Syntriax.Engine.Systems.Input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Pong.Behaviours;
 | 
					namespace Pong.Behaviours;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class PaddleBehaviour(Keys Up, Keys Down, float High, float Low, float Speed) : BehaviourOverride
 | 
					public class PaddleBehaviour(Keys Up, Keys Down, float High, float Low, float Speed) : Behaviour2D
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    private Keys Up { get; } = Up;
 | 
					    private Keys Up { get; } = Up;
 | 
				
			||||||
    private Keys Down { get; } = Down;
 | 
					    private Keys Down { get; } = Down;
 | 
				
			||||||
@@ -26,17 +26,16 @@ public class PaddleBehaviour(Keys Up, Keys Down, float High, float Low, float Sp
 | 
				
			|||||||
            return;
 | 
					            return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (isUpPressed)
 | 
					        if (isUpPressed)
 | 
				
			||||||
            GameObject.Transform.Position = GameObject.Transform.Position + Vector2D.Up * (float)Time.Elapsed.TotalSeconds * Speed;
 | 
					            Transform.Position = Transform.Position + Vector2D.Up * GameManager.Time.DeltaTime * Speed;
 | 
				
			||||||
        else if (isDownPressed)
 | 
					        else if (isDownPressed)
 | 
				
			||||||
            GameObject.Transform.Position = GameObject.Transform.Position + -Vector2D.Up * (float)Time.Elapsed.TotalSeconds * Speed;
 | 
					            Transform.Position = Transform.Position + -Vector2D.Up * GameManager.Time.DeltaTime * Speed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        GameObject.Transform.Position = new Vector2D(GameObject.Transform.Position.X, MathF.Max(MathF.Min(GameObject.Transform.Position.Y, High), Low));
 | 
					        Transform.Position = new Vector2D(Transform.Position.X, MathF.Max(MathF.Min(Transform.Position.Y, High), Low));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected override void OnFirstActiveFrame()
 | 
					    protected override void OnFirstActiveFrame()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (!BehaviourController.TryGetBehaviour<IButtonInputs<Keys>>(out var behaviourResult))
 | 
					        inputs = GameManager.FindBehaviour<IButtonInputs<Keys>>() ?? throw new("Unable to find inputs");
 | 
				
			||||||
            inputs = behaviourResult ?? BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        inputs.RegisterOnPress(Up, OnUpPressed);
 | 
					        inputs.RegisterOnPress(Up, OnUpPressed);
 | 
				
			||||||
        inputs.RegisterOnRelease(Up, OnUpReleased);
 | 
					        inputs.RegisterOnRelease(Up, OnUpReleased);
 | 
				
			||||||
@@ -3,10 +3,11 @@ using System;
 | 
				
			|||||||
using Microsoft.Xna.Framework.Input;
 | 
					using Microsoft.Xna.Framework.Input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using Syntriax.Engine.Core;
 | 
					using Syntriax.Engine.Core;
 | 
				
			||||||
 | 
					using Syntriax.Engine.Systems.Input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Pong.Behaviours;
 | 
					namespace Pong.Behaviours;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class PongManagerBehaviour : BehaviourOverride
 | 
					public class PongManagerBehaviour : Behaviour
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public Action<PongManagerBehaviour>? OnReset { get; set; } = null;
 | 
					    public Action<PongManagerBehaviour>? OnReset { get; set; } = null;
 | 
				
			||||||
    public Action<PongManagerBehaviour>? OnFinished { get; set; } = null;
 | 
					    public Action<PongManagerBehaviour>? OnFinished { get; set; } = null;
 | 
				
			||||||
@@ -23,11 +24,7 @@ public class PongManagerBehaviour : BehaviourOverride
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    protected override void OnFirstActiveFrame()
 | 
					    protected override void OnFirstActiveFrame()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        KeyboardInputsBehaviour? buttonInputs = null!;
 | 
					        var buttonInputs = GameManager.FindBehaviour<IButtonInputs<Keys>>() ?? throw new("Unable to find inputs");
 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (!BehaviourController.TryGetBehaviour(out buttonInputs))
 | 
					 | 
				
			||||||
            buttonInputs = BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        buttonInputs.RegisterOnRelease(Keys.Space, (_, _1) => Reset());
 | 
					        buttonInputs.RegisterOnRelease(Keys.Space, (_, _1) => Reset());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -4,13 +4,12 @@ using Apos.Shapes;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
using Syntriax.Engine.Core;
 | 
					using Syntriax.Engine.Core;
 | 
				
			||||||
using Syntriax.Engine.Core.Abstract;
 | 
					using Syntriax.Engine.Core.Abstract;
 | 
				
			||||||
using Syntriax.Engine.Input;
 | 
					 | 
				
			||||||
using Syntriax.Engine.Physics2D.Abstract;
 | 
					using Syntriax.Engine.Physics2D.Abstract;
 | 
				
			||||||
using Syntriax.Engine.Physics2D.Primitives;
 | 
					using Syntriax.Engine.Systems.Input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Pong.Behaviours;
 | 
					namespace Pong.Behaviours;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class ShapeAABBBehaviour : BehaviourOverride, IDisplayableShape
 | 
					public class ShapeAABBBehaviour : Behaviour2D, IDisplayableShape
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    private IShapeCollider2D? shapeCollider = null;
 | 
					    private IShapeCollider2D? shapeCollider = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2,8 +2,8 @@ using Microsoft.Xna.Framework;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
using Apos.Shapes;
 | 
					using Apos.Shapes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using Syntriax.Engine.Core;
 | 
				
			||||||
using Syntriax.Engine.Core.Abstract;
 | 
					using Syntriax.Engine.Core.Abstract;
 | 
				
			||||||
using Syntriax.Engine.Physics2D.Primitives;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Pong.Behaviours;
 | 
					namespace Pong.Behaviours;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -26,8 +26,8 @@ public class ShapeBehaviour : Syntriax.Engine.Physics2D.Collider2DShapeBehaviour
 | 
				
			|||||||
        shapeBatch.DrawLine(ShapeWorld[0].ToDisplayVector2(), ShapeWorld[^1].ToDisplayVector2(), Thickness, Color, Color);
 | 
					        shapeBatch.DrawLine(ShapeWorld[0].ToDisplayVector2(), ShapeWorld[^1].ToDisplayVector2(), Thickness, Color, Color);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ShapeBehaviour(Shape shape) : base(shape) { }
 | 
					    public ShapeBehaviour(Shape2D shape) : base(shape) { }
 | 
				
			||||||
    public ShapeBehaviour(Shape shape, float thickness) : base(shape) { Thickness = thickness; }
 | 
					    public ShapeBehaviour(Shape2D shape, float thickness) : base(shape) { Thickness = thickness; }
 | 
				
			||||||
    public ShapeBehaviour(Shape shape, Color color) : base(shape) { Color = color; }
 | 
					    public ShapeBehaviour(Shape2D shape, Color color) : base(shape) { Color = color; }
 | 
				
			||||||
    public ShapeBehaviour(Shape shape, Color color, float thickness) : base(shape) { Thickness = thickness; Color = color; }
 | 
					    public ShapeBehaviour(Shape2D shape, Color color, float thickness) : base(shape) { Thickness = thickness; Color = color; }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -6,7 +6,7 @@ using Syntriax.Engine.Core.Abstract;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Pong.Behaviours;
 | 
					namespace Pong.Behaviours;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class TextBehaviour : BehaviourOverride, IDisplayableSprite
 | 
					public class TextBehaviour : Behaviour2D, IDisplayableSprite
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public SpriteFont? Font { get; set; } = null;
 | 
					    public SpriteFont? Font { get; set; } = null;
 | 
				
			||||||
    public int Size { get; set; } = 16;
 | 
					    public int Size { get; set; } = 16;
 | 
				
			||||||
@@ -11,7 +11,7 @@ public class TextScoreBehaviour : TextBehaviour
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    protected override void OnFirstActiveFrame()
 | 
					    protected override void OnFirstActiveFrame()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (!GameObject.GameManager.TryFindBehaviour(out pongManager))
 | 
					        if (!HierarchyObject.GameManager.TryFindBehaviour(out pongManager))
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pongManager.OnScored += UpdateScores;
 | 
					        pongManager.OnScored += UpdateScores;
 | 
				
			||||||
@@ -5,7 +5,7 @@ using Syntriax.Engine.Physics2D.Abstract;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Pong.Behaviours;
 | 
					namespace Pong.Behaviours;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class WallScoreBehaviour(Action OnCollision) : BehaviourOverride
 | 
					public class WallScoreBehaviour(Action OnCollision) : Behaviour2D
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    private Action OnCollision { get; } = OnCollision;
 | 
					    private Action OnCollision { get; } = OnCollision;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								Shared/Content/Ubuntu Mono.ttf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Shared/Content/Ubuntu Mono.ttf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										165
									
								
								Shared/GamePong.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										165
									
								
								Shared/GamePong.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,165 @@
 | 
				
			|||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using Microsoft.Xna.Framework;
 | 
				
			||||||
 | 
					using Microsoft.Xna.Framework.Graphics;
 | 
				
			||||||
 | 
					using Microsoft.Xna.Framework.Input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using Pong.Behaviours;
 | 
				
			||||||
 | 
					using Apos.Shapes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using Syntriax.Engine.Core;
 | 
				
			||||||
 | 
					using Syntriax.Engine.Core.Abstract;
 | 
				
			||||||
 | 
					using Syntriax.Engine.Physics2D;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Pong;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class GamePong : Game
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    private readonly IHierarchyObject platformSpecificHierarchyObject = null!;
 | 
				
			||||||
 | 
					    private readonly GraphicsDeviceManager graphics = null!;
 | 
				
			||||||
 | 
					    private SpriteBatch spriteBatch = null!;
 | 
				
			||||||
 | 
					    private ShapeBatch shapeBatch = null!;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private GameManager gameManager = null!;
 | 
				
			||||||
 | 
					    private BehaviourCollector<IDisplayableSprite> displayableCollector = null!;
 | 
				
			||||||
 | 
					    private BehaviourCollector<IDisplayableShape> displayableShapeCollector = null!;
 | 
				
			||||||
 | 
					    private MonoGameCamera2DBehaviour cameraBehaviour = null!;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private PongManagerBehaviour pongManager = null!;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public GamePong(IHierarchyObject platformSpecificHierarchyObject)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.platformSpecificHierarchyObject = platformSpecificHierarchyObject;
 | 
				
			||||||
 | 
					        graphics = new GraphicsDeviceManager(this)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            PreferredBackBufferWidth = 1024,
 | 
				
			||||||
 | 
					            PreferredBackBufferHeight = 576,
 | 
				
			||||||
 | 
					            GraphicsProfile = GraphicsProfile.HiDef
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Content.RootDirectory = "Content";
 | 
				
			||||||
 | 
					        IsMouseVisible = true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected override void Initialize()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // TODO: Add your initialization logic here
 | 
				
			||||||
 | 
					        gameManager = new();
 | 
				
			||||||
 | 
					        displayableCollector = new(gameManager);
 | 
				
			||||||
 | 
					        displayableShapeCollector = new(gameManager);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        gameManager.Initialize();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        base.Initialize();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected override void LoadContent()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        spriteBatch = new SpriteBatch(GraphicsDevice);
 | 
				
			||||||
 | 
					        shapeBatch = new ShapeBatch(GraphicsDevice, Content);
 | 
				
			||||||
 | 
					        SpriteFont spriteFont = Content.Load<SpriteFont>("UbuntuMono");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        gameManager.Register(platformSpecificHierarchyObject);
 | 
				
			||||||
 | 
					        gameManager.InstantiateHierarchyObject<PhysicsEngine2D>().SetHierarchyObject("Physics Engine 2D");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IHierarchyObject HierarchyObjectCamera = gameManager.InstantiateHierarchyObject<HierarchyObject>().SetHierarchyObject("Camera"); ;
 | 
				
			||||||
 | 
					        HierarchyObjectCamera.BehaviourController.AddBehaviour<Transform2D>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        HierarchyObjectCamera.BehaviourController.AddBehaviour<CameraController>();
 | 
				
			||||||
 | 
					        cameraBehaviour = HierarchyObjectCamera.BehaviourController.AddBehaviour<MonoGameCamera2DBehaviour>(graphics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IHierarchyObject HierarchyObjectPongManager = gameManager.InstantiateHierarchyObject<HierarchyObject>().SetHierarchyObject("Pong Game Manager");
 | 
				
			||||||
 | 
					        pongManager = HierarchyObjectPongManager.BehaviourController.AddBehaviour<PongManagerBehaviour>(5);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IHierarchyObject HierarchyObjectBall = gameManager.InstantiateHierarchyObject<HierarchyObject>().SetHierarchyObject("Ball");
 | 
				
			||||||
 | 
					        HierarchyObjectBall.BehaviourController.AddBehaviour<Transform2D>().SetTransform(position: new Vector2D(0, 0f), scale: new Vector2D(10f, 10f));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        HierarchyObjectBall.BehaviourController.AddBehaviour<CircleBehaviour>(new Circle(Vector2D.Zero, 1f));
 | 
				
			||||||
 | 
					        HierarchyObjectBall.BehaviourController.AddBehaviour<BallBehaviour>();
 | 
				
			||||||
 | 
					        HierarchyObjectBall.BehaviourController.AddBehaviour<RigidBody2D>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IHierarchyObject HierarchyObjectLeftPaddle = gameManager.InstantiateHierarchyObject<HierarchyObject>().SetHierarchyObject("Left Paddle");
 | 
				
			||||||
 | 
					        HierarchyObjectLeftPaddle.BehaviourController.AddBehaviour<Transform2D>().SetTransform(position: new Vector2D(-468f, 0f), scale: new Vector2D(15f, 60f));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        HierarchyObjectLeftPaddle.BehaviourController.AddBehaviour<PaddleBehaviour>(Keys.W, Keys.S, 228f, -228f, 400f);
 | 
				
			||||||
 | 
					        HierarchyObjectLeftPaddle.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape2D.Square);
 | 
				
			||||||
 | 
					        HierarchyObjectLeftPaddle.BehaviourController.AddBehaviour<RigidBody2D>().IsStatic = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IHierarchyObject HierarchyObjectRightPaddle = gameManager.InstantiateHierarchyObject<HierarchyObject>().SetHierarchyObject("Right Paddle");
 | 
				
			||||||
 | 
					        HierarchyObjectRightPaddle.BehaviourController.AddBehaviour<Transform2D>().SetTransform(position: new Vector2D(468f, 0f), scale: new Vector2D(15f, 60f));
 | 
				
			||||||
 | 
					        HierarchyObjectRightPaddle.BehaviourController.AddBehaviour<PaddleBehaviour>(Keys.Up, Keys.Down, 228f, -228f, 400f);
 | 
				
			||||||
 | 
					        HierarchyObjectRightPaddle.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape2D.Square);
 | 
				
			||||||
 | 
					        HierarchyObjectRightPaddle.BehaviourController.AddBehaviour<RigidBody2D>().IsStatic = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IHierarchyObject HierarchyObjectWallTop = gameManager.InstantiateHierarchyObject<HierarchyObject>().SetHierarchyObject("Wall Top");
 | 
				
			||||||
 | 
					        HierarchyObjectWallTop.BehaviourController.AddBehaviour<Transform2D>().SetTransform(position: new Vector2D(0f, 308f), scale: new Vector2D(552f, 20f));
 | 
				
			||||||
 | 
					        HierarchyObjectWallTop.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape2D.Square);
 | 
				
			||||||
 | 
					        HierarchyObjectWallTop.BehaviourController.AddBehaviour<RigidBody2D>().IsStatic = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IHierarchyObject HierarchyObjectWallBottom = gameManager.InstantiateHierarchyObject<HierarchyObject>().SetHierarchyObject("Wall Bottom");
 | 
				
			||||||
 | 
					        HierarchyObjectWallBottom.BehaviourController.AddBehaviour<Transform2D>().SetTransform(position: new Vector2D(0f, -308f), scale: new Vector2D(552f, 20f));
 | 
				
			||||||
 | 
					        HierarchyObjectWallBottom.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape2D.Square);
 | 
				
			||||||
 | 
					        HierarchyObjectWallBottom.BehaviourController.AddBehaviour<RigidBody2D>().IsStatic = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IHierarchyObject HierarchyObjectWallRight = gameManager.InstantiateHierarchyObject<HierarchyObject>().SetHierarchyObject("Wall Right");
 | 
				
			||||||
 | 
					        HierarchyObjectWallRight.BehaviourController.AddBehaviour<Transform2D>().SetTransform(position: new Vector2D(532f, 0f), scale: new Vector2D(20f, 328f));
 | 
				
			||||||
 | 
					        HierarchyObjectWallRight.BehaviourController.AddBehaviour<WallScoreBehaviour>((Action)pongManager.ScoreToLeft);
 | 
				
			||||||
 | 
					        HierarchyObjectWallRight.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape2D.Square);
 | 
				
			||||||
 | 
					        HierarchyObjectWallRight.BehaviourController.AddBehaviour<RigidBody2D>().IsStatic = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IHierarchyObject HierarchyObjectWallLeft = gameManager.InstantiateHierarchyObject<HierarchyObject>().SetHierarchyObject("Wall Left");
 | 
				
			||||||
 | 
					        HierarchyObjectWallLeft.BehaviourController.AddBehaviour<Transform2D>().SetTransform(position: new Vector2D(-532f, 0f), scale: new Vector2D(20f, 328f));
 | 
				
			||||||
 | 
					        HierarchyObjectWallLeft.BehaviourController.AddBehaviour<WallScoreBehaviour>((Action)pongManager.ScoreToRight);
 | 
				
			||||||
 | 
					        HierarchyObjectWallLeft.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape2D.Square);
 | 
				
			||||||
 | 
					        HierarchyObjectWallLeft.BehaviourController.AddBehaviour<RigidBody2D>().IsStatic = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IHierarchyObject HierarchyObjectLeftScoreText = gameManager.InstantiateHierarchyObject<HierarchyObject>().SetHierarchyObject("Score Left");
 | 
				
			||||||
 | 
					        HierarchyObjectLeftScoreText.BehaviourController.AddBehaviour<Transform2D>().SetTransform(position: new Vector2D(-250f, 250f), scale: Vector2D.One * .25f);
 | 
				
			||||||
 | 
					        HierarchyObjectLeftScoreText.BehaviourController.AddBehaviour<TextScoreBehaviour>(true, spriteFont);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IHierarchyObject HierarchyObjectRightScoreText = gameManager.InstantiateHierarchyObject<HierarchyObject>().SetHierarchyObject("Score Right");
 | 
				
			||||||
 | 
					        HierarchyObjectRightScoreText.BehaviourController.AddBehaviour<Transform2D>().SetTransform(position: new Vector2D(250f, 250f), scale: Vector2D.One * .25f);
 | 
				
			||||||
 | 
					        HierarchyObjectRightScoreText.BehaviourController.AddBehaviour<TextScoreBehaviour>(false, spriteFont);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected override void Update(GameTime gameTime)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
 | 
				
			||||||
 | 
					            Exit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        gameManager.Update(gameTime.ToEngineTime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        base.Update(gameTime);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected override void Draw(GameTime gameTime)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        GraphicsDevice.Clear(new Color() { R = 32, G = 32, B = 32 });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // TODO: Add your drawing code here
 | 
				
			||||||
 | 
					        gameManager.PreDraw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        spriteBatch.Begin(SpriteSortMode.Deferred, transformMatrix: cameraBehaviour.MatrixTransform);
 | 
				
			||||||
 | 
					        foreach (var displayable in displayableCollector)
 | 
				
			||||||
 | 
					            displayable.Draw(spriteBatch);
 | 
				
			||||||
 | 
					        spriteBatch.End();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        shapeBatch.Begin(cameraBehaviour.MatrixTransform);
 | 
				
			||||||
 | 
					        foreach (var displayableShape in displayableShapeCollector)
 | 
				
			||||||
 | 
					            displayableShape.Draw(shapeBatch);
 | 
				
			||||||
 | 
					        shapeBatch.End();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        base.Draw(gameTime);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										16
									
								
								Shared/Shared.csproj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								Shared/Shared.csproj
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					<Project Sdk="Microsoft.NET.Sdk">
 | 
				
			||||||
 | 
					  <PropertyGroup>
 | 
				
			||||||
 | 
					    <TargetFramework>net8.0</TargetFramework>
 | 
				
			||||||
 | 
					    <Nullable>enable</Nullable>
 | 
				
			||||||
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <PackageReference Include="Apos.Shapes" Version="0.2.3" />
 | 
				
			||||||
 | 
					    <PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.303" />
 | 
				
			||||||
 | 
					    <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.2.1105">
 | 
				
			||||||
 | 
					      <PrivateAssets>All</PrivateAssets>
 | 
				
			||||||
 | 
					    </PackageReference>
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <ProjectReference Include="../Engine/Engine/Engine.csproj" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					</Project>
 | 
				
			||||||
		Reference in New Issue
	
	Block a user