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()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user