feat: Test Shapes Scene
This commit is contained in:
parent
9eed074025
commit
ef08eedc34
2
Engine
2
Engine
|
@ -1 +1 @@
|
||||||
Subproject commit ceebe210417e52abf6d904ae603d82263b658599
|
Subproject commit 85bad951ff9802d1b8c0a00e23f11914b5acd20d
|
|
@ -3,8 +3,9 @@ using Microsoft.Xna.Framework;
|
||||||
using Apos.Shapes;
|
using Apos.Shapes;
|
||||||
|
|
||||||
using Syntriax.Engine.Core;
|
using Syntriax.Engine.Core;
|
||||||
using Syntriax.Engine.Physics2D.Primitives;
|
using Syntriax.Engine.Input;
|
||||||
using Syntriax.Engine.Physics2D.Abstract;
|
using Syntriax.Engine.Physics2D.Abstract;
|
||||||
|
using Syntriax.Engine.Physics2D.Primitives;
|
||||||
|
|
||||||
namespace Pong.Behaviours;
|
namespace Pong.Behaviours;
|
||||||
|
|
||||||
|
@ -19,14 +20,21 @@ public class ShapeAABBBehaviour : BehaviourOverride, IDisplayableShape
|
||||||
|
|
||||||
public Color Color { get; set; } = Color.White;
|
public Color Color { get; set; } = Color.White;
|
||||||
public float Thickness { get; set; } = .5f;
|
public float Thickness { get; set; } = .5f;
|
||||||
|
public bool display = true;
|
||||||
|
|
||||||
protected override void OnFirstActiveFrame()
|
protected override void OnFirstActiveFrame()
|
||||||
{
|
{
|
||||||
BehaviourController.TryGetBehaviour(out shapeCollider);
|
BehaviourController.TryGetBehaviour(out shapeCollider);
|
||||||
|
|
||||||
|
if (BehaviourController.TryGetBehaviour(out IButtonInputs<Microsoft.Xna.Framework.Input.Keys>? keys))
|
||||||
|
keys.RegisterOnPress(Microsoft.Xna.Framework.Input.Keys.D, (_1, _2) => display = !display);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(ShapeBatch shapeBatch)
|
public void Draw(ShapeBatch shapeBatch)
|
||||||
{
|
{
|
||||||
|
if (!display)
|
||||||
|
return;
|
||||||
|
|
||||||
if (shapeCollider is null)
|
if (shapeCollider is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -66,14 +66,14 @@ public class Game1 : Game
|
||||||
gameManager.Camera = cameraBehaviour;
|
gameManager.Camera = cameraBehaviour;
|
||||||
|
|
||||||
|
|
||||||
IGameObject gameObjectCircle = gameManager.InstantiateGameObject<GameObject>();
|
// IGameObject gameObjectCircle = gameManager.InstantiateGameObject<GameObject>();
|
||||||
gameObjectCircle.Name = "Circle";
|
// gameObjectCircle.Name = "Circle";
|
||||||
gameObjectCircle.Transform.Position = new Vector2D(0f, -50f);
|
// gameObjectCircle.Transform.Position = new Vector2D(0f, -50f);
|
||||||
gameObjectCircle.Transform.Scale = new Vector2D(25f, 25f);
|
// gameObjectCircle.Transform.Scale = new Vector2D(25f, 25f);
|
||||||
gameObjectCircle.BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
|
// gameObjectCircle.BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
|
||||||
gameObjectCircle.BehaviourController.AddBehaviour<MovementBoxBehaviour>(Keys.W, Keys.S, 268f, -268f, 400f);
|
// gameObjectCircle.BehaviourController.AddBehaviour<MovementBoxBehaviour>(Keys.W, Keys.S, 268f, -268f, 400f);
|
||||||
gameObjectCircle.BehaviourController.AddBehaviour<CircleBehaviour>(new Circle(Vector2D.Zero, 1f));
|
// gameObjectCircle.BehaviourController.AddBehaviour<CircleBehaviour>(new Circle(Vector2D.Zero, 1f));
|
||||||
engine.AddRigidBody(gameObjectCircle.BehaviourController.AddBehaviour<RigidBody2D>());
|
// engine.AddRigidBody(gameObjectCircle.BehaviourController.AddBehaviour<RigidBody2D>());
|
||||||
|
|
||||||
IGameObject gameObjectCircle2 = gameManager.InstantiateGameObject<GameObject>();
|
IGameObject gameObjectCircle2 = gameManager.InstantiateGameObject<GameObject>();
|
||||||
gameObjectCircle2.Name = "Circle2";
|
gameObjectCircle2.Name = "Circle2";
|
||||||
|
@ -83,15 +83,43 @@ public class Game1 : Game
|
||||||
gameObjectCircle2.BehaviourController.AddBehaviour<CircleBehaviour>(new Circle(Vector2D.Zero, 1f));
|
gameObjectCircle2.BehaviourController.AddBehaviour<CircleBehaviour>(new Circle(Vector2D.Zero, 1f));
|
||||||
engine.AddRigidBody(gameObjectCircle2.BehaviourController.AddBehaviour<RigidBody2D>());
|
engine.AddRigidBody(gameObjectCircle2.BehaviourController.AddBehaviour<RigidBody2D>());
|
||||||
|
|
||||||
// IGameObject gameObjectDiamond = gameManager.InstantiateGameObject<GameObject>();
|
IGameObject gameObjectDiamond = gameManager.InstantiateGameObject<GameObject>();
|
||||||
// gameObjectDiamond.Name = "Diamond";
|
gameObjectDiamond.Name = "Diamond";
|
||||||
// gameObjectDiamond.Transform.Position = new Vector2D(0f, 0f);
|
gameObjectDiamond.Transform.Position = new Vector2D(-150f, -150f);
|
||||||
// gameObjectDiamond.Transform.Scale = new Vector2D(100f, 100f);
|
gameObjectDiamond.Transform.Scale = new Vector2D(50f, 50f);
|
||||||
// gameObjectDiamond.BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
|
gameObjectDiamond.BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
|
||||||
// gameObjectDiamond.BehaviourController.AddBehaviour<MovementBoxBehaviour>(Keys.W, Keys.S, 268f, -268f, 400f);
|
gameObjectDiamond.BehaviourController.AddBehaviour<MovementBoxBehaviour>(Keys.W, Keys.S, 268f, -268f, 400f);
|
||||||
// gameObjectDiamond.BehaviourController.AddBehaviour<RotatableBehaviour>();
|
gameObjectDiamond.BehaviourController.AddBehaviour<RotatableBehaviour>();
|
||||||
// gameObjectDiamond.BehaviourController.AddBehaviour<ShapeBehaviour>(new Shape([Vector2D.Up, Vector2D.One, Vector2D.Right, Vector2D.Down, Vector2D.Zero, Vector2D.Left]));
|
gameObjectDiamond.BehaviourController.AddBehaviour<ShapeBehaviour>(new Shape([Vector2D.Up, Vector2D.One, Vector2D.Right, Vector2D.Down, -Vector2D.One, Vector2D.Left]));
|
||||||
// gameObjectDiamond.BehaviourController.AddBehaviour<ShapeAABBBehaviour>();
|
gameObjectDiamond.BehaviourController.AddBehaviour<ShapeAABBBehaviour>();
|
||||||
|
engine.AddRigidBody(gameObjectDiamond.BehaviourController.AddBehaviour<RigidBody2D>());
|
||||||
|
|
||||||
|
IGameObject gameObjectBox = gameManager.InstantiateGameObject<GameObject>();
|
||||||
|
gameObjectBox.Name = "Box";
|
||||||
|
gameObjectBox.Transform.Position = new Vector2D(150f, -150f);
|
||||||
|
gameObjectBox.Transform.Scale = new Vector2D(100f, 100f);
|
||||||
|
gameObjectBox.BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
|
||||||
|
gameObjectBox.BehaviourController.AddBehaviour<MovementBoxBehaviour>(Keys.W, Keys.S, 268f, -268f, 400f);
|
||||||
|
gameObjectBox.BehaviourController.AddBehaviour<RotatableBehaviour>();
|
||||||
|
gameObjectBox.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape.Pentagon);
|
||||||
|
gameObjectBox.BehaviourController.AddBehaviour<ShapeAABBBehaviour>();
|
||||||
|
engine.AddRigidBody(gameObjectBox.BehaviourController.AddBehaviour<RigidBody2D>());
|
||||||
|
|
||||||
|
for (int i = 3; i < 10; i++)
|
||||||
|
{
|
||||||
|
IGameObject Test = gameManager.InstantiateGameObject<GameObject>();
|
||||||
|
Test.Name = i.ToString();
|
||||||
|
Test.Transform.Position = new Vector2D((i - 6) * 150, 0f);
|
||||||
|
Test.Transform.Scale = new Vector2D(75f, 75f);
|
||||||
|
Test.BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
|
||||||
|
Test.BehaviourController.AddBehaviour<MovementBoxBehaviour>(Keys.W, Keys.S, 268f, -268f, 400f);
|
||||||
|
Test.BehaviourController.AddBehaviour<RotatableBehaviour>();
|
||||||
|
Test.BehaviourController.AddBehaviour<ShapeBehaviour>(Shape.CreateNgon(i));
|
||||||
|
Test.BehaviourController.AddBehaviour<ShapeAABBBehaviour>();
|
||||||
|
RigidBody2D rigidBody = Test.BehaviourController.AddBehaviour<RigidBody2D>();
|
||||||
|
rigidBody.AngularVelocity = 90f;
|
||||||
|
engine.AddRigidBody(rigidBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// IGameObject gameObjectShape = gameManager.InstantiateGameObject<GameObject>();
|
// IGameObject gameObjectShape = gameManager.InstantiateGameObject<GameObject>();
|
||||||
|
|
Loading…
Reference in New Issue