camera implemented
This commit is contained in:
@@ -6,28 +6,28 @@ namespace PhysicsEngine
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
const int screenWidth = 1280;
|
||||
const int screenHeight = 720;
|
||||
|
||||
Raylib.InitWindow(screenWidth, screenHeight, "Fysikmotor & Sandlåda");
|
||||
Raylib.SetTargetFPS(144);
|
||||
Raylib.SetConfigFlags(ConfigFlags.FullscreenMode | ConfigFlags.VSyncHint);
|
||||
Raylib.InitWindow(0, 0, "Physics Engine");
|
||||
|
||||
const float physicsTimeStep = 1.0f / 60.0f;
|
||||
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;
|
||||
}
|
||||
|
||||
accumulator += frameTime;
|
||||
// Update Camera
|
||||
camera.Update(frameTime);
|
||||
|
||||
// Update loop
|
||||
// Update Physics accumulator
|
||||
accumulator += frameTime;
|
||||
while (accumulator >= physicsTimeStep)
|
||||
{
|
||||
UpdatePhysics(physicsTimeStep);
|
||||
@@ -36,26 +36,33 @@ namespace PhysicsEngine
|
||||
|
||||
// Render loop
|
||||
Raylib.BeginDrawing();
|
||||
Raylib.ClearBackground(Color.RayWhite);
|
||||
Raylib.ClearBackground(MuiDarkColor.BackgroundDefault.ToColor());
|
||||
|
||||
// Draw
|
||||
// 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();
|
||||
}
|
||||
|
||||
// Close
|
||||
Raylib.CloseWindow();
|
||||
}
|
||||
|
||||
private static void UpdatePhysics(float dt)
|
||||
{
|
||||
|
||||
// Physics simulation step
|
||||
}
|
||||
|
||||
private static void RenderScene()
|
||||
{
|
||||
Raylib.DrawText("Physics Engine", 20, 20, 20, Color.DarkGray);
|
||||
Raylib.DrawText("Physics Engine", 20, 20, 20, MuiDarkColor.TextPrimary.ToColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user