diff options
| author | raysan5 <[email protected]> | 2020-04-13 13:31:45 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2020-04-13 13:31:45 +0200 |
| commit | fd5d1dfcb6d740728f21cdd08ba8387b0ee2f899 (patch) | |
| tree | 6884674e4585aeef46346e0f8868b0e25c634efd /games/drturtle | |
| parent | eb04be8141c5e70f99d8104c44a61fb71779a55a (diff) | |
| download | raylib-fd5d1dfcb6d740728f21cdd08ba8387b0ee2f899.tar.gz raylib-fd5d1dfcb6d740728f21cdd08ba8387b0ee2f899.zip | |
WARNING: REMOVED raylib/games - Moved to raysan5/raylib-games
Move raylib games to another repo. It will reduce repo size for new clones.
I considered also removing the related history with [`git filter-repo`](https://github.com/newren/git-filter-repo) (the current sane alternative to the deprecated `filter-branch`) but it has some implications: It would had made a new repository with distinct history and checksums. If the repo was previously published,
the history of the new one won't have been compatible with the history others have pulled.
Diffstat (limited to 'games/drturtle')
27 files changed, 0 insertions, 3269 deletions
diff --git a/games/drturtle/00_drturtle_screens.c b/games/drturtle/00_drturtle_screens.c deleted file mode 100644 index fd9b3dad..00000000 --- a/games/drturtle/00_drturtle_screens.c +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Define current screen - GameScreen currentScreen = TITLE; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - } - - } break; - case GAMEPLAY: - { - // Press enter to change to ending screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = ENDING; - } - - } break; - case ENDING: - { - // Press enter to change to title screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = TITLE; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - switch (currentScreen) - { - case TITLE: - { - // Draw title screen - DrawRectangle(0, 0, screenWidth, screenHeight, GREEN); - DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN); - - } break; - case GAMEPLAY: - { - // Draw gameplay screen - DrawRectangle(0, 0, screenWidth, screenHeight, RED); - DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON); - - } break; - case ENDING: - { - // Draw ending screen - DrawRectangle(0, 0, screenWidth, screenHeight, BLUE); - DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/games/drturtle/01_drturtle_scrolling.c b/games/drturtle/01_drturtle_scrolling.c deleted file mode 100644 index b8a091de..00000000 --- a/games/drturtle/01_drturtle_scrolling.c +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Load game resources: textures - Texture2D sky = LoadTexture("resources/sky.png"); - Texture2D mountains = LoadTexture("resources/mountains.png"); - Texture2D sea = LoadTexture("resources/sea.png"); - - // Define scrolling variables - int backScrolling = 0; - int seaScrolling = 0; - - // Define current screen - GameScreen currentScreen = TITLE; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= 8; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to ending screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = ENDING; - } - - } break; - case ENDING: - { - // Press enter to change to title screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = TITLE; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - DrawTexture(sea, seaScrolling, 0, BLUE); - DrawTexture(sea, screenWidth + seaScrolling, 0, BLUE); - - switch (currentScreen) - { - case TITLE: - { - // Draw title screen - DrawText("PRESS ENTER", 450, 420, 40, BLACK); - - } break; - case GAMEPLAY: - { - // Draw gameplay screen - DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON); - - } break; - case ENDING: - { - // Draw ending screen - - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/games/drturtle/02_drturtle_player.c b/games/drturtle/02_drturtle_player.c deleted file mode 100644 index bf49abe5..00000000 --- a/games/drturtle/02_drturtle_player.c +++ /dev/null @@ -1,212 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Load game resources: textures - Texture2D sky = LoadTexture("resources/sky.png"); - Texture2D mountains = LoadTexture("resources/mountains.png"); - Texture2D sea = LoadTexture("resources/sea.png"); - Texture2D title = LoadTexture("resources/title.png"); - Texture2D turtle = LoadTexture("resources/turtle.png"); - Texture2D gamera = LoadTexture("resources/gamera.png"); - - // Define scrolling variables - int backScrolling = 0; - int seaScrolling = 0; - - // Define current screen - GameScreen currentScreen = TITLE; - - // Define player variables - int playerRail = 1; - Rectangle playerBounds = { 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - bool gameraMode = false; - - // Define additional game variables - int framesCounter = 0; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - framesCounter++; - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - framesCounter = 0; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= 8; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Player movement logic - if (IsKeyPressed(KEY_DOWN)) playerRail++; - else if (IsKeyPressed(KEY_UP)) playerRail--; - - // Check player not out of rails - if (playerRail > 4) playerRail = 4; - else if (playerRail < 0) playerRail = 0; - - // Update player bounds - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - if (IsKeyPressed(KEY_SPACE)) gameraMode = !gameraMode; - if (IsKeyPressed(KEY_ENTER)) currentScreen = ENDING; - - } break; - case ENDING: - { - // Press enter to play again - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - - // Reset player - playerRail = 1; - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - gameraMode = false; - framesCounter = 0; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - if (!gameraMode) - { - DrawTexture(sea, seaScrolling, 0, BLUE); - DrawTexture(sea, screenWidth + seaScrolling, 0, BLUE); - } - else - { - DrawTexture(sea, seaScrolling, 0, RED); - DrawTexture(sea, screenWidth + seaScrolling, 0, RED); - } - - switch (currentScreen) - { - case TITLE: - { - // Draw title - //DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); - DrawRectangle(380, 140, 500, 300, GRAY); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawText("PRESS ENTER", 480, 480, 40, BLACK); - - } break; - case GAMEPLAY: - { - // Draw player - //if (!gameraMode) DrawTexture(turtle, playerBounds.x - 14, playerBounds.y - 14, WHITE); - //else DrawTexture(gamera, playerBounds.x - 64, playerBounds.y - 64, WHITE); - - // Draw player bounding box - if (!gameraMode) DrawRectangleRec(playerBounds, GREEN); - else DrawRectangleRec(playerBounds, ORANGE); - - } break; - case ENDING: - { - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawText("GAME OVER", 300, 200, 100, MAROON); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawText("PRESS ENTER to REPLAY", 400, 420, 30, LIGHTGRAY); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - UnloadTexture(title); - UnloadTexture(turtle); - UnloadTexture(gamera); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/games/drturtle/03_drturtle_enemies.c b/games/drturtle/03_drturtle_enemies.c deleted file mode 100644 index f659a19a..00000000 --- a/games/drturtle/03_drturtle_enemies.c +++ /dev/null @@ -1,393 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Load game resources: textures - Texture2D sky = LoadTexture("resources/sky.png"); - Texture2D mountains = LoadTexture("resources/mountains.png"); - Texture2D sea = LoadTexture("resources/sea.png"); - Texture2D title = LoadTexture("resources/title.png"); - Texture2D turtle = LoadTexture("resources/turtle.png"); - Texture2D gamera = LoadTexture("resources/gamera.png"); - Texture2D shark = LoadTexture("resources/shark.png"); - Texture2D orca = LoadTexture("resources/orca.png"); - Texture2D swhale = LoadTexture("resources/swhale.png"); - Texture2D fish = LoadTexture("resources/fish.png"); - - // Define scrolling variables - int backScrolling = 0; - int seaScrolling = 0; - - // Define current screen - GameScreen currentScreen = TITLE; - - // Define player variables - int playerRail = 1; - Rectangle playerBounds = { 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - bool gameraMode = false; - - // Define enemies variables - Rectangle enemyBounds[MAX_ENEMIES]; - int enemyRail[MAX_ENEMIES]; - int enemyType[MAX_ENEMIES]; - bool enemyActive[MAX_ENEMIES]; - float enemySpeed = 10; - - // Init enemies variables - for (int i = 0; i < MAX_ENEMIES; i++) - { - // Define enemy type (all same probability) - enemyType[i] = GetRandomValue(0, 3); - - // Define enemy rail - enemyRail[i] = GetRandomValue(0, 4); - - // Define enemy bounding box - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - // Define additional game variables - int foodBar = 0; - int framesCounter = 0; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - framesCounter++; - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - framesCounter = 0; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= (enemySpeed - 2); - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Player movement logic - if (IsKeyPressed(KEY_DOWN)) playerRail++; - else if (IsKeyPressed(KEY_UP)) playerRail--; - - // Check player not out of rails - if (playerRail > 4) playerRail = 4; - else if (playerRail < 0) playerRail = 0; - - // Update player bounds - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Enemies activation logic (every 40 frames) - if (framesCounter > 40) - { - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i] == false) - { - enemyActive[i] = true; - i = MAX_ENEMIES; - } - } - - framesCounter = 0; - } - - // Enemies logic - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - enemyBounds[i].x -= enemySpeed; - } - - // Check enemies out of screen - if (enemyBounds[i].x <= 0 - 128) - { - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - } - - // Enemies speed increase every frame - if (!gameraMode) enemySpeed += 0.005; - - // Check collision player vs enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - if (CheckCollisionRecs(playerBounds, enemyBounds[i])) - { - if (enemyType[i] < 3) // Bad enemies - { - if (gameraMode) - { - foodBar += 15; - - // After enemy deactivation, reset enemy parameters to be reused - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - else - { - // Player die logic - currentScreen = ENDING; - framesCounter = 0; - } - } - else // Sweet fish - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - if (!gameraMode) foodBar += 80; - else foodBar += 25; - - if (foodBar == 400) - { - gameraMode = true; - } - } - } - } - } - - // Gamera mode logic - if (gameraMode) - { - foodBar--; - - if (foodBar <= 0) - { - gameraMode = false; - enemySpeed -= 2; - if (enemySpeed < 10) enemySpeed = 10; - } - } - - } break; - case ENDING: - { - // Press enter to play again - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - - // Reset player - playerRail = 1; - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - gameraMode = false; - - // Reset enemies data - for (int i = 0; i < MAX_ENEMIES; i++) - { - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - enemySpeed = 10; - - // Reset game variables - foodBar = 0; - framesCounter = 0; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - if (!gameraMode) - { - DrawTexture(sea, seaScrolling, 0, BLUE); - DrawTexture(sea, screenWidth + seaScrolling, 0, BLUE); - } - else - { - DrawTexture(sea, seaScrolling, 0, RED); - DrawTexture(sea, screenWidth + seaScrolling, 0, RED); - } - - switch (currentScreen) - { - case TITLE: - { - // Draw title - DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawText("PRESS ENTER", 480, 480, 40, BLACK); - - } break; - case GAMEPLAY: - { - // Draw water lines - for (int i = 0; i < 5; i++) DrawRectangle(0, i*120 + 120, screenWidth, 110, Fade(SKYBLUE, 0.1f)); - - // Draw player - if (!gameraMode) DrawTexture(turtle, playerBounds.x - 14, playerBounds.y - 14, WHITE); - else DrawTexture(gamera, playerBounds.x - 64, playerBounds.y - 64, WHITE); - - // Draw player bounding box - //if (!gameraMode) DrawRectangleRec(playerBounds, Fade(GREEN, 0.4f)); - //else DrawRectangleRec(playerBounds, Fade(ORANGE, 0.4f)); - - // Draw enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - // Draw enemies - /* - switch(enemyType[i]) - { - case 0: DrawTexture(shark, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 1: DrawTexture(orca, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 2: DrawTexture(swhale, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 3: DrawTexture(fish, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - default: break; - } - */ - - // Draw enemies bounding boxes - switch(enemyType[i]) - { - case 0: DrawRectangleRec(enemyBounds[i], RED); break; - case 1: DrawRectangleRec(enemyBounds[i], RED); break; - case 2: DrawRectangleRec(enemyBounds[i], RED); break; - case 3: DrawRectangleRec(enemyBounds[i], GREEN); break; - default: break; - } - } - } - - // Draw gameplay interface - - // Draw food bar - DrawRectangle(20, 20, 400, 40, Fade(GRAY, 0.4f)); - DrawRectangle(20, 20, foodBar, 40, ORANGE); - DrawRectangleLines(20, 20, 400, 40, BLACK); - - if (gameraMode) - { - DrawText("GAMERA MODE", 60, 22, 40, GRAY); - } - - } break; - case ENDING: - { - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawText("GAME OVER", 300, 200, 100, MAROON); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawText("PRESS ENTER to REPLAY", 400, 420, 30, LIGHTGRAY); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - UnloadTexture(title); - UnloadTexture(turtle); - UnloadTexture(gamera); - UnloadTexture(shark); - UnloadTexture(orca); - UnloadTexture(swhale); - UnloadTexture(fish); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/games/drturtle/04_drturtle_gui.c b/games/drturtle/04_drturtle_gui.c deleted file mode 100644 index 0ec06fb6..00000000 --- a/games/drturtle/04_drturtle_gui.c +++ /dev/null @@ -1,447 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Load game resources: textures - Texture2D sky = LoadTexture("resources/sky.png"); - Texture2D mountains = LoadTexture("resources/mountains.png"); - Texture2D sea = LoadTexture("resources/sea.png"); - Texture2D title = LoadTexture("resources/title.png"); - Texture2D turtle = LoadTexture("resources/turtle.png"); - Texture2D gamera = LoadTexture("resources/gamera.png"); - Texture2D shark = LoadTexture("resources/shark.png"); - Texture2D orca = LoadTexture("resources/orca.png"); - Texture2D swhale = LoadTexture("resources/swhale.png"); - Texture2D fish = LoadTexture("resources/fish.png"); - Texture2D gframe = LoadTexture("resources/gframe.png"); - - // Load game resources: fonts - Font font = LoadFont("resources/komika.png"); - - // Define scrolling variables - int backScrolling = 0; - int seaScrolling = 0; - - // Define current screen - GameScreen currentScreen = TITLE; - - // Define player variables - int playerRail = 1; - Rectangle playerBounds = { 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - bool gameraMode = false; - - // Define enemies variables - Rectangle enemyBounds[MAX_ENEMIES]; - int enemyRail[MAX_ENEMIES]; - int enemyType[MAX_ENEMIES]; - bool enemyActive[MAX_ENEMIES]; - float enemySpeed = 10; - - // Init enemies variables - for (int i = 0; i < MAX_ENEMIES; i++) - { - // Define enemy type (all same probability) - //enemyType[i] = GetRandomValue(0, 3); - - // Probability system for enemies type - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - // Define enemy rail - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - // Define additional game variables - int score = 0; - float distance = 0.0f; - int hiscore = 0; - float hidistance = 0.0f; - int foodBar = 0; - int framesCounter = 0; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - framesCounter++; - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - framesCounter = 0; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= (enemySpeed - 2); - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Player movement logic - if (IsKeyPressed(KEY_DOWN)) playerRail++; - else if (IsKeyPressed(KEY_UP)) playerRail--; - - // Check player not out of rails - if (playerRail > 4) playerRail = 4; - else if (playerRail < 0) playerRail = 0; - - // Update player bounds - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Enemies activation logic (every 40 frames) - if (framesCounter > 40) - { - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i] == false) - { - enemyActive[i] = true; - i = MAX_ENEMIES; - } - } - - framesCounter = 0; - } - - // Enemies logic - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - enemyBounds[i].x -= enemySpeed; - } - - // Check enemies out of screen - if (enemyBounds[i].x <= 0 - 128) - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - } - } - - if (!gameraMode) enemySpeed += 0.005; - - // Check collision player vs enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - if (CheckCollisionRecs(playerBounds, enemyBounds[i])) - { - if (enemyType[i] < 3) // Bad enemies - { - if (gameraMode) - { - if (enemyType[i] == 0) score += 50; - else if (enemyType[i] == 1) score += 150; - else if (enemyType[i] == 2) score += 300; - - foodBar += 15; - - enemyActive[i] = false; - - // After enemy deactivation, reset enemy parameters to be reused - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - } - else - { - // Player die logic - currentScreen = ENDING; - framesCounter = 0; - - // Save hiscore and hidistance for next game - if (score > hiscore) hiscore = score; - if (distance > hidistance) hidistance = distance; - } - } - else // Sweet fish - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - if (!gameraMode) foodBar += 80; - else foodBar += 25; - - score += 10; - - if (foodBar == 400) - { - gameraMode = true; - } - } - } - } - } - - // Gamera mode logic - if (gameraMode) - { - foodBar--; - - if (foodBar <= 0) - { - gameraMode = false; - enemySpeed -= 2; - if (enemySpeed < 10) enemySpeed = 10; - } - } - - // Update distance counter - distance += 0.5f; - - } break; - case ENDING: - { - // Press enter to play again - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - - // Reset player - playerRail = 1; - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - gameraMode = false; - - // Reset enemies data - for (int i = 0; i < MAX_ENEMIES; i++) - { - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - //enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - enemySpeed = 10; - - // Reset game variables - score = 0; - distance = 0.0; - foodBar = 0; - framesCounter = 0; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - if (!gameraMode) - { - DrawTexture(sea, seaScrolling, 0, (Color){ 16, 189, 227, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 16, 189, 227, 255}); - } - else - { - DrawTexture(sea, seaScrolling, 0, (Color){ 255, 113, 66, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 255, 113, 66, 255}); - } - - switch (currentScreen) - { - case TITLE: - { - // Draw title - DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 0, WHITE); - - } break; - case GAMEPLAY: - { - // Draw water lines - for (int i = 0; i < 5; i++) DrawRectangle(0, i*120 + 120, screenWidth, 110, Fade(SKYBLUE, 0.1f)); - - // Draw player - if (!gameraMode) DrawTexture(turtle, playerBounds.x - 14, playerBounds.y - 14, WHITE); - else DrawTexture(gamera, playerBounds.x - 64, playerBounds.y - 64, WHITE); - - // Draw player bounding box - //if (!gameraMode) DrawRectangleRec(playerBounds, Fade(GREEN, 0.4f)); - //else DrawRectangleRec(playerBounds, Fade(ORANGE, 0.4f)); - - // Draw enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - // Draw enemies - switch(enemyType[i]) - { - case 0: DrawTexture(shark, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 1: DrawTexture(orca, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 2: DrawTexture(swhale, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 3: DrawTexture(fish, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - default: break; - } - - // Draw enemies bounding boxes - /* - switch(enemyType[i]) - { - case 0: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 1: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 2: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 3: DrawRectangleRec(enemyBounds[i], Fade(GREEN, 0.5f)); break; - default: break; - } - */ - } - } - - // Draw gameplay interface - DrawRectangle(20, 20, 400, 40, Fade(GRAY, 0.4f)); - DrawRectangle(20, 20, foodBar, 40, ORANGE); - DrawRectangleLines(20, 20, 400, 40, BLACK); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE); - - if (gameraMode) - { - DrawText("GAMERA MODE", 60, 22, 40, GRAY); - DrawTexture(gframe, 0, 0, Fade(WHITE, 0.5f)); - } - - } break; - case ENDING: - { - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - UnloadTexture(gframe); - UnloadTexture(title); - UnloadTexture(turtle); - UnloadTexture(shark); - UnloadTexture(orca); - UnloadTexture(swhale); - UnloadTexture(fish); - UnloadTexture(gamera); - - // Unload font texture - UnloadFont(font); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/games/drturtle/05_drturtle_audio.c b/games/drturtle/05_drturtle_audio.c deleted file mode 100644 index 4c3ce4ad..00000000 --- a/games/drturtle/05_drturtle_audio.c +++ /dev/null @@ -1,471 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.6 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Initialize audio device - InitAudioDevice(); - - // Load game resources: textures - Texture2D sky = LoadTexture("resources/sky.png"); - Texture2D mountains = LoadTexture("resources/mountains.png"); - Texture2D sea = LoadTexture("resources/sea.png"); - Texture2D title = LoadTexture("resources/title.png"); - Texture2D turtle = LoadTexture("resources/turtle.png"); - Texture2D shark = LoadTexture("resources/shark.png"); - Texture2D orca = LoadTexture("resources/orca.png"); - Texture2D swhale = LoadTexture("resources/swhale.png"); - Texture2D fish = LoadTexture("resources/fish.png"); - Texture2D gamera = LoadTexture("resources/gamera.png"); - Texture2D gframe = LoadTexture("resources/gframe.png"); - - // Load game resources: fonts - Font font = LoadFont("resources/komika.png"); - - // Load game resources: sounds - Sound eat = LoadSound("resources/eat.wav"); - Sound die = LoadSound("resources/die.wav"); - Sound growl = LoadSound("resources/gamera.wav"); - - // Load music stream and start playing music - Music music = LoadMusicStream("resources/speeding.ogg"); - PlayMusicStream(music); - - // Define scrolling variables - int backScrolling = 0; - int seaScrolling = 0; - - // Define current screen - GameScreen currentScreen = TITLE; - - // Define player variables - int playerRail = 1; - Rectangle playerBounds = { 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - bool gameraMode = false; - - // Define enemies variables - Rectangle enemyBounds[MAX_ENEMIES]; - int enemyRail[MAX_ENEMIES]; - int enemyType[MAX_ENEMIES]; - bool enemyActive[MAX_ENEMIES]; - float enemySpeed = 10; - - // Init enemies variables - for (int i = 0; i < MAX_ENEMIES; i++) - { - // Define enemy type (all same probability) - //enemyType[i] = GetRandomValue(0, 3); - - // Probability system for enemies type - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - // Define enemy rail - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - // Define additional game variables - int score = 0; - float distance = 0.0f; - int hiscore = 0; - float hidistance = 0.0f; - int foodBar = 0; - int framesCounter = 0; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdateMusicStream(music); // Refill music stream buffers (if required) - - framesCounter++; - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - framesCounter = 0; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= (enemySpeed - 2); - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Player movement logic - if (IsKeyPressed(KEY_DOWN)) playerRail++; - else if (IsKeyPressed(KEY_UP)) playerRail--; - - // Check player not out of rails - if (playerRail > 4) playerRail = 4; - else if (playerRail < 0) playerRail = 0; - - // Update player bounds - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Enemies activation logic (every 40 frames) - if (framesCounter > 40) - { - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i] == false) - { - enemyActive[i] = true; - i = MAX_ENEMIES; - } - } - - framesCounter = 0; - } - - // Enemies logic - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - enemyBounds[i].x -= enemySpeed; - } - - // Check enemies out of screen - if (enemyBounds[i].x <= 0 - 128) - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - } - } - - if (!gameraMode) enemySpeed += 0.005; - - // Check collision player vs enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - if (CheckCollisionRecs(playerBounds, enemyBounds[i])) - { - if (enemyType[i] < 3) // Bad enemies - { - if (gameraMode) - { - if (enemyType[i] == 0) score += 50; - else if (enemyType[i] == 1) score += 150; - else if (enemyType[i] == 2) score += 300; - - foodBar += 15; - - enemyActive[i] = false; - - // After enemy deactivation, reset enemy parameters to be reused - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - PlaySound(eat); - } - else - { - // Player die logic - PlaySound(die); - - currentScreen = ENDING; - framesCounter = 0; - - // Save hiscore and hidistance for next game - if (score > hiscore) hiscore = score; - if (distance > hidistance) hidistance = distance; - } - } - else // Sweet fish - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - if (!gameraMode) foodBar += 80; - else foodBar += 25; - - score += 10; - - if (foodBar == 400) - { - gameraMode = true; - - PlaySound(growl); - } - - PlaySound(eat); - } - } - } - } - - // Gamera mode logic - if (gameraMode) - { - foodBar--; - - if (foodBar <= 0) - { - gameraMode = false; - enemySpeed -= 2; - if (enemySpeed < 10) enemySpeed = 10; - } - } - - // Update distance counter - distance += 0.5f; - - } break; - case ENDING: - { - // Press enter to play again - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - - // Reset player - playerRail = 1; - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Reset enemies data - for (int i = 0; i < MAX_ENEMIES; i++) - { - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - //enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - enemySpeed = 10; - - // Reset game variables - score = 0; - distance = 0.0; - foodBar = 0; - gameraMode = false; - framesCounter = 0; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - if (!gameraMode) - { - DrawTexture(sea, seaScrolling, 0, (Color){ 16, 189, 227, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 16, 189, 227, 255}); - } - else - { - DrawTexture(sea, seaScrolling, 0, (Color){ 255, 113, 66, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 255, 113, 66, 255}); - } - - switch (currentScreen) - { - case TITLE: - { - // Draw title - DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 0, WHITE); - - } break; - case GAMEPLAY: - { - // Draw water lines - for (int i = 0; i < 5; i++) DrawRectangle(0, i*120 + 120, screenWidth, 110, Fade(SKYBLUE, 0.1f)); - - // Draw player - if (!gameraMode) DrawTexture(turtle, playerBounds.x - 14, playerBounds.y - 14, WHITE); - else DrawTexture(gamera, playerBounds.x - 64, playerBounds.y - 64, WHITE); - - // Draw player bounding box - //if (!gameraMode) DrawRectangleRec(playerBounds, Fade(GREEN, 0.4f)); - //else DrawRectangleRec(playerBounds, Fade(ORANGE, 0.4f)); - - // Draw enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - // Draw enemies - switch(enemyType[i]) - { - case 0: DrawTexture(shark, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 1: DrawTexture(orca, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 2: DrawTexture(swhale, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 3: DrawTexture(fish, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - default: break; - } - - // Draw enemies bounding boxes - /* - switch(enemyType[i]) - { - case 0: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 1: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 2: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 3: DrawRectangleRec(enemyBounds[i], Fade(GREEN, 0.5f)); break; - default: break; - } - */ - } - } - - // Draw gameplay interface - DrawRectangle(20, 20, 400, 40, Fade(GRAY, 0.4f)); - DrawRectangle(20, 20, foodBar, 40, ORANGE); - DrawRectangleLines(20, 20, 400, 40, BLACK); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE); - - if (gameraMode) - { - DrawText("GAMERA MODE", 60, 22, 40, GRAY); - DrawTexture(gframe, 0, 0, Fade(WHITE, 0.5f)); - } - - } break; - case ENDING: - { - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - UnloadTexture(gframe); - UnloadTexture(title); - UnloadTexture(turtle); - UnloadTexture(shark); - UnloadTexture(orca); - UnloadTexture(swhale); - UnloadTexture(fish); - UnloadTexture(gamera); - - // Unload font texture - UnloadFont(font); - - // Unload sounds - UnloadSound(eat); - UnloadSound(die); - UnloadSound(growl); - - UnloadMusicStream(music); // Unload music - CloseAudioDevice(); // Close audio device - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/games/drturtle/06_drturtle_final.c b/games/drturtle/06_drturtle_final.c deleted file mode 100644 index 15dcf09c..00000000 --- a/games/drturtle/06_drturtle_final.c +++ /dev/null @@ -1,495 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.6 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include <math.h> // Used for sinf() - -#define MAX_ENEMIES 10 - -typedef enum { TITLE, GAMEPLAY, ENDING } GameScreen; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1280; - const int screenHeight = 720; - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Initialize audio device - InitAudioDevice(); - - // Load game resources: textures - Texture2D sky = LoadTexture("resources/sky.png"); - Texture2D mountains = LoadTexture("resources/mountains.png"); - Texture2D sea = LoadTexture("resources/sea.png"); - Texture2D title = LoadTexture("resources/title.png"); - Texture2D turtle = LoadTexture("resources/turtle.png"); - Texture2D gamera = LoadTexture("resources/gamera.png"); - Texture2D shark = LoadTexture("resources/shark.png"); - Texture2D orca = LoadTexture("resources/orca.png"); - Texture2D swhale = LoadTexture("resources/swhale.png"); - Texture2D fish = LoadTexture("resources/fish.png"); - Texture2D gframe = LoadTexture("resources/gframe.png"); - - // Load game resources: fonts - Font font = LoadFont("resources/komika.png"); - - // Load game resources: sounds - Sound eat = LoadSound("resources/eat.wav"); - Sound die = LoadSound("resources/die.wav"); - Sound growl = LoadSound("resources/gamera.wav"); - - // Load music stream and start playing music - Music music = LoadMusicStream("resources/speeding.ogg"); - PlayMusicStream(music); - - // Define scrolling variables - int backScrolling = 0; - int seaScrolling = 0; - - // Define current screen - GameScreen currentScreen = TITLE; - - // Define player variables - int playerRail = 1; - Rectangle playerBounds = { 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - bool gameraMode = false; - - // Define enemies variables - Rectangle enemyBounds[MAX_ENEMIES]; - int enemyRail[MAX_ENEMIES]; - int enemyType[MAX_ENEMIES]; - bool enemyActive[MAX_ENEMIES]; - float enemySpeed = 10; - - // Init enemies variables - for (int i = 0; i < MAX_ENEMIES; i++) - { - // Define enemy type (all same probability) - //enemyType[i] = GetRandomValue(0, 3); - - // Probability system for enemies type - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - // define enemy rail - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - // Define additional game variables - int score = 0; - float distance = 0.0f; - int hiscore = 0; - float hidistance = 0.0f; - int foodBar = 0; - int framesCounter = 0; - - unsigned char blue = 200; - float timeCounter = 0; - - SetTargetFPS(60); // Setup game frames per second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdateMusicStream(music); // Refill music stream buffers (if required) - - framesCounter++; - - // Sea color tint effect - blue = 210 + 25 * sinf(timeCounter); - timeCounter += 0.01; - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - framesCounter = 0; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= (enemySpeed - 2); - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Player movement logic - if (IsKeyPressed(KEY_DOWN)) playerRail++; - else if (IsKeyPressed(KEY_UP)) playerRail--; - - // Check player not out of rails - if (playerRail > 4) playerRail = 4; - else if (playerRail < 0) playerRail = 0; - - // Update player bounds - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Enemies activation logic (every 40 frames) - if (framesCounter > 40) - { - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i] == false) - { - enemyActive[i] = true; - i = MAX_ENEMIES; - } - } - - framesCounter = 0; - } - - // Enemies logic - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - enemyBounds[i].x -= enemySpeed; - } - - // Check enemies out of screen - if (enemyBounds[i].x <= 0 - 128) - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - } - } - - if (!gameraMode) enemySpeed += 0.005; - - // Check collision player vs enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - if (CheckCollisionRecs(playerBounds, enemyBounds[i])) - { - if (enemyType[i] < 3) // Bad enemies - { - if (gameraMode) - { - if (enemyType[i] == 0) score += 50; - else if (enemyType[i] == 1) score += 150; - else if (enemyType[i] == 2) score += 300; - - foodBar += 15; - - enemyActive[i] = false; - - // After enemy deactivation, reset enemy parameters to be reused - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - PlaySound(eat); - } - else - { - // Player die logic - PlaySound(die); - - currentScreen = ENDING; - framesCounter = 0; - - // Save hiscore and hidistance for next game - if (score > hiscore) hiscore = score; - if (distance > hidistance) hidistance = distance; - } - } - else // Sweet fish - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - if (!gameraMode) foodBar += 80; - else foodBar += 25; - - score += 10; - - if (foodBar == 400) - { - gameraMode = true; - - PlaySound(growl); - } - - PlaySound(eat); - } - } - } - } - - // Gamera mode logic - if (gameraMode) - { - foodBar--; - - if (foodBar <= 0) - { - gameraMode = false; - enemySpeed -= 2; - if (enemySpeed < 10) enemySpeed = 10; - } - } - - // Update distance counter - distance += 0.5f; - - } break; - case ENDING: - { - // Press enter to play again - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - - // Reset player - playerRail = 1; - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - gameraMode = false; - - // Reset enemies data - for (int i = 0; i < MAX_ENEMIES; i++) - { - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - //enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - enemySpeed = 10; - - // Reset game variables - score = 0; - distance = 0.0; - foodBar = 0; - framesCounter = 0; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - if (!gameraMode) - { - DrawTexture(sea, seaScrolling, 0, (Color){ 16, 189, blue, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 16, 189, blue, 255}); - } - else - { - DrawTexture(sea, seaScrolling, 0, (Color){ 255, 113, 66, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 255, 113, 66, 255}); - } - - switch (currentScreen) - { - case TITLE: - { - // Draw title - DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 0, WHITE); - - } break; - case GAMEPLAY: - { - // Draw water lines - for (int i = 0; i < 5; i++) DrawRectangle(0, i*120 + 120, screenWidth, 110, Fade(SKYBLUE, 0.1f)); - - // Draw player - if (!gameraMode) DrawTexture(turtle, playerBounds.x - 14, playerBounds.y - 14, WHITE); - else DrawTexture(gamera, playerBounds.x - 64, playerBounds.y - 64, WHITE); - - // Draw player bounding box - //if (!gameraMode) DrawRectangleRec(playerBounds, Fade(GREEN, 0.4f)); - //else DrawRectangleRec(playerBounds, Fade(ORANGE, 0.4f)); - - // Draw enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - // Draw enemies - switch(enemyType[i]) - { - case 0: DrawTexture(shark, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 1: DrawTexture(orca, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 2: DrawTexture(swhale, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 3: DrawTexture(fish, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - default: break; - } - - // Draw enemies bounding boxes - /* - switch(enemyType[i]) - { - case 0: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 1: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 2: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 3: DrawRectangleRec(enemyBounds[i], Fade(GREEN, 0.5f)); break; - default: break; - } - */ - } - } - - // Draw gameplay interface - DrawRectangle(20, 20, 400, 40, Fade(GRAY, 0.4f)); - DrawRectangle(20, 20, foodBar, 40, ORANGE); - DrawRectangleLines(20, 20, 400, 40, BLACK); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE); - - if (gameraMode) - { - DrawText("GAMERA MODE", 60, 22, 40, GRAY); - DrawTexture(gframe, 0, 0, Fade(WHITE, 0.5f)); - } - - } break; - case ENDING: - { - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - UnloadTexture(gframe); - UnloadTexture(title); - UnloadTexture(turtle); - UnloadTexture(shark); - UnloadTexture(orca); - UnloadTexture(swhale); - UnloadTexture(fish); - UnloadTexture(gamera); - - // Unload font texture - UnloadFont(font); - - // Unload sounds - UnloadSound(eat); - UnloadSound(die); - UnloadSound(growl); - - UnloadMusicStream(music); // Unload music - CloseAudioDevice(); // Close audio device - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/games/drturtle/CMakeLists.txt b/games/drturtle/CMakeLists.txt deleted file mode 100644 index f5778d9c..00000000 --- a/games/drturtle/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -project(drturtle) - -# Executable & linking -add_executable(${PROJECT_NAME} 06_drturtle_final.c) -if (NOT TARGET raylib) - find_package(raylib 2.0 REQUIRED) -endif() -target_link_libraries(${PROJECT_NAME} raylib) - -# Resources -# Copy all of the resource files to the destination -file(COPY "resources/" DESTINATION "resources/") diff --git a/games/drturtle/LICENSE.txt b/games/drturtle/LICENSE.txt deleted file mode 100644 index 510604da..00000000 --- a/games/drturtle/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ - -This game sources are licensed under an unmodified zlib/libpng license, -which is an OSI-certified, BSD-like license: - -Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) - -This software is provided "as-is", without any express or implied warranty. In no event -will the authors be held liable for any damages arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, including commercial -applications, and to alter it and redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not claim that you - wrote the original software. If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be misrepresented - as being the original software. - - 3. This notice may not be removed or altered from any source distribution.
\ No newline at end of file diff --git a/games/drturtle/Makefile b/games/drturtle/Makefile deleted file mode 100644 index ce272e47..00000000 --- a/games/drturtle/Makefile +++ /dev/null @@ -1,385 +0,0 @@ -#************************************************************************************************** -# -# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 -# -# Copyright (c) 2013-2020 Ramon Santamaria (@raysan5) -# -# This software is provided "as-is", without any express or implied warranty. In no event -# will the authors be held liable for any damages arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, including commercial -# applications, and to alter it and redistribute it freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim that you -# wrote the original software. If you use this software in a product, an acknowledgment -# in the product documentation would be appreciated but is not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be misrepresented -# as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution. -# -#************************************************************************************************** - -.PHONY: all clean - -# Define required raylib variables -PROJECT_NAME ?= drturtle -RAYLIB_VERSION ?= 3.0.0 -RAYLIB_API_VERSION ?= 3 -RAYLIB_PATH ?= C:\GitHub\raylib - -# Define default options - -# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP - -# Locations of your newly installed library and associated headers. See ../src/Makefile -# On Linux, if you have installed raylib but cannot compile the examples, check that -# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. -# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED. -# To enable compile-time linking to a special version of libraylib.so, change these variables here. -# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below. -# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime, -# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH. -# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. -DESTDIR ?= /usr/local -RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib -# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. -RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include - -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC - -# Build mode for project: DEBUG or RELEASE -BUILD_MODE ?= RELEASE - -# Use external GLFW library instead of rglfw module -# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 -USE_EXTERNAL_GLFW ?= FALSE - -# Use Wayland display server protocol on Linux desktop -# by default it uses X11 windowing system -USE_WAYLAND_DISPLAY ?= FALSE - -# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! - # ifeq ($(UNAME),Msys) -> Windows - ifeq ($(OS),Windows_NT) - PLATFORM_OS=WINDOWS - else - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif - ifeq ($(UNAMEOS),FreeBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),OpenBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),NetBSD) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),DragonFly) - PLATFORM_OS=BSD - endif - ifeq ($(UNAMEOS),Darwin) - PLATFORM_OS=OSX - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - UNAMEOS=$(shell uname) - ifeq ($(UNAMEOS),Linux) - PLATFORM_OS=LINUX - endif -endif - -# RAYLIB_PATH adjustment for different platforms. -# If using GNU make, we can get the full path to the top of the tree. Windows? BSD? -# Required for ldconfig or other tools that do not perform path expansion. -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_PREFIX ?= .. - RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) - endif -endif -# Default path for raylib on Raspberry Pi, if installed in different path, update it! -# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki. -# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX. -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif - -ifeq ($(PLATFORM),PLATFORM_WEB) - # Emscripten required variables - EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten - CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin - PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 - NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin - export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) -endif - -# Define raylib release directory for compiled library. -# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src - -# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries -# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH -# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux -# without formal installation from ../src/Makefile. It aids portability and is useful if you have -# multiple versions of raylib, have raylib installed to a non-standard location, or want to -# bundle libraylib.so with your game. Change it to your liking. -# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, -# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH, -# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) -# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute. -# To see which libraries a built example is linking to, ldd core/core_basic_window; -# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. -EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) - -# Define default C compiler: gcc -# NOTE: define g++ compiler if using C++ -CC = gcc - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),OSX) - # OSX default compiler - CC = clang - endif - ifeq ($(PLATFORM_OS),BSD) - # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler - CC = clang - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) - # Define RPI cross-compiler - #CC = armv6j-hardfloat-linux-gnueabi-gcc - CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc - endif -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # HTML5 emscripten compiler - # WARNING: To compile to HTML5, code must be redesigned - # to use emscripten.h and emscripten_set_main_loop() - CC = emcc -endif - -# Define default make program: Mingw32-make -MAKE = mingw32-make - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - MAKE = make - endif -endif - -# Define compiler flags: -# -O1 defines optimization level -# -g include debug information on compilation -# -s strip unnecessary data from build -# -Wall turns on most, but not all, compiler warnings -# -std=c99 defines C language mode (standard C from 1999 revision) -# -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces - -ifeq ($(BUILD_MODE),DEBUG) - CFLAGS += -g - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -s ASSERTIONS=1 --profiling - endif -else - ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -Os - else - CFLAGS += -s -O1 - endif -endif - -# Additional flags for compiler (if desired) -#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),LINUX) - ifeq ($(RAYLIB_LIBTYPE),STATIC) - CFLAGS += -D_DEFAULT_SOURCE - endif - ifeq ($(RAYLIB_LIBTYPE),SHARED) - # Explicitly enable runtime link to libraylib.so - CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) - endif - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - CFLAGS += -std=gnu99 -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # -Os # size optimization - # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # --profiling # include information for code profiling - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources - - # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html - EXT = .html -endif - -# Define include paths for required headers -# NOTE: Several external required libraries (stb and others) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external - -# Define additional directories containing required header files -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI required libraries - INCLUDE_PATHS += -I/opt/vc/include - INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_H_INSTALL_PATH) - INCLUDE_PATHS += -I/usr/local/include - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include - INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external - endif -endif - -# Define library paths containing required libs. -LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src - -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # resource file contains windows executable icon and properties - LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data - # -Wl,--subsystem,windows hides the console window - ifeq ($(BUILD_MODE), RELEASE) - LDFLAGS += -Wl,--subsystem,windows - endif - endif - ifeq ($(PLATFORM_OS),BSD) - # Consider -L$(RAYLIB_INSTALL_PATH) - LDFLAGS += -L. -Lsrc -L/usr/local/lib - endif - ifeq ($(PLATFORM_OS),LINUX) - # Reset everything. - # Precedence: immediately local, installed version, raysan5 provided libs - LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) - endif -endif - -ifeq ($(PLATFORM),PLATFORM_RPI) - LDFLAGS += -L/opt/vc/lib -endif - -# Define any libraries required on linking -# if you want to link libraries (libname.so or libname.a), use the -lname -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - # Libraries for Windows desktop compilation - # NOTE: WinMM library required to set high-res timer resolution - LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - LDLIBS += -static -lpthread - endif - ifeq ($(PLATFORM_OS),LINUX) - # Libraries for Debian GNU/Linux desktop compiling - # NOTE: Required packages: libegl1-mesa-dev - LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - - # On X11 requires also below libraries - LDLIBS += -lX11 - # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them - #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - - # On Wayland windowing system, additional libraries requires - ifeq ($(USE_WAYLAND_DISPLAY),TRUE) - LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon - endif - # Explicit link to libc - ifeq ($(RAYLIB_LIBTYPE),SHARED) - LDLIBS += -lc - endif - endif - ifeq ($(PLATFORM_OS),OSX) - # Libraries for OSX 10.9 desktop compiling - # NOTE: Required packages: libopenal-dev libegl1-mesa-dev - LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo - endif - ifeq ($(PLATFORM_OS),BSD) - # Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling - # NOTE: Required packages: mesa-libs - LDLIBS = -lraylib -lGL -lpthread -lm - - # On XWindow requires also below libraries - LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - endif - ifeq ($(USE_EXTERNAL_GLFW),TRUE) - # NOTE: It could require additional packages installed: libglfw3-dev - LDLIBS += -lglfw - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # Libraries for Raspberry Pi compiling - # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc -endif - -# Define all source files required -SCREENS = drturtle_final_web \ - -# typing 'make' will invoke the default target entry -all: $(SCREENS) - -%: %.c -ifeq ($(PLATFORM),PLATFORM_ANDROID) - $(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$< -else - $(CC) -o $(PROJECT_NAME)$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -endif - -# Clean everything -clean: -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - del *.o *.exe /s - endif - ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv - endif - ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete - rm -f *.o - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - find . -type f -executable -delete - rm -fv *.o -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - del *.o *.html *.js -endif - @echo Cleaning done - diff --git a/games/drturtle/drturtle_final_web.c b/games/drturtle/drturtle_final_web.c deleted file mode 100644 index 0b639e38..00000000 --- a/games/drturtle/drturtle_final_web.c +++ /dev/null @@ -1,544 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Dr. Turtle & Mr. Gamera -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This game has been created using raylib 1.6 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include <math.h> // Used for sinf() - -#if defined(PLATFORM_WEB) - #include <emscripten/emscripten.h> -#endif - -#define MAX_ENEMIES 10 - -typedef enum { TITLE = 0, GAMEPLAY, ENDING } GameScreen; - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- -const int screenWidth = 1280; -const int screenHeight = 720; - -Texture2D sky; -Texture2D mountains; -Texture2D sea; -Texture2D title; -Texture2D turtle; -Texture2D gamera; -Texture2D shark; -Texture2D orca; -Texture2D swhale; -Texture2D fish; -Texture2D gframe; - -Font font; - -Sound eat; -Sound die; -Sound growl; - -Music music; - -// Define scrolling variables -int backScrolling = 0; -int seaScrolling = 0; - -// Define current screen -GameScreen currentScreen = 0; - -// Define player variables -int playerRail = 1; -Rectangle playerBounds; -bool gameraMode = false; - -// Define enemies variables -Rectangle enemyBounds[MAX_ENEMIES]; -int enemyRail[MAX_ENEMIES]; -int enemyType[MAX_ENEMIES]; -bool enemyActive[MAX_ENEMIES]; -float enemySpeed = 10; - -// Define additional game variables -int score = 0; -float distance = 0.0f; -int hiscore = 0; -float hidistance = 0.0f; -int foodBar = 0; -int framesCounter = 0; - -unsigned char blue = 200; -float timeCounter = 0; - -//---------------------------------------------------------------------------------- -// Module Functions Declaration -//---------------------------------------------------------------------------------- -void UpdateDrawFrame(void); // Update and Draw one frame - -//---------------------------------------------------------------------------------- -// Main Enry Point -//---------------------------------------------------------------------------------- -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - - // Init window - InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); - - // Initialize audio device - InitAudioDevice(); - - // Load game resources: textures - sky = LoadTexture("resources/sky.png"); - mountains = LoadTexture("resources/mountains.png"); - sea = LoadTexture("resources/sea.png"); - title = LoadTexture("resources/title.png"); - turtle = LoadTexture("resources/turtle.png"); - gamera = LoadTexture("resources/gamera.png"); - shark = LoadTexture("resources/shark.png"); - orca = LoadTexture("resources/orca.png"); - swhale = LoadTexture("resources/swhale.png"); - fish = LoadTexture("resources/fish.png"); - gframe = LoadTexture("resources/gframe.png"); - - // Load game resources: fonts - font = LoadFont("resources/komika.png"); - - // Load game resources: sounds - eat = LoadSound("resources/eat.wav"); - die = LoadSound("resources/die.wav"); - growl = LoadSound("resources/gamera.wav"); - - // Load music stream and start playing music - music = LoadMusicStream("resources/speeding.ogg"); - PlayMusicStream(music); - - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Init enemies variables - for (int i = 0; i < MAX_ENEMIES; i++) - { - // Define enemy type (all same probability) - //enemyType[i] = GetRandomValue(0, 3); - - // Probability system for enemies type - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - // define enemy rail - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - -#if defined(PLATFORM_WEB) - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); -#else - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - UpdateDrawFrame(); - } -#endif - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures - UnloadTexture(sky); - UnloadTexture(mountains); - UnloadTexture(sea); - UnloadTexture(gframe); - UnloadTexture(title); - UnloadTexture(turtle); - UnloadTexture(shark); - UnloadTexture(orca); - UnloadTexture(swhale); - UnloadTexture(fish); - UnloadTexture(gamera); - - // Unload font texture - UnloadFont(font); - - // Unload sounds - UnloadSound(eat); - UnloadSound(die); - UnloadSound(growl); - - UnloadMusicStream(music); // Unload music - CloseAudioDevice(); // Close audio device - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//---------------------------------------------------------------------------------- -// Module Functions Definition -//---------------------------------------------------------------------------------- -void UpdateDrawFrame(void) -{ - // Update - //---------------------------------------------------------------------------------- - UpdateMusicStream(music); // Refill music stream buffers (if required) - - framesCounter++; - - // Sea color tint effect - blue = 210 + 25 * sinf(timeCounter); - timeCounter += 0.01; - - // Game screens management - switch (currentScreen) - { - case TITLE: - { - // Sea scrolling - seaScrolling -= 2; - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Press enter to change to gameplay screen - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - framesCounter = 0; - } - - } break; - case GAMEPLAY: - { - // Background scrolling logic - backScrolling--; - if (backScrolling <= -screenWidth) backScrolling = 0; - - // Sea scrolling logic - seaScrolling -= (enemySpeed - 2); - if (seaScrolling <= -screenWidth) seaScrolling = 0; - - // Player movement logic - if (IsKeyPressed(KEY_DOWN)) playerRail++; - else if (IsKeyPressed(KEY_UP)) playerRail--; - - // Check player not out of rails - if (playerRail > 4) playerRail = 4; - else if (playerRail < 0) playerRail = 0; - - // Update player bounds - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - - // Enemies activation logic (every 40 frames) - if (framesCounter > 40) - { - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i] == false) - { - enemyActive[i] = true; - i = MAX_ENEMIES; - } - } - - framesCounter = 0; - } - - // Enemies logic - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - enemyBounds[i].x -= enemySpeed; - } - - // Check enemies out of screen - if (enemyBounds[i].x <= 0 - 128) - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - } - } - - if (!gameraMode) enemySpeed += 0.005; - - // Check collision player vs enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - if (CheckCollisionRecs(playerBounds, enemyBounds[i])) - { - if (enemyType[i] < 3) // Bad enemies - { - if (gameraMode) - { - if (enemyType[i] == 0) score += 50; - else if (enemyType[i] == 1) score += 150; - else if (enemyType[i] == 2) score += 300; - - foodBar += 15; - - enemyActive[i] = false; - - // After enemy deactivation, reset enemy parameters to be reused - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - PlaySound(eat); - } - else - { - // Player die logic - PlaySound(die); - - currentScreen = ENDING; - framesCounter = 0; - - // Save hiscore and hidistance for next game - if (score > hiscore) hiscore = score; - if (distance > hidistance) hidistance = distance; - } - } - else // Sweet fish - { - enemyActive[i] = false; - enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - - if (!gameraMode) foodBar += 80; - else foodBar += 25; - - score += 10; - - if (foodBar == 400) - { - gameraMode = true; - - PlaySound(growl); - } - - PlaySound(eat); - } - } - } - } - - // Gamera mode logic - if (gameraMode) - { - foodBar--; - - if (foodBar <= 0) - { - gameraMode = false; - enemySpeed -= 2; - if (enemySpeed < 10) enemySpeed = 10; - } - } - - // Update distance counter - distance += 0.5f; - - } break; - case ENDING: - { - // Press enter to play again - if (IsKeyPressed(KEY_ENTER)) - { - currentScreen = GAMEPLAY; - - // Reset player - playerRail = 1; - playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; - gameraMode = false; - - // Reset enemies data - for (int i = 0; i < MAX_ENEMIES; i++) - { - int enemyProb = GetRandomValue(0, 100); - - if (enemyProb < 30) enemyType[i] = 0; - else if (enemyProb < 60) enemyType[i] = 1; - else if (enemyProb < 90) enemyType[i] = 2; - else enemyType[i] = 3; - - //enemyType[i] = GetRandomValue(0, 3); - enemyRail[i] = GetRandomValue(0, 4); - - // Make sure not two consecutive enemies in the same row - if (i > 0) while (enemyRail[i] == enemyRail[i - 1]) enemyRail[i] = GetRandomValue(0, 4); - - enemyBounds[i] = (Rectangle){ screenWidth + 14, 120*enemyRail[i] + 90 + 14, 100, 100 }; - enemyActive[i] = false; - } - - enemySpeed = 10; - - // Reset game variables - score = 0; - distance = 0.0; - foodBar = 0; - framesCounter = 0; - } - - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw background (common to all screens) - DrawTexture(sky, 0, 0, WHITE); - - DrawTexture(mountains, backScrolling, 0, WHITE); - DrawTexture(mountains, screenWidth + backScrolling, 0, WHITE); - - if (!gameraMode) - { - DrawTexture(sea, seaScrolling, 0, (Color){ 16, 189, blue, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 16, 189, blue, 255}); - } - else - { - DrawTexture(sea, seaScrolling, 0, (Color){ 255, 113, 66, 255}); - DrawTexture(sea, screenWidth + seaScrolling, 0, (Color){ 255, 113, 66, 255}); - } - - switch (currentScreen) - { - case TITLE: - { - // Draw title - DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 1, WHITE); - - } break; - case GAMEPLAY: - { - // Draw water lines - for (int i = 0; i < 5; i++) DrawRectangle(0, i*120 + 120, screenWidth, 110, Fade(SKYBLUE, 0.1f)); - - // Draw player - if (!gameraMode) DrawTexture(turtle, playerBounds.x - 14, playerBounds.y - 14, WHITE); - else DrawTexture(gamera, playerBounds.x - 64, playerBounds.y - 64, WHITE); - - // Draw player bounding box - //if (!gameraMode) DrawRectangleRec(playerBounds, Fade(GREEN, 0.4f)); - //else DrawRectangleRec(playerBounds, Fade(ORANGE, 0.4f)); - - // Draw enemies - for (int i = 0; i < MAX_ENEMIES; i++) - { - if (enemyActive[i]) - { - // Draw enemies - switch(enemyType[i]) - { - case 0: DrawTexture(shark, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 1: DrawTexture(orca, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 2: DrawTexture(swhale, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - case 3: DrawTexture(fish, enemyBounds[i].x - 14, enemyBounds[i].y - 14, WHITE); break; - default: break; - } - - // Draw enemies bounding boxes - /* - switch(enemyType[i]) - { - case 0: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 1: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 2: DrawRectangleRec(enemyBounds[i], Fade(RED, 0.5f)); break; - case 3: DrawRectangleRec(enemyBounds[i], Fade(GREEN, 0.5f)); break; - default: break; - } - */ - } - } - - // Draw gameplay interface - DrawRectangle(20, 20, 400, 40, Fade(GRAY, 0.4f)); - DrawRectangle(20, 20, foodBar, 40, ORANGE); - DrawRectangleLines(20, 20, 400, 40, BLACK); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE); - - if (gameraMode) - { - DrawText("GAMERA MODE", 60, 22, 40, GRAY); - DrawTexture(gframe, 0, 0, Fade(WHITE, 0.5f)); - } - - } break; - case ENDING: - { - // Draw a transparent black rectangle that covers all screen - DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); - - DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON); - - DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD); - DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE); - DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE); - - // Draw blinking text - if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY); - - } break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- -} diff --git a/games/drturtle/resources/die.wav b/games/drturtle/resources/die.wav Binary files differdeleted file mode 100644 index 277ae356..00000000 --- a/games/drturtle/resources/die.wav +++ /dev/null diff --git a/games/drturtle/resources/eat.wav b/games/drturtle/resources/eat.wav Binary files differdeleted file mode 100644 index e1c33a4c..00000000 --- a/games/drturtle/resources/eat.wav +++ /dev/null diff --git a/games/drturtle/resources/fish.png b/games/drturtle/resources/fish.png Binary files differdeleted file mode 100644 index dca5956e..00000000 --- a/games/drturtle/resources/fish.png +++ /dev/null diff --git a/games/drturtle/resources/gamera.png b/games/drturtle/resources/gamera.png Binary files differdeleted file mode 100644 index 9c2fea71..00000000 --- a/games/drturtle/resources/gamera.png +++ /dev/null diff --git a/games/drturtle/resources/gamera.wav b/games/drturtle/resources/gamera.wav Binary files differdeleted file mode 100644 index deb79230..00000000 --- a/games/drturtle/resources/gamera.wav +++ /dev/null diff --git a/games/drturtle/resources/gframe.png b/games/drturtle/resources/gframe.png Binary files differdeleted file mode 100644 index 5946589e..00000000 --- a/games/drturtle/resources/gframe.png +++ /dev/null diff --git a/games/drturtle/resources/komika.png b/games/drturtle/resources/komika.png Binary files differdeleted file mode 100644 index 2c2ab714..00000000 --- a/games/drturtle/resources/komika.png +++ /dev/null diff --git a/games/drturtle/resources/mountains.png b/games/drturtle/resources/mountains.png Binary files differdeleted file mode 100644 index f193f504..00000000 --- a/games/drturtle/resources/mountains.png +++ /dev/null diff --git a/games/drturtle/resources/orca.png b/games/drturtle/resources/orca.png Binary files differdeleted file mode 100644 index b580ef07..00000000 --- a/games/drturtle/resources/orca.png +++ /dev/null diff --git a/games/drturtle/resources/sea.png b/games/drturtle/resources/sea.png Binary files differdeleted file mode 100644 index 34593536..00000000 --- a/games/drturtle/resources/sea.png +++ /dev/null diff --git a/games/drturtle/resources/shark.png b/games/drturtle/resources/shark.png Binary files differdeleted file mode 100644 index 24a56957..00000000 --- a/games/drturtle/resources/shark.png +++ /dev/null diff --git a/games/drturtle/resources/sky.png b/games/drturtle/resources/sky.png Binary files differdeleted file mode 100644 index e75715c9..00000000 --- a/games/drturtle/resources/sky.png +++ /dev/null diff --git a/games/drturtle/resources/speeding.ogg b/games/drturtle/resources/speeding.ogg Binary files differdeleted file mode 100644 index eeac47f3..00000000 --- a/games/drturtle/resources/speeding.ogg +++ /dev/null diff --git a/games/drturtle/resources/swhale.png b/games/drturtle/resources/swhale.png Binary files differdeleted file mode 100644 index 5652928c..00000000 --- a/games/drturtle/resources/swhale.png +++ /dev/null diff --git a/games/drturtle/resources/title.png b/games/drturtle/resources/title.png Binary files differdeleted file mode 100644 index 9ddd0de3..00000000 --- a/games/drturtle/resources/title.png +++ /dev/null diff --git a/games/drturtle/resources/turtle.png b/games/drturtle/resources/turtle.png Binary files differdeleted file mode 100644 index 52ce9691..00000000 --- a/games/drturtle/resources/turtle.png +++ /dev/null |
