| @ -1,28 +1,37 @@ | |||
| roadmap | |||
| ------- | |||
| Current version of raylib is quite complete and functional but there is still a lot of things I would like to improve. | |||
| Here it is a list of features I would like to add and functions to improve. | |||
| Around the source code there are multiple TODO points with pending revisions/bugs and here it is a list of desired features. | |||
| raylib v1.4 | |||
| [DONE] TTF fonts support (using stb_truetype) | |||
| [DONE] Raycast system for 3D picking (including collisions detection) | |||
| [DONE] Floyd-Steinberg dithering on 16bit image format conversion | |||
| [DONE] Basic image manipulation functions (crop, resize, draw...) | |||
| [DONE] Storage load/save data functionality | |||
| [DONE] Physics module | |||
| [IN PROGRESS] LUA scripting support (wrapper to lua lib) | |||
| - Remove GLEW dependency (use another solution... glad?) | |||
| - Basic image procedural generation (spot, gradient, noise...) | |||
| - Basic GPU stats sytem (memory, draws, time...) | |||
| Check [GITHUB ISSUES][issues] for further details on implementation status for this features! | |||
| Current version of raylib is quite complete and functional but there is still a lot of things to add and improve. | |||
| Here it is a wish list of features I would like to add and functions to improve. | |||
| Note that around the raylib source code there are multiple TODO points with pending revisions/bugs. Check [GITHUB ISSUES][issues] for further details! | |||
| raylib 1.5 | |||
| Redesign Shaders/Textures system, use Materials | |||
| Redesign physics module (physac) | |||
| Basic GPU stats sytem (memory, draws, time...) | |||
| Procedural image generation functions (spot, gradient, noise...) | |||
| Procedural mesh generation functions (cube, cone, sphere...) | |||
| Touch-based camera controls for Android | |||
| Skybox and Fog support | |||
| [IN PROGRESS] LUA scripting support (wrapper to lua lib) | |||
| raylib 1.4 | |||
| [DONE] TTF fonts support (using stb_truetype) | |||
| [DONE] Raycast system for 3D picking (including collisions detection) | |||
| [DONE] Floyd-Steinberg dithering on 16bit image format conversion | |||
| [DONE] Basic image manipulation functions (crop, resize, draw...) | |||
| [DONE] Storage load/save data functionality | |||
| [DONE] Add Physics module (physac) | |||
| [DONE] Remove GLEW dependency -> Replaced by GLAD | |||
| [DONE] Redesign Raspberry PI inputs system | |||
| [DONE] Redesign gestures module to be multiplatform | |||
| [DONE] Module raymath as header-only and functions inline | |||
| [DONE] Add Easings module (easings.h) | |||
| Any feature missing? Do you have a request? [Let me know!][raysan5] | |||
| [raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San" | |||
| [raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San" | |||
| [isssues]: https://github.com/raysan5/raylib/issues | |||
| @ -0,0 +1,541 @@ | |||
| /******************************************************************************************* | |||
| * | |||
| * 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 (Ray San - raysan@raysanweb.com) | |||
| * | |||
| ********************************************************************************************/ | |||
| #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; | |||
| SpriteFont font; | |||
| Sound eat; | |||
| Sound die; | |||
| Sound growl; | |||
| // 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 = LoadSpriteFont("resources/komika.png"); | |||
| // Load game resources: sounds | |||
| eat = LoadSound("resources/eat.wav"); | |||
| die = LoadSound("resources/die.wav"); | |||
| growl = LoadSound("resources/gamera.wav"); | |||
| // Start playing streaming music | |||
| PlayMusicStream("resources/speeding.ogg"); | |||
| 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 | |||
| UnloadSpriteFont(font); | |||
| // Unload sounds | |||
| UnloadSound(eat); | |||
| UnloadSound(die); | |||
| UnloadSound(growl); | |||
| StopMusicStream(); // Stop music | |||
| CloseAudioDevice(); // Close audio device | |||
| CloseWindow(); // Close window and OpenGL context | |||
| //-------------------------------------------------------------------------------------- | |||
| return 0; | |||
| } | |||
| //---------------------------------------------------------------------------------- | |||
| // Module Functions Definition | |||
| //---------------------------------------------------------------------------------- | |||
| void UpdateDrawFrame(void) | |||
| { | |||
| // Update | |||
| //---------------------------------------------------------------------------------- | |||
| UpdateMusicStream(); | |||
| 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.size, 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.size, -2, ORANGE); | |||
| DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.size, -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.size*3, -2, MAROON); | |||
| DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.size, -2, GOLD); | |||
| DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.size, -2, GOLD); | |||
| DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.size, -2, ORANGE); | |||
| DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.size, -2, ORANGE); | |||
| // Draw blinking text | |||
| if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.size, -2, LIGHTGRAY); | |||
| } break; | |||
| default: break; | |||
| } | |||
| EndDrawing(); | |||
| //---------------------------------------------------------------------------------- | |||
| } | |||
| @ -0,0 +1,186 @@ | |||
| #************************************************************************************************** | |||
| # | |||
| # raylib - makefile to compile Dr.Turtle game | |||
| # | |||
| # Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) | |||
| # | |||
| # 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. | |||
| # | |||
| #************************************************************************************************** | |||
| # define raylib platform if not defined (by default, compile for RPI) | |||
| # Other possible platform: PLATFORM_DESKTOP | |||
| PLATFORM ?= PLATFORM_DESKTOP | |||
| # 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 | |||
| LIBPATH=win32 | |||
| else | |||
| UNAMEOS:=$(shell uname) | |||
| ifeq ($(UNAMEOS),Linux) | |||
| PLATFORM_OS=LINUX | |||
| LIBPATH=linux | |||
| else | |||
| ifeq ($(UNAMEOS),Darwin) | |||
| PLATFORM_OS=OSX | |||
| LIBPATH=osx | |||
| endif | |||
| endif | |||
| endif | |||
| endif | |||
| # define compiler: gcc for C program, define as g++ for C++ | |||
| ifeq ($(PLATFORM),PLATFORM_WEB) | |||
| # define emscripten compiler | |||
| CC = emcc | |||
| else | |||
| ifeq ($(PLATFORM_OS),OSX) | |||
| # define llvm compiler for mac | |||
| CC = clang | |||
| else | |||
| # define default gcc compiler | |||
| CC = gcc | |||
| endif | |||
| endif | |||
| # define compiler flags: | |||
| # -O2 defines optimization level | |||
| # -Wall turns on most, but not all, compiler warnings | |||
| # -std=c99 use standard C from 1999 revision | |||
| ifeq ($(PLATFORM),PLATFORM_RPI) | |||
| CFLAGS = -O2 -Wall -std=gnu99 -fgnu89-inline | |||
| else | |||
| CFLAGS = -O2 -Wall -std=c99 | |||
| endif | |||
| ifeq ($(PLATFORM),PLATFORM_WEB) | |||
| CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 --preload-file resources -s ALLOW_MEMORY_GROWTH=1 --shell-file ../../templates/web_shell/shell.html | |||
| #-s ASSERTIONS=1 --preload-file resources | |||
| #-s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing | |||
| #-s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) | |||
| endif | |||
| # define any directories containing required header files | |||
| ifeq ($(PLATFORM),PLATFORM_RPI) | |||
| INCLUDES = -I. -I../../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads | |||
| else | |||
| INCLUDES = -I. -I../../src | |||
| # external libraries headers | |||
| # GLFW3 | |||
| INCLUDES += -I../../external/glfw3/include | |||
| # GLEW | |||
| INCLUDES += -I../../external/glew/include | |||
| # OpenAL Soft | |||
| INCLUDES += -I../../external/openal_soft/include | |||
| endif | |||
| # define library paths containing required libs | |||
| ifeq ($(PLATFORM),PLATFORM_RPI) | |||
| LFLAGS = -L. -L../../src -L/opt/vc/lib | |||
| else | |||
| LFLAGS = -L. -L../../src | |||
| # external libraries to link with | |||
| # GLFW3 | |||
| LFLAGS += -L../../external/glfw3/lib/$(LIBPATH) | |||
| ifneq ($(PLATFORM_OS),OSX) | |||
| # OpenAL Soft | |||
| LFLAGS += -L../../external/openal_soft/lib/$(LIBPATH) | |||
| # GLEW | |||
| LFLAGS += -L../../external/glew/lib/$(LIBPATH) | |||
| endif | |||
| endif | |||
| # define any libraries to link into executable | |||
| # if you want to link libraries (libname.so or libname.a), use the -lname | |||
| ifeq ($(PLATFORM),PLATFORM_DESKTOP) | |||
| ifeq ($(PLATFORM_OS),LINUX) | |||
| # libraries for Debian GNU/Linux desktop compiling | |||
| # requires the following packages: | |||
| # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev | |||
| LIBS = -lraylib -lglfw -lGLEW -lGL -lopenal | |||
| endif | |||
| ifeq ($(PLATFORM_OS),OSX) | |||
| # libraries for OS X 10.9 desktop compiling | |||
| # requires the following packages: | |||
| # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev | |||
| LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa | |||
| else | |||
| # libraries for Windows desktop compiling | |||
| # NOTE: GLFW3 and OpenAL Soft libraries should be installed | |||
| LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32 | |||
| endif | |||
| endif | |||
| ifeq ($(PLATFORM),PLATFORM_RPI) | |||
| # libraries for Raspberry Pi compiling | |||
| # NOTE: OpenAL Soft library should be installed (libopenal1 package) | |||
| LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal | |||
| endif | |||
| ifeq ($(PLATFORM),PLATFORM_WEB) | |||
| LIBS = ../../src/libraylib.bc | |||
| endif | |||
| # define additional parameters and flags for windows | |||
| ifeq ($(PLATFORM_OS),WINDOWS) | |||
| # resources file contains windows exe icon | |||
| # -Wl,--subsystem,windows hides the console window | |||
| WINFLAGS = ../../src/resources -Wl,--subsystem,windows | |||
| endif | |||
| ifeq ($(PLATFORM),PLATFORM_WEB) | |||
| EXT = .html | |||
| endif | |||
| # define all screen object files required | |||
| SCREENS = \ | |||
| # typing 'make' will invoke the first target entry in the file, | |||
| # in this case, the 'default' target entry is advance_game | |||
| default: drturtle | |||
| # compile template - advance_game | |||
| drturtle: drturtle_final_web.c $(SCREENS) | |||
| $(CC) -o $@$(EXT) $< $(SCREENS) $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) | |||
| # clean everything | |||
| clean: | |||
| ifeq ($(PLATFORM),PLATFORM_DESKTOP) | |||
| ifeq ($(PLATFORM_OS),OSX) | |||
| find . -type f -perm +ugo+x -delete | |||
| rm -f *.o | |||
| else | |||
| ifeq ($(PLATFORM_OS),LINUX) | |||
| find . -type f -executable -delete | |||
| rm -f *.o | |||
| else | |||
| del *.o *.exe | |||
| endif | |||
| endif | |||
| endif | |||
| ifeq ($(PLATFORM),PLATFORM_RPI) | |||
| find . -type f -executable -delete | |||
| rm -f *.o | |||
| endif | |||
| ifeq ($(PLATFORM),PLATFORM_WEB) | |||
| del *.o *.html *.js | |||
| endif | |||
| @echo Cleaning done | |||
| # instead of defining every module one by one, we can define a pattern | |||
| # this pattern below will automatically compile every module defined on $(OBJS) | |||
| #%.exe : %.c | |||
| # $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) | |||
| @ -0,0 +1,254 @@ | |||
| #************************************************************************************************** | |||
| # | |||
| # raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) | |||
| # | |||
| # Copyright (c) 2015 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. | |||
| # | |||
| #************************************************************************************************** | |||
| # define raylib platform to compile for | |||
| # possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB | |||
| # WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() | |||
| PLATFORM ?= PLATFORM_DESKTOP | |||
| # 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 | |||
| LIBPATH=win32 | |||
| else | |||
| UNAMEOS:=$(shell uname) | |||
| ifeq ($(UNAMEOS),Linux) | |||
| PLATFORM_OS=LINUX | |||
| LIBPATH=linux | |||
| else | |||
| ifeq ($(UNAMEOS),Darwin) | |||
| PLATFORM_OS=OSX | |||
| LIBPATH=osx | |||
| endif | |||
| endif | |||
| endif | |||
| endif | |||
| # define compiler: gcc for C program, define as g++ for C++ | |||
| ifeq ($(PLATFORM),PLATFORM_WEB) | |||
| # define emscripten compiler | |||
| CC = emcc | |||
| else | |||
| ifeq ($(PLATFORM_OS),OSX) | |||
| # define llvm compiler for mac | |||
| CC = clang | |||
| else | |||
| # define default gcc compiler | |||
| CC = gcc | |||
| endif | |||
| endif | |||
| # define compiler flags: | |||
| # -O2 defines optimization level | |||
| # -Wall turns on most, but not all, compiler warnings | |||
| # -std=c99 use standard C from 1999 revision | |||
| ifeq ($(PLATFORM),PLATFORM_RPI) | |||
| CFLAGS = -O2 -Wall -std=gnu99 -fgnu89-inline | |||
| else | |||
| CFLAGS = -O2 -Wall -std=c99 | |||
| endif | |||
| ifeq ($(PLATFORM),PLATFORM_WEB) | |||
| CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 --shell-file ../../templates/web_shell/shell.html | |||
| #-s ASSERTIONS=1 # to check for memory allocation errors (-O1 disables it) | |||
| #-s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing | |||
| #-s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) | |||
| endif | |||
| #CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes | |||
| # define any directories containing required header files | |||
| ifeq ($(PLATFORM),PLATFORM_RPI) | |||
| INCLUDES = -I. -I../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads | |||
| else | |||
| INCLUDES = -I. -I../src | |||
| # external libraries headers | |||
| # GLFW3 | |||
| INCLUDES += -I../external/glfw3/include | |||
| # GLEW - Not required any more, replaced by GLAD | |||
| #INCLUDES += -I../external/glew/include | |||
| # OpenAL Soft | |||
| INCLUDES += -I../external/openal_soft/include | |||
| endif | |||
| # define library paths containing required libs | |||
| ifeq ($(PLATFORM),PLATFORM_RPI) | |||
| LFLAGS = -L. -L../src -L/opt/vc/lib | |||
| else | |||
| LFLAGS = -L. -L../src | |||
| # external libraries to link with | |||
| # GLFW3 | |||
| LFLAGS += -L../external/glfw3/lib/$(LIBPATH) | |||
| ifneq ($(PLATFORM_OS),OSX) | |||
| # OpenAL Soft | |||
| LFLAGS += -L../external/openal_soft/lib/$(LIBPATH) | |||
| # GLEW: Not used, replaced by GLAD | |||
| #LFLAGS += -L../../external/glew/lib/$(LIBPATH) | |||
| endif | |||
| endif | |||
| # define any libraries to link into executable | |||
| # if you want to link libraries (libname.so or libname.a), use the -lname | |||
| ifeq ($(PLATFORM),PLATFORM_DESKTOP) | |||
| ifeq ($(PLATFORM_OS),LINUX) | |||
| # libraries for Debian GNU/Linux desktop compiling | |||
| # requires the following packages: | |||
| # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev | |||
| LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -pthread | |||
| # on XWindow could require also below libraries, just uncomment | |||
| #LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor | |||
| else | |||
| ifeq ($(PLATFORM_OS),OSX) | |||
| # libraries for OS X 10.9 desktop compiling | |||
| # requires the following packages: | |||
| # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev | |||
| LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa | |||
| else | |||
| # libraries for Windows desktop compiling | |||
| # NOTE: GLFW3 and OpenAL Soft libraries should be installed | |||
| LIBS = -lraylib -lglfw3 -lopengl32 -lopenal32 -lgdi32 | |||
| endif | |||
| endif | |||
| endif | |||
| ifeq ($(PLATFORM),PLATFORM_RPI) | |||
| # libraries for Raspberry Pi compiling | |||
| # NOTE: OpenAL Soft library should be installed (libopenal1 package) | |||
| LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal | |||
| endif | |||
| ifeq ($(PLATFORM),PLATFORM_WEB) | |||
| # NOTE: Set the correct path to libraylib.bc | |||
| LIBS = ../src/libraylib.bc | |||
| endif | |||
| # define additional parameters and flags for windows | |||
| ifeq ($(PLATFORM_OS),WINDOWS) | |||
| # resources file contains windows exe icon | |||
| # -Wl,--subsystem,windows hides the console window | |||
| WINFLAGS = ../src/resources -Wl,--subsystem,windows | |||
| endif | |||
| ifeq ($(PLATFORM),PLATFORM_WEB) | |||
| EXT = .html | |||
| endif | |||
| # define all object files required | |||
| SAMPLES = \ | |||
| arkanoid \ | |||
| asteroids \ | |||
| asteroids_survival \ | |||
| floppy \ | |||
| gold_fever \ | |||
| gorilas \ | |||
| missile_commander \ | |||
| pang \ | |||
| snake \ | |||
| space_invaders \ | |||
| tetris \ | |||
| fix_dylib \ | |||
| # typing 'make' will invoke the first target entry in the file, | |||
| # in this case, the 'default' target entry is raylib | |||
| default: samples | |||
| # compile all game samples | |||
| samples: $(SAMPLES) | |||
| # compile game sample - arkanoid | |||
| arkanoid: arkanoid.c | |||
| $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) | |||
| # compile game sample - steroids | |||
| asteroids: asteroids.c | |||
| $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) | |||
| # compile game sample - asteroids_survival | |||
| asteroids_survival: asteroids_survival.c | |||
| $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) | |||
| # compile game sample - floppy | |||
| floppy: floppy.c | |||
| $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) | |||
| # compile game sample - gold_fever | |||
| gold_fever: gold_fever.c | |||
| $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) | |||
| # compile game sample - gorilas | |||
| gorilas: gorilas.c | |||
| $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) | |||
| # compile game sample - missile_commander | |||
| missile_commander: missile_commander.c | |||
| $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) | |||
| # compile game sample - pang | |||
| pang: pang.c | |||
| $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) | |||
| # compile game sample - snake | |||
| snake: snake.c | |||
| $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) | |||
| # compile game sample - space_invaders | |||
| space_invaders: space_invaders.c | |||
| $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) | |||
| # compile game sample - tetris | |||
| tetris: tetris.c | |||
| $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) | |||
| # fix dylib install path name for each executable (MAC) | |||
| fix_dylib: | |||
| ifeq ($(PLATFORM_OS),OSX) | |||
| find . -type f -perm +ugo+x -print0 | xargs -t -0 -R 1 -I file install_name_tool -change libglfw.3.0.dylib ../external/glfw3/lib/osx/libglfw.3.0.dylib file | |||
| endif | |||
| # clean everything | |||
| clean: | |||
| ifeq ($(PLATFORM),PLATFORM_DESKTOP) | |||
| ifeq ($(PLATFORM_OS),OSX) | |||
| find . -type f -perm +ugo+x -delete | |||
| rm -f *.o | |||
| else | |||
| ifeq ($(PLATFORM_OS),LINUX) | |||
| find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f | |||
| else | |||
| del *.o *.exe | |||
| endif | |||
| endif | |||
| endif | |||
| ifeq ($(PLATFORM),PLATFORM_RPI) | |||
| find . -type f -executable -delete | |||
| rm -f *.o | |||
| endif | |||
| ifeq ($(PLATFORM),PLATFORM_WEB) | |||
| del *.o *.html *.js | |||
| endif | |||
| @echo Cleaning done | |||
| # instead of defining every module one by one, we can define a pattern | |||
| # this pattern below will automatically compile every module defined on $(OBJS) | |||
| #%.exe : %.c | |||
| # $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) | |||