Arreglo de velocidad con /DeltaTime/, FPS limitados a 60
This commit is contained in:
1 parent
b695b60153
commit
739a4c8109
1 file changed
+14
-9
+14
-9
@@ -3,39 +3,44 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
InitWindow(800, 600, "Attacks for Bombs 1");
|
InitWindow(800, 600, "Attacks for Bombs 1");
|
||||||
|
SetTargetFPS(60);
|
||||||
|
|
||||||
int x = 375;
|
float x = 375.0f;
|
||||||
int y = 275;
|
float y = 275.0f;
|
||||||
int tamaño = 50;
|
float tamano = 50.0f;
|
||||||
int velocidad = 5;
|
float velocidad = 300.0f;
|
||||||
|
|
||||||
while (!WindowShouldClose())
|
while (!WindowShouldClose())
|
||||||
{
|
{
|
||||||
|
float dt = GetFrameTime();
|
||||||
|
|
||||||
if (IsKeyDown(KEY_W))
|
if (IsKeyDown(KEY_W))
|
||||||
{
|
{
|
||||||
y -= velocidad;
|
y -= velocidad * dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyDown(KEY_S))
|
if (IsKeyDown(KEY_S))
|
||||||
{
|
{
|
||||||
y += velocidad;
|
y += velocidad * dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyDown(KEY_A))
|
if (IsKeyDown(KEY_A))
|
||||||
{
|
{
|
||||||
x -= velocidad;
|
x -= velocidad * dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyDown(KEY_D))
|
if (IsKeyDown(KEY_D))
|
||||||
{
|
{
|
||||||
x += velocidad;
|
x += velocidad * dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
ClearBackground(WHITE);
|
ClearBackground(WHITE);
|
||||||
|
|
||||||
DrawRectangle(x, y, tamaño, tamaño, RED);
|
DrawRectangle((int)x, (int)y, (int)tamano, (int)tamano, RED);
|
||||||
|
|
||||||
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user