Compare commits

..

2 Commits

Author SHA1 Message Date
Émi Lefèvre
84abf9f447 Add static methods for better architecture (wip) 2026-04-21 13:04:37 +02:00
Émi Lefèvre
506cef572d Add speed variable 2026-04-21 13:04:37 +02:00

View File

@@ -12,6 +12,16 @@ by Jeffery Myers is marked with CC0 1.0. To view a copy of this license, visit h
#include "resource_dir.h" // utility header for SearchAndSetResourceDir #include "resource_dir.h" // utility header for SearchAndSetResourceDir
#include <stdlib.h> #include <stdlib.h>
//------------------------------------------------------------------------------------
// Module Functions Declaration (local)
//------------------------------------------------------------------------------------
static void InitGame(void); // Initialize game
static void UpdateGame(void); // Update game (one frame)
static void DrawGame(void); // Draw game (one frame)
static void UnloadGame(void); // Unload game
static void UpdateDrawFrame(void); // Update and Draw (one frame)
int main () int main ()
{ {
// Tell the window to use vsync and work on high DPI displays // Tell the window to use vsync and work on high DPI displays
@@ -38,6 +48,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 +81,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
}; };
@@ -107,3 +120,29 @@ int main ()
CloseWindow(); CloseWindow();
return 0; return 0;
} }
void InitGame(void)
{
return;
}
void UpdateGame(void)
{
return;
}
void DrawGame(void)
{
return;
}
void UnloadGame(void)
{
return;
}
void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
}