Skip to content

Commit

Permalink
Add missing 2D physics methods
Browse files Browse the repository at this point in the history
  • Loading branch information
MrScautHD committed May 31, 2024
1 parent cdd8463 commit e8fb3f7
Show file tree
Hide file tree
Showing 4 changed files with 473 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/Sparkle.Test/CSharp/Test2DScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Test2DScene : Scene {
Cam2D cam2D = new Cam2D(new Vector2(0, 0), new Vector2(0, 0), Cam2D.CameraFollowMode.Smooth);
this.AddEntity(cam2D);

// PLAYER
Test2DEntity player = new Test2DEntity(new Vector2(0, -40));
player.Rotation = Quaternion.CreateFromYawPitchRoll(0, 0, 90 * RayMath.Deg2Rad);
this.AddEntity(player);
Expand All @@ -30,6 +31,7 @@ public class Test2DScene : Scene {
Density = 1.0F,
}));

// GROUND
Test2DEntity entity = new Test2DEntity(new Vector2(0, 0));
this.AddEntity(entity);

Expand Down
6 changes: 3 additions & 3 deletions src/Sparkle.Test/CSharp/TestEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ public class TestEntity : Entity {

protected override void FixedUpdate() {
base.FixedUpdate();

RigidBody3D body3D = this.GetComponent<RigidBody3D>();

if (!body3D.World.RayCast(new JVector(this.Position.X, this.Position.Y - 8, this.Position.Z), -JVector.UnitY, default, default, out Shape? shape, out JVector normal, out float fraction)) {
body3D.Body.AddForce(new JVector(0, 200, 0));
body3D.AddForce(new Vector3(0, 200, 0));
}
}

protected override void Update() {
base.Update();

/*
if (Input.IsKeyPressed(KeyboardKey.U)) {
this.GetComponent<ModelRenderer>().AnimationPlayer.Play(1, true, 0.5F);
Expand Down
Loading

0 comments on commit e8fb3f7

Please sign in to comment.