From 5d41620ab10b706b581e42a22ffed1c3ad90e94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copl?= =?UTF-8?q?an?= Date: Mon, 23 Dec 2024 15:36:12 -0800 Subject: [PATCH] fix(blocks_game): don't say you can click Currently, the text says "PRESS ENTER or TAP to JUMP", however you cannot tap. This commit updates the text to remove "TAP". This commit also adds the calculation for centering text, and removes some trailing whitespace. --- lessons/01_blocks_game_intro.c | 70 ++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/lessons/01_blocks_game_intro.c b/lessons/01_blocks_game_intro.c index 766c7d4..18c2e47 100644 --- a/lessons/01_blocks_game_intro.c +++ b/lessons/01_blocks_game_intro.c @@ -42,69 +42,69 @@ int main() // LESSON 01: Window initialization and screens management InitWindow(screenWidth, screenHeight, "PROJECT: BLOCKS GAME"); - + // NOTE: Load resources (textures, fonts, audio) after Window initialization // Game required variables GameScreen screen = LOGO; // Current game screen state - - int framesCounter = 0; // General pourpose frames counter + + int framesCounter = 0; // General purpose frames counter int gameResult = -1; // Game result: 0 - Loose, 1 - Win, -1 - Not defined bool gamePaused = false; // Game paused state toggle - + // TODO: Define and Initialize game variables - + SetTargetFPS(60); // Set desired framerate (frames per second) //-------------------------------------------------------------------------------------- - + // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- - switch(screen) + switch(screen) { - case LOGO: + case LOGO: { // Update LOGO screen data here! - + framesCounter++; - - if (framesCounter > 180) + + if (framesCounter > 180) { screen = TITLE; // Change to TITLE screen after 3 seconds framesCounter = 0; } - + } break; - case TITLE: + case TITLE: { // Update TITLE screen data here! - + framesCounter++; - + // LESSON 03: Inputs management (keyboard, mouse) if (IsKeyPressed(KEY_ENTER)) screen = GAMEPLAY; - + } break; case GAMEPLAY: - { + { // Update GAMEPLAY screen data here! if (!gamePaused) { // TODO: Gameplay logic } - + if (IsKeyPressed(KEY_ENTER)) screen = ENDING; } break; - case ENDING: + case ENDING: { // Update END screen data here! - + framesCounter++; - + // LESSON 03: Inputs management (keyboard, mouse) if (IsKeyPressed(KEY_ENTER)) screen = TITLE; @@ -112,14 +112,14 @@ int main() default: break; } //---------------------------------------------------------------------------------- - + // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + ClearBackground(RAYWHITE); - - switch(screen) + + switch(screen) { case LOGO: { @@ -131,41 +131,47 @@ int main() case TITLE: { // TODO: Draw TITLE screen here! + char const* text = "PRESS ENTER to JUMP to GAMEPLAY SCREEN"; + int fontSize = 20; DrawRectangle(0, 0, screenWidth, screenHeight, GREEN); DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN); - DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, DARKGREEN); + DrawText(text, screenWidth/2 - MeasureText(text, fontSize)/2, 220, fontSize, DARKGREEN); } break; case GAMEPLAY: { // TODO: Draw GAMEPLAY screen here! + char* text = "PRESS ENTER to JUMP to ENDING SCREEN"; + int fontSize = 20; DrawRectangle(0, 0, screenWidth, screenHeight, PURPLE); DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON); - DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, MAROON); + DrawText(text, screenWidth/2 - MeasureText(text, fontSize)/2, 220, fontSize, MAROON); } break; case ENDING: { // TODO: Draw ENDING screen here! + char* text = "PRESS ENTER to RETURN to TITLE SCREEN"; + int fontSize = 20; DrawRectangle(0, 0, screenWidth, screenHeight, BLUE); DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE); - DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, DARKBLUE); + DrawText(text, screenWidth/2 - MeasureText(text, fontSize)/2, 220, fontSize, DARKBLUE); } break; default: break; } - + EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- - + // NOTE: Unload any loaded resources (texture, fonts, audio) CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - + return 0; -} \ No newline at end of file +}