68 lines
1.9 KiB
C#
68 lines
1.9 KiB
C#
using Raylib_cs;
|
|
|
|
namespace PhysicsEngine
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
Raylib.SetConfigFlags(ConfigFlags.FullscreenMode | ConfigFlags.VSyncHint);
|
|
Raylib.InitWindow(0, 0, "Physics Engine");
|
|
|
|
Camera camera = new Camera();
|
|
|
|
const float physicsTimeStep = 1.0f / 60.0f;
|
|
float accumulator = 0.0f;
|
|
|
|
// Main loop
|
|
while (!Raylib.WindowShouldClose())
|
|
{
|
|
float frameTime = Raylib.GetFrameTime();
|
|
if (frameTime > 0.25f)
|
|
{
|
|
frameTime = 0.25f;
|
|
}
|
|
|
|
// Update Camera
|
|
camera.Update(frameTime);
|
|
|
|
// Update Physics accumulator
|
|
accumulator += frameTime;
|
|
while (accumulator >= physicsTimeStep)
|
|
{
|
|
UpdatePhysics(physicsTimeStep);
|
|
accumulator -= physicsTimeStep;
|
|
}
|
|
|
|
// Render loop
|
|
Raylib.BeginDrawing();
|
|
Raylib.ClearBackground(MuiDarkColor.BackgroundDefault.ToColor());
|
|
|
|
// Draw background screen-space elements (Grid)
|
|
camera.DrawGrid();
|
|
|
|
// Draw world-space elements inside 2D mode
|
|
Raylib.BeginMode2D(camera.RaylibCamera);
|
|
Raylib.EndMode2D();
|
|
|
|
// Draw UI / HUD elements
|
|
RenderScene();
|
|
camera.DrawHUD();
|
|
|
|
Raylib.EndDrawing();
|
|
}
|
|
|
|
Raylib.CloseWindow();
|
|
}
|
|
|
|
private static void UpdatePhysics(float dt)
|
|
{
|
|
// Physics simulation step
|
|
}
|
|
|
|
private static void RenderScene()
|
|
{
|
|
Raylib.DrawText("Physics Engine", 20, 20, 20, MuiDarkColor.TextPrimary.ToColor());
|
|
}
|
|
}
|
|
} |