From 739a4c81092f30f35258b20720ca4e188b28871b Mon Sep 17 00:00:00 2001 From: TEC-GO Date: Sat, 26 Sep 2026 15:07:28 -0300 Subject: [PATCH] Arreglo de velocidad con /DeltaTime/, FPS limitados a 60 --- source/Pacman/main.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/source/Pacman/main.cpp b/source/Pacman/main.cpp index 2020e0c..ec038b5 100644 --- a/source/Pacman/main.cpp +++ b/source/Pacman/main.cpp @@ -3,39 +3,44 @@ int main() { InitWindow(800, 600, "Attacks for Bombs 1"); + SetTargetFPS(60); - int x = 375; - int y = 275; - int tamaño = 50; - int velocidad = 5; + float x = 375.0f; + float y = 275.0f; + float tamano = 50.0f; + float velocidad = 300.0f; while (!WindowShouldClose()) { + float dt = GetFrameTime(); + if (IsKeyDown(KEY_W)) { - y -= velocidad; + y -= velocidad * dt; } if (IsKeyDown(KEY_S)) { - y += velocidad; + y += velocidad * dt; } if (IsKeyDown(KEY_A)) { - x -= velocidad; + x -= velocidad * dt; } if (IsKeyDown(KEY_D)) { - x += velocidad; + x += velocidad * dt; } BeginDrawing(); ClearBackground(WHITE); - DrawRectangle(x, y, tamaño, tamaño, RED); + DrawRectangle((int)x, (int)y, (int)tamano, (int)tamano, RED); + + DrawFPS(10, 10); EndDrawing(); }