Add speed variable

This commit is contained in:
Émi Lefèvre
2026-04-21 12:54:43 +02:00
parent 93bca5b327
commit 506cef572d

View File

@@ -38,6 +38,9 @@ int main ()
int positionXCollectible = GetRandomValue(0, 600); int positionXCollectible = GetRandomValue(0, 600);
int positionYCollectible = GetRandomValue(0, 800); int positionYCollectible = GetRandomValue(0, 800);
// Character controller settings
int speed = 2;
// game loop // game loop
while (!WindowShouldClose()) // run the loop until the user presses ESCAPE or presses the Close button on the window while (!WindowShouldClose()) // run the loop until the user presses ESCAPE or presses the Close button on the window
@@ -68,21 +71,21 @@ int main ()
//up //up
if (IsKeyDown(74) && VerticalPosition != 580 ) { if (IsKeyDown(74) && VerticalPosition != 580 ) {
// draw some text using the default font // draw some text using the default font
VerticalPosition = VerticalPosition+10; VerticalPosition = VerticalPosition+speed;
}; };
//down //down
if (IsKeyDown(75) && VerticalPosition != 0) { if (IsKeyDown(75) && VerticalPosition != 0) {
VerticalPosition = VerticalPosition-10; VerticalPosition = VerticalPosition-speed;
// draw some text using the default font // draw some text using the default font
}; };
//left //left
if (IsKeyDown(72) && HorizontalPosition != 0) { if (IsKeyDown(72) && HorizontalPosition != 0) {
HorizontalPosition = HorizontalPosition-10; HorizontalPosition = HorizontalPosition-speed;
// draw some text using the default font // draw some text using the default font
}; };
//right //right
if (IsKeyDown(76)&& HorizontalPosition != 780) { if (IsKeyDown(76)&& HorizontalPosition != 780) {
HorizontalPosition = HorizontalPosition+10; HorizontalPosition = HorizontalPosition+speed;
// draw some text using the default font // draw some text using the default font
}; };