diff options
| author | raysan5 <raysan5@gmail.com> | 2016-02-07 11:08:31 +0100 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2016-02-07 11:08:31 +0100 |
| commit | 4fae37bb88962816328a6b4e0f23bedb084b0604 (patch) | |
| tree | 1a04c6d4ff1f1141083ca7492752cf5307e164f1 | |
| parent | 646f1c3f716dd817ff717d35480a744a8be46ead (diff) | |
| download | raylib-4fae37bb88962816328a6b4e0f23bedb084b0604.tar.gz raylib-4fae37bb88962816328a6b4e0f23bedb084b0604.zip | |
Removed floppy game, available as sample
| -rw-r--r-- | games/floppy/floppy.c | 213 | ||||
| -rw-r--r-- | games/floppy/resources/background.png | bin | 228930 -> 0 bytes | |||
| -rw-r--r-- | games/floppy/resources/coin.wav | bin | 37396 -> 0 bytes | |||
| -rw-r--r-- | games/floppy/resources/floppy.png | bin | 2030 -> 0 bytes | |||
| -rw-r--r-- | games/floppy/resources/jump.wav | bin | 14540 -> 0 bytes | |||
| -rw-r--r-- | games/floppy/resources/tubes.png | bin | 19623 -> 0 bytes |
6 files changed, 0 insertions, 213 deletions
diff --git a/games/floppy/floppy.c b/games/floppy/floppy.c deleted file mode 100644 index 0c0cb5f2..00000000 --- a/games/floppy/floppy.c +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************************* -* -* raylib game - Floppy Bird -* -* 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" - -#define MAX_TUBES 100 - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "Floppy Bird"); - - InitAudioDevice(); // Initialize audio device - - Sound coin = LoadSound("resources/coin.wav"); - Sound jump = LoadSound("resources/jump.wav"); - - Texture2D background = LoadTexture("resources/background.png"); - Texture2D tubes = LoadTexture("resources/tubes.png"); - Texture2D floppy = LoadTexture("resources/floppy.png"); - - Vector2 floppyPos = { 80, screenHeight/2 - floppy.height/2 }; - - Vector2 tubesPos[MAX_TUBES]; - int tubesSpeedX = 2; - - for (int i = 0; i < MAX_TUBES; i++) - { - tubesPos[i].x = 400 + 280*i; - tubesPos[i].y = -GetRandomValue(0, 120); - } - - Rectangle tubesRecs[MAX_TUBES*2]; - bool tubesActive[MAX_TUBES]; - - for (int i = 0; i < MAX_TUBES*2; i += 2) - { - tubesRecs[i].x = tubesPos[i/2].x; - tubesRecs[i].y = tubesPos[i/2].y; - tubesRecs[i].width = tubes.width; - tubesRecs[i].height = 255; - - tubesRecs[i+1].x = tubesPos[i/2].x; - tubesRecs[i+1].y = 600 + tubesPos[i/2].y - 255; - tubesRecs[i+1].width = tubes.width; - tubesRecs[i+1].height = 255; - - tubesActive[i/2] = true; - } - - int backScroll = 0; - - int score = 0; - int hiscore = 0; - - bool gameover = false; - bool superfx = false; - - SetTargetFPS(60); - //--------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - - // Background scroll logic - backScroll--; - if (backScroll <= -800) backScroll = 0; - - // Player movement logic - if (!gameover) - { - if (IsKeyDown(KEY_SPACE)) floppyPos.y -= 3; - else floppyPos.y += 1; - - if (IsKeyPressed(KEY_SPACE)) PlaySound(jump); - } - - // Tubes moving logic - for (int i = 0; i < MAX_TUBES; i++) tubesPos[i].x -= tubesSpeedX; - - for (int i = 0; i < MAX_TUBES*2; i += 2) - { - tubesRecs[i].x = tubesPos[i/2].x; - tubesRecs[i+1].x = tubesPos[i/2].x; - } - - // Check collisions player-tubes - for (int i = 0; i < MAX_TUBES*2; i++) - { - if (CheckCollisionCircleRec((Vector2){ floppyPos.x + floppy.width/2, floppyPos.y + floppy.height/2 }, floppy.width/2, tubesRecs[i])) - { - gameover = true; - } - else if ((tubesPos[i/2].x < floppyPos.x) && tubesActive[i/2] && !gameover) - { - score += 100; - tubesActive[i/2] = false; - PlaySound(coin); - - superfx = true; - - if (score > hiscore) hiscore = score; - } - } - - // Gameover logic for reset - if (gameover && IsKeyPressed(KEY_ENTER)) - { - for (int i = 0; i < MAX_TUBES; i++) - { - tubesPos[i].x = 400 + 280*i; - tubesPos[i].y = -GetRandomValue(0, 120); - } - - for (int i = 0; i < MAX_TUBES*2; i += 2) - { - tubesRecs[i].x = tubesPos[i/2].x; - tubesRecs[i].y = tubesPos[i/2].y; - - tubesRecs[i+1].x = tubesPos[i/2].x; - tubesRecs[i+1].y = 600 + tubesPos[i/2].y - 255; - - tubesActive[i/2] = true; - } - - floppyPos.x = 80; - floppyPos.y = screenHeight/2 - floppy.height/2; - - gameover = false; - score = 0; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw scrolling background - DrawTexture(background, backScroll, 0, WHITE); - DrawTexture(background, screenWidth + backScroll, 0, WHITE); - - // Draw moving tubes - for (int i = 0; i < MAX_TUBES; i++) - { - if (tubesPos[i].x <= 800) DrawTextureEx(tubes, tubesPos[i], 0, 1.0, WHITE); - - // Draw collision recs - //DrawRectangleLines(tubesRecs[i*2].x, tubesRecs[i*2].y, tubesRecs[i*2].width, tubesRecs[i*2].height, RED); - //DrawRectangleLines(tubesRecs[i*2 + 1].x, tubesRecs[i*2 + 1].y, tubesRecs[i*2 + 1].width, tubesRecs[i*2 + 1].height, RED); - } - - // Draw scores - DrawText(FormatText("%04i", score), 20, 20, 40, PINK); - DrawText(FormatText("HI-SCORE: %04i", hiscore), 20, 70, 20, VIOLET); - - // Draw player or game over messages - if (!gameover) - { - DrawTextureEx(floppy, floppyPos, 0, 1.0, WHITE); - - // Draw collision circle - //DrawCircleLines(floppyPos.x + floppy.width/2, floppyPos.y + floppy.height/2, floppy.width/2, RED); - } - else - { - DrawText("GAME OVER", 100, 180, 100, MAROON); - DrawText("PRESS ENTER to RETRY!", 280, 280, 20, RED); - } - - // Draw screen light flash when passing through a tube - if (superfx) - { - DrawRectangle(0, 0, screenWidth, screenHeight, GOLD); - superfx = false; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(background); // Texture unloading - UnloadTexture(tubes); // Texture unloading - UnloadTexture(floppy); // Texture unloading - - UnloadSound(coin); // Unload sound data - UnloadSound(jump); // Unload sound data - - CloseAudioDevice(); // Close audio device - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/games/floppy/resources/background.png b/games/floppy/resources/background.png Binary files differdeleted file mode 100644 index eab9d865..00000000 --- a/games/floppy/resources/background.png +++ /dev/null diff --git a/games/floppy/resources/coin.wav b/games/floppy/resources/coin.wav Binary files differdeleted file mode 100644 index d3b6e93c..00000000 --- a/games/floppy/resources/coin.wav +++ /dev/null diff --git a/games/floppy/resources/floppy.png b/games/floppy/resources/floppy.png Binary files differdeleted file mode 100644 index 7c851086..00000000 --- a/games/floppy/resources/floppy.png +++ /dev/null diff --git a/games/floppy/resources/jump.wav b/games/floppy/resources/jump.wav Binary files differdeleted file mode 100644 index 1f68d336..00000000 --- a/games/floppy/resources/jump.wav +++ /dev/null diff --git a/games/floppy/resources/tubes.png b/games/floppy/resources/tubes.png Binary files differdeleted file mode 100644 index a3ca8e7e..00000000 --- a/games/floppy/resources/tubes.png +++ /dev/null |
