add box2D colliders simple impl, some little tweaks, fixed camera bug

This commit is contained in:
2025-12-13 22:42:03 +08:00
parent 4140a5b4be
commit c92c831d02
30 changed files with 964 additions and 310 deletions

View File

@ -6,27 +6,20 @@ namespace Example
{
public float Speed;
private Entity m_PlayerEntity;
public void OnCreate()
{
m_PlayerEntity = FindEntityByTag("Player");
}
public void OnUpdate(float ts)
{
Mat4 transform = GetTransform();
Vec3 translation = transform.Translation;
float speed = Speed * ts;
if (Input.IsKeyPressed(KeyCode.Up))
translation.Y += speed;
else if (Input.IsKeyPressed(KeyCode.Down))
translation.Y -= speed;
if (Input.IsKeyPressed(KeyCode.Right))
translation.X += speed;
else if (Input.IsKeyPressed(KeyCode.Left))
translation.X -= speed;
translation.XY = m_PlayerEntity.GetTransform().Translation.XY;
translation.Y = Math.Max(translation.Y, 4.5f);
transform.Translation = translation;
SetTransform(transform);
}