diff options
| author | Ray <[email protected]> | 2016-10-16 18:24:13 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-10-16 18:24:13 +0200 |
| commit | a9315fc422a3a036891f50f0c2be5059c3db8b31 (patch) | |
| tree | 9f5213dac656079e2163bc5d091200dc837672b8 /games | |
| parent | 53056f3e7e84e18b8ebfc4a2ab2f7f1fbe7ae36c (diff) | |
| parent | 1c05017548ea21dd1a44c31e9fc80b8700891f11 (diff) | |
| download | raylib-a9315fc422a3a036891f50f0c2be5059c3db8b31.tar.gz raylib-a9315fc422a3a036891f50f0c2be5059c3db8b31.zip | |
Merge pull request #189 from raysan5/develop
Develop branch integration
Diffstat (limited to 'games')
| -rw-r--r-- | games/arkanoid.lua | 297 | ||||
| -rw-r--r-- | games/drturtle/05_drturtle_audio.c | 15 | ||||
| -rw-r--r-- | games/drturtle/06_drturtle_final.c | 17 | ||||
| -rw-r--r-- | games/drturtle/drturtle_final_web.c | 19 | ||||
| -rw-r--r-- | games/just_do/just_do.c | 17 | ||||
| -rw-r--r-- | games/light_my_ritual/light_my_ritual.c | 20 | ||||
| -rw-r--r-- | games/light_my_ritual/screens/screen_gameplay.c | 21 | ||||
| -rw-r--r-- | games/light_my_ritual/screens/screen_logo_raylib.c | 5 | ||||
| -rw-r--r-- | games/makefile | 10 | ||||
| -rw-r--r-- | games/raylib_demo/raylib_demo.c | 20 | ||||
| -rw-r--r-- | games/skully_escape/skully_escape.c | 11 |
11 files changed, 393 insertions, 59 deletions
diff --git a/games/arkanoid.lua b/games/arkanoid.lua new file mode 100644 index 00000000..2dc59247 --- /dev/null +++ b/games/arkanoid.lua @@ -0,0 +1,297 @@ +--[[ + + raylib - sample game: arkanoid + + Sample game Marc Palau and Ramon Santamaria + + This game has been created using raylib v1.3 (www.raylib.com) + raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) + + Copyright (c) 2015 Ramon Santamaria (@raysan5) + + Translated to Lua by Ghassan Al-Mashareqa ([email protected]) + +--]] + +------------------------------------------------------------------------------------ +-- Some Defines +------------------------------------------------------------------------------------ +PLAYER_MAX_LIFE = 5 +LINES_OF_BRICKS = 5 +BRICKS_PER_LINE = 20 + +------------------------------------------------------------------------------------ +-- Types and Structures Definition +------------------------------------------------------------------------------------ + +GameScreen = { LOGO = 0, TITLE = 1, GAMEPLAY = 2, ENDING = 3 } + +function Player() + return { position = Vector2(0,0), size = Vector2(0,0), life = 0 } +end + +function Ball() + return { position = Vector2(0,0), speed = Vector2(0,0), radius = 0, active = false } +end + +function Brick() + return { position = Vector2(0,0), active = false } +end + +-------------------------------------------------------------------------------------- +-- Global Variables Declaration +-------------------------------------------------------------------------------------- +screenWidth = 800; +screenHeight = 450; + +framesCounter = 0; +gameOver = false; +pause = false; + +player = Player() +ball = Ball() +brick = {}--[LINES_OF_BRICKS][BRICKS_PER_LINE]; +for i = 0, LINES_OF_BRICKS-1 do + brick[i] = {} + for j = 0, BRICKS_PER_LINE-1 do + brick[i][j] = Brick() + end +end +brickSize = Vector2(0,0) + + +-------------------------------------------------------------------------------------- +-- Module Functions Definitions (local) +-------------------------------------------------------------------------------------- + +-- Initialize game variables +function InitGame() + + brickSize = Vector2(GetScreenWidth()/BRICKS_PER_LINE, 40) + + -- Initialize player + player.position = Vector2(screenWidth/2, screenHeight*7/8) + player.size = Vector2(screenWidth/10, 20) + player.life = PLAYER_MAX_LIFE; + + -- Initialize ball + ball.position = Vector2(screenWidth/2, screenHeight*7/8 - 30) + ball.speed = Vector2(0, 0) + ball.radius = 7; + ball.active = false; + + -- Initialize bricks + local initialDownPosition = 50; + + for i = 0, LINES_OF_BRICKS-1 do + for j = 0, BRICKS_PER_LINE-1 do + brick[i][j].position = Vector2(j*brickSize.x + brickSize.x/2, i*brickSize.y + initialDownPosition) + brick[i][j].active = true; + end + end +end + +-- Update game (one frame) +function UpdateGame() + + if (not gameOver) then + if (IsKeyPressed(KEY.P)) then pause = not pause; end + + if (not pause) then + -- Player movement + if (IsKeyDown(KEY.LEFT)) then player.position.x = player.position.x - 5; end + if ((player.position.x - player.size.x/2) <= 0) then player.position.x = player.size.x/2; end + if (IsKeyDown(KEY.RIGHT)) then player.position.x = player.position.x + 5; end + if ((player.position.x + player.size.x/2) >= screenWidth) then player.position.x = screenWidth - player.size.x/2; end + + -- Launch ball + if (not ball.active) then + if (IsKeyPressed(KEY.SPACE)) then + ball.active = true; + ball.speed = Vector2(0, -5) + end + end + + UpdateBall(); + + -- Game over logic + if (player.life <= 0) then + gameOver = true; + else + gameOver = true; + + for i = 0, LINES_OF_BRICKS-1 do + for j = 0, BRICKS_PER_LINE-1 do + if (brick[i][j].active) then gameOver = false; end + end + end + end + end + else + if (IsKeyPressed(KEY.ENTER)) then + InitGame(); + gameOver = false; + end + end + +end + +-- Draw game (one frame) +function DrawGame() + + BeginDrawing(); + + ClearBackground(RAYWHITE); + + if (not gameOver) then + -- Draw player bar + DrawRectangle(player.position.x - player.size.x/2, player.position.y - player.size.y/2, player.size.x, player.size.y, BLACK); + + -- Draw player lives + for i = 0, player.life-1 do + DrawRectangle(20 + 40*i, screenHeight - 30, 35, 10, LIGHTGRAY); + end + + -- Draw ball + DrawCircleV(ball.position, ball.radius, MAROON); + + -- Draw bricks + for i = 0, LINES_OF_BRICKS-1 do + for j = 0, BRICKS_PER_LINE-1 do + if (brick[i][j].active) then + if ((i + j) % 2 == 0) then + DrawRectangle(brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, GRAY); + else + DrawRectangle(brick[i][j].position.x - brickSize.x/2, brick[i][j].position.y - brickSize.y/2, brickSize.x, brickSize.y, DARKGRAY); + end + end + end + end + + if (pause) then + DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); + end + else + DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY); + end + + EndDrawing(); +end + +-- Unload game variables +function UnloadGame() + -- TODO: Unload all dynamic loaded data (textures, sounds, models...) +end + +-- Update and Draw (one frame) +function UpdateDrawFrame() + UpdateGame(); + DrawGame(); +end + +---------------------------------------------------------------------------------------- +-- Additional module functions +---------------------------------------------------------------------------------------- +function UpdateBall() + -- Update position + if (ball.active) then + ball.position.x = ball.position.x + ball.speed.x; + ball.position.y = ball.position.y + ball.speed.y; + else + ball.position = Vector2(player.position.x, screenHeight*7/8 - 30); + end + + -- Bounce in x + if (((ball.position.x + ball.radius) >= screenWidth) or ((ball.position.x - ball.radius) <= 0)) + then + ball.speed.x = ball.speed.x * -1; + end + + -- Bounce in y + if ((ball.position.y - ball.radius) <= 0) then + ball.speed.y = ball.speed.y * -1; + end + + -- Ball reaches bottom of the screen + if ((ball.position.y + ball.radius) >= screenHeight) then + ball.speed = Vector2(0, 0); + ball.active = false; + + player.life = player.life - 1; + end + + -- Collision logic: ball vs player + if CheckCollisionCircleRec(ball.position, ball.radius, + Rectangle( + player.position.x - player.size.x/2, + player.position.y - player.size.y/2, + player.size.x, + player.size.y)) then + if (ball.speed.y > 0) then + ball.speed.y = ball.speed.y * -1; + ball.speed.x = (ball.position.x - player.position.x)/(player.size.x/2)*5; + end + end + + -- Collision logic: ball vs bricks + for i = 0,LINES_OF_BRICKS-1 do + for j = 0,BRICKS_PER_LINE-1 do + if (brick[i][j].active) then + -- Hit below + if (((ball.position.y - ball.radius) <= (brick[i][j].position.y + brickSize.y/2)) and + ((ball.position.y - ball.radius) > (brick[i][j].position.y + brickSize.y/2 + ball.speed.y)) and + ((math.abs(ball.position.x - brick[i][j].position.x)) < (brickSize.x/2 + ball.radius*2/3)) and (ball.speed.y < 0)) + then + brick[i][j].active = false; + ball.speed.y = ball.speed.y * -1; + -- Hit above + elseif (((ball.position.y + ball.radius) >= (brick[i][j].position.y - brickSize.y/2)) and + ((ball.position.y + ball.radius) < (brick[i][j].position.y - brickSize.y/2 + ball.speed.y)) and + ((math.abs(ball.position.x - brick[i][j].position.x)) < (brickSize.x/2 + ball.radius*2/3)) and (ball.speed.y > 0)) + then + brick[i][j].active = false; + ball.speed.y = ball.speed.y * -1; + -- Hit left + elseif (((ball.position.x + ball.radius) >= (brick[i][j].position.x - brickSize.x/2)) and + ((ball.position.x + ball.radius) < (brick[i][j].position.x - brickSize.x/2 + ball.speed.x)) and + ((math.abs(ball.position.y - brick[i][j].position.y)) < (brickSize.y/2 + ball.radius*2/3)) and (ball.speed.x > 0)) + then + brick[i][j].active = false; + ball.speed.x = ball.speed.x * -1; + -- Hit right + elseif (((ball.position.x - ball.radius) <= (brick[i][j].position.x + brickSize.x/2)) and + ((ball.position.x - ball.radius) > (brick[i][j].position.x + brickSize.x/2 + ball.speed.x)) and + ((math.abs(ball.position.y - brick[i][j].position.y)) < (brickSize.y/2 + ball.radius*2/3)) and (ball.speed.x < 0)) + then + brick[i][j].active = false; + ball.speed.x = ball.speed.x * -1; + end + end + end + end +end + +InitWindow(screenWidth, screenHeight, "sample game: arkanoid"); + +InitGame(); + +SetTargetFPS(60); +---------------------------------------------------------------------------------------- + +-- Main game loop +while (not WindowShouldClose()) -- Detect window close button or ESC key +do + -- Update + ------------------------------------------------------------------------------------ + UpdateGame(); + ------------------------------------------------------------------------------------ + + -- Draw + ------------------------------------------------------------------------------------ + DrawGame(); + ------------------------------------------------------------------------------------ +end + +UnloadGame(); -- Unload loaded data (textures, sounds, models...) + +CloseWindow(); -- Close window and OpenGL context diff --git a/games/drturtle/05_drturtle_audio.c b/games/drturtle/05_drturtle_audio.c index 4a36d015..b94de106 100644 --- a/games/drturtle/05_drturtle_audio.c +++ b/games/drturtle/05_drturtle_audio.c @@ -12,7 +12,7 @@ * * Enjoy using raylib. :) * -* This game has been created using raylib 1.1 (www.raylib.com) +* 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 (Ray San - [email protected]) @@ -59,8 +59,9 @@ int main() Sound die = LoadSound("resources/die.wav"); Sound growl = LoadSound("resources/gamera.wav"); - // Start playing streaming music - PlayMusicStream("resources/speeding.ogg"); + // Load music stream and start playing music + Music music = LoadMusicStream("resources/speeding.ogg"); + PlayMusicStream(music); // Define scrolling variables int backScrolling = 0; @@ -118,6 +119,8 @@ int main() { // Update //---------------------------------------------------------------------------------- + UpdateMusicStream(music); // Refill music stream buffers (if required) + framesCounter++; // Game screens management @@ -458,10 +461,10 @@ int main() UnloadSound(die); UnloadSound(growl); - StopMusicStream(); // Stop music - CloseAudioDevice(); // Close audio device + UnloadMusicStream(music); // Unload music + CloseAudioDevice(); // Close audio device - CloseWindow(); // Close window and OpenGL context + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; diff --git a/games/drturtle/06_drturtle_final.c b/games/drturtle/06_drturtle_final.c index 128b23a5..48708094 100644 --- a/games/drturtle/06_drturtle_final.c +++ b/games/drturtle/06_drturtle_final.c @@ -12,7 +12,7 @@ * * Enjoy using raylib. :) * -* This game has been created using raylib 1.1 (www.raylib.com) +* 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 (Ray San - [email protected]) @@ -39,7 +39,7 @@ int main() InitWindow(screenWidth, screenHeight, "Dr. Turtle & Mr. GAMERA"); // Initialize audio device - InitAudioDevice(); + InitAudioDevice(); // Load game resources: textures Texture2D sky = LoadTexture("resources/sky.png"); @@ -62,8 +62,9 @@ int main() Sound die = LoadSound("resources/die.wav"); Sound growl = LoadSound("resources/gamera.wav"); - // Start playing streaming music - PlayMusicStream("resources/speeding.ogg"); + // Load music stream and start playing music + Music music = LoadMusicStream("resources/speeding.ogg"); + PlayMusicStream(music); // Define scrolling variables int backScrolling = 0; @@ -127,6 +128,8 @@ int main() { // Update //---------------------------------------------------------------------------------- + UpdateMusicStream(music); // Refill music stream buffers (if required) + framesCounter++; // Sea color tint effect @@ -483,10 +486,10 @@ int main() UnloadSound(die); UnloadSound(growl); - StopMusicStream(); // Stop music - CloseAudioDevice(); // Close audio device + UnloadMusicStream(music); // Unload music + CloseAudioDevice(); // Close audio device - CloseWindow(); // Close window and OpenGL context + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; diff --git a/games/drturtle/drturtle_final_web.c b/games/drturtle/drturtle_final_web.c index 25f4074b..bec7ebd0 100644 --- a/games/drturtle/drturtle_final_web.c +++ b/games/drturtle/drturtle_final_web.c @@ -12,7 +12,7 @@ * * Enjoy using raylib. :) * -* This game has been created using raylib 1.1 (www.raylib.com) +* 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 (Ray San - [email protected]) @@ -54,6 +54,8 @@ Sound eat; Sound die; Sound growl; +Music music; + // Define scrolling variables int backScrolling = 0; int seaScrolling = 0; @@ -124,8 +126,9 @@ int main() die = LoadSound("resources/die.wav"); growl = LoadSound("resources/gamera.wav"); - // Start playing streaming music - PlayMusicStream("resources/speeding.ogg"); + // Load music stream and start playing music + music = LoadMusicStream("resources/speeding.ogg"); + PlayMusicStream(music); playerBounds = (Rectangle){ 30 + 14, playerRail*120 + 90 + 14, 100, 100 }; @@ -190,10 +193,10 @@ int main() UnloadSound(die); UnloadSound(growl); - StopMusicStream(); // Stop music - CloseAudioDevice(); // Close audio device + UnloadMusicStream(music); // Unload music + CloseAudioDevice(); // Close audio device - CloseWindow(); // Close window and OpenGL context + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; @@ -206,8 +209,8 @@ void UpdateDrawFrame(void) { // Update //---------------------------------------------------------------------------------- - UpdateMusicStream(); - + UpdateMusicStream(music); // Refill music stream buffers (if required) + framesCounter++; // Sea color tint effect diff --git a/games/just_do/just_do.c b/games/just_do/just_do.c index beac9e14..811150d3 100644 --- a/games/just_do/just_do.c +++ b/games/just_do/just_do.c @@ -6,7 +6,7 @@ * * Developed by: Ramon Santamaria (Ray San) * -* This game has been created using raylib (www.raylib.com) +* 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) * * raylib - Copyright (c) 2015 Ramon Santamaria (Ray San - [email protected]) @@ -23,7 +23,7 @@ //---------------------------------------------------------------------------------- // Global Variables Definition (local to this module) //---------------------------------------------------------------------------------- -const int screenWidth = 1280; // Moved to screens.h +const int screenWidth = 1280; // Moved to screens.h const int screenHeight = 720; // Moved to screens.h // Required variables to manage screen transitions (fade-in, fade-out) @@ -35,6 +35,7 @@ int transToScreen = -1; int framesCounter = 0; //static Sound levelWin; +Music music; //---------------------------------------------------------------------------------- // Local Functions Declaration @@ -57,10 +58,11 @@ int main(void) //SetupFlags(FLAG_FULLSCREEN_MODE); InitWindow(screenWidth, screenHeight, windowTitle); - // TODO: Load global data here (assets that must be available in all screens, i.e. fonts) + // Load global data here (assets that must be available in all screens, i.e. fonts) InitAudioDevice(); levelWin = LoadSound("resources/win.wav"); + music = LoadMusicStream("resources/ambient.ogg"); // Setup and Init first screen currentScreen = LOGO; @@ -85,8 +87,9 @@ int main(void) // De-Initialization //-------------------------------------------------------------------------------------- - // TODO: Unload all global loaded data (i.e. fonts) here! + // Unload all global loaded data (i.e. fonts) here! UnloadSound(levelWin); + UnloadMusicStream(music); CloseAudioDevice(); @@ -197,6 +200,8 @@ void UpdateDrawFrame(void) InitLevel08Screen(); } + UpdateMusicStream(music); + switch(currentScreen) { case LOGO: @@ -209,8 +214,8 @@ void UpdateDrawFrame(void) TransitionToScreen(LEVEL00); InitLevel00Screen(); - PlayMusicStream("resources/ambient.ogg"); - SetMusicVolume(0.6f); + PlayMusicStream(music); + SetMusicVolume(music, 0.6f); } } break; case LEVEL00: diff --git a/games/light_my_ritual/light_my_ritual.c b/games/light_my_ritual/light_my_ritual.c index 0f1dc47e..000eca36 100644 --- a/games/light_my_ritual/light_my_ritual.c +++ b/games/light_my_ritual/light_my_ritual.c @@ -35,6 +35,8 @@ bool onTransition = false; bool transFadeOut = false; int transFromScreen = -1; int transToScreen = -1; + +static Music music; //---------------------------------------------------------------------------------- // Local Functions Declaration @@ -66,11 +68,13 @@ int main(void) UnloadImage(image); // Unload image from CPU memory (RAM) - //PlayMusicStream("resources/audio/come_play_with_me.ogg"); - font = LoadSpriteFont("resources/font_arcadian.png"); //doors = LoadTexture("resources/textures/doors.png"); //sndDoor = LoadSound("resources/audio/door.ogg"); + + music = LoadMusicStream("resources/audio/ambient.ogg"); + PlayMusicStream(music); + SetMusicVolume(music, 1.0f); // Setup and Init first screen currentScreen = LOGO_RL; @@ -105,6 +109,8 @@ int main(void) UnloadSpriteFont(font); //UnloadSound(sndDoor); + UnloadMusicStream(music); + free(lightsMap); CloseAudioDevice(); @@ -218,13 +224,17 @@ void UpdateDrawFrame(void) rlUpdateLogoScreen(); if (rlFinishLogoScreen()) TransitionToScreen(TITLE); - + } break; case TITLE: { UpdateTitleScreen(); - if (FinishTitleScreen() == 1) TransitionToScreen(GAMEPLAY); + if (FinishTitleScreen() == 1) + { + StopMusicStream(music); + TransitionToScreen(GAMEPLAY); + } } break; case GAMEPLAY: @@ -244,7 +254,7 @@ void UpdateDrawFrame(void) UpdateTransition(); } - UpdateMusicStream(); + if (currentScreen != GAMEPLAY) UpdateMusicStream(music); //---------------------------------------------------------------------------------- // Draw diff --git a/games/light_my_ritual/screens/screen_gameplay.c b/games/light_my_ritual/screens/screen_gameplay.c index b91d2545..c1779f73 100644 --- a/games/light_my_ritual/screens/screen_gameplay.c +++ b/games/light_my_ritual/screens/screen_gameplay.c @@ -64,7 +64,7 @@ typedef struct Enemy { Color color; } Enemy; -typedef struct Light { +typedef struct LightSpot { Vector2 position; int radius; int requiredEnergy; @@ -74,7 +74,7 @@ typedef struct Light { int framesCounter; int currentFrame; Rectangle frameRec; -} Light; +} LightSpot; typedef enum { LEVEL_I, LEVEL_II, LEVEL_III, LEVEL_FINISHED } LightedLevel; @@ -92,9 +92,9 @@ static bool pause; static Player player; -static Light lightsI[MAX_LIGHTS_I]; -static Light lightsII[MAX_LIGHTS_II]; -static Light lightsIII[MAX_LIGHTS_III]; +static LightSpot lightsI[MAX_LIGHTS_I]; +static LightSpot lightsII[MAX_LIGHTS_II]; +static LightSpot lightsIII[MAX_LIGHTS_III]; static Enemy enemies[MAX_ENEMIES]; @@ -133,6 +133,8 @@ static Rectangle lightOff, lightOn; static Sound fxLightOn, fxLightOff; +static Music music; + // Debug variables static bool enemiesStopped; @@ -286,7 +288,8 @@ void InitGameplayScreen(void) enemiesStopped = false; - PlayMusicStream("resources/audio/ritual.ogg"); + music = LoadMusicStream("resources/audio/ritual.ogg"); + PlayMusicStream(music); } // Gameplay Screen Update logic @@ -549,10 +552,12 @@ void UpdateGameplayScreen(void) { alphaRitual += 0.02f; - SetMusicVolume(1.0f - alphaRitual); + SetMusicVolume(music, 1.0f - alphaRitual); if (alphaRitual > 1.0f) finishScreen = 1; } + + UpdateMusicStream(music); } // Gameplay Screen Draw logic @@ -757,6 +762,8 @@ void UnloadGameplayScreen(void) // Unload sounds UnloadSound(fxLightOn); UnloadSound(fxLightOff); + + UnloadMusicStream(music); } // Gameplay Screen should finish? diff --git a/games/light_my_ritual/screens/screen_logo_raylib.c b/games/light_my_ritual/screens/screen_logo_raylib.c index 40157b10..f21055d7 100644 --- a/games/light_my_ritual/screens/screen_logo_raylib.c +++ b/games/light_my_ritual/screens/screen_logo_raylib.c @@ -75,9 +75,6 @@ void rlInitLogoScreen(void) state = 0; alpha = 1.0f; - - PlayMusicStream("resources/audio/ambient.ogg"); - SetMusicVolume(1.0f); } // Logo Screen Update logic @@ -204,7 +201,7 @@ void rlDrawLogoScreen(void) // Logo Screen Unload logic void rlUnloadLogoScreen(void) { - // TODO: Unload LOGO screen variables here! + // Unload LOGO screen variables here! } // Logo Screen should finish? diff --git a/games/makefile b/games/makefile index 2d992896..c48e4d68 100644 --- a/games/makefile +++ b/games/makefile @@ -86,8 +86,6 @@ else # 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 @@ -103,8 +101,6 @@ else 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 @@ -115,9 +111,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # 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 + LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -lpthread -ldl + # on XWindow could require also below libraries: + LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor else ifeq ($(PLATFORM_OS),OSX) # libraries for OS X 10.9 desktop compiling diff --git a/games/raylib_demo/raylib_demo.c b/games/raylib_demo/raylib_demo.c index 22213b46..722d8ce6 100644 --- a/games/raylib_demo/raylib_demo.c +++ b/games/raylib_demo/raylib_demo.c @@ -123,6 +123,8 @@ Model cat; Sound fxWav; Sound fxOgg; +Music music; + Vector2 soundBallsPosition[MAX_BALLS]; Color soundBallsColor[MAX_BALLS]; bool soundBallsActive[MAX_BALLS]; @@ -203,11 +205,13 @@ int main() catTexture = LoadTexture("resources/catsham.png"); // Load model texture cat = LoadModel("resources/cat.obj"); // Load OBJ model - cat.material.texDiffuse = texture; // Set cat model diffuse texture + cat.material.texDiffuse = catTexture; // Set cat model diffuse texture fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file + music = LoadMusicStream("resources/audio/guitar_noodling.ogg"); // Load music + for (int i = 0; i < MAX_BALLS; i++) { soundBallsPosition[i] = (Vector2){ 650 + 560/2 + GetRandomValue(-280, 280), 220 + 200 + GetRandomValue(-200, 200) }; @@ -267,6 +271,8 @@ int main() UnloadSound(fxWav); UnloadSound(fxOgg); + + UnloadMusicStream(music); CloseAudioDevice(); @@ -464,11 +470,11 @@ void UpdateDrawOneFrame(void) if (selectedModule == AUDIO) { - if (IsKeyPressed(KEY_SPACE) && !MusicIsPlaying()) PlayMusicStream("resources/audio/guitar_noodling.ogg"); // Play music stream + if (IsKeyPressed(KEY_SPACE) && !IsMusicPlaying(music)) PlayMusicStream(music); // Play music stream if (IsKeyPressed('S')) { - StopMusicStream(); + StopMusicStream(music); timePlayed = 0.0f; for (int i = 0; i < MAX_BALLS; i++) @@ -482,9 +488,11 @@ void UpdateDrawOneFrame(void) } } - if (MusicIsPlaying()) + if (IsMusicPlaying(music)) { - timePlayed = GetMusicTimePlayed() / GetMusicTimeLength() * 100 * 4; + UpdateMusicStream(music); + + timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*100*4; if ((framesCounter%10) == 0) { @@ -842,7 +850,7 @@ void UpdateDrawOneFrame(void) DrawRectangle(150, 390, 400, 12, LIGHTGRAY); DrawRectangle(150, 390, (int)timePlayed, 12, MAROON); - if (MusicIsPlaying()) + if (IsMusicPlaying(music)) { DrawText("PRESS 'S' to STOP PLAYING MUSIC", 165, 425, 20, GRAY); diff --git a/games/skully_escape/skully_escape.c b/games/skully_escape/skully_escape.c index 22cc04e4..83f9732b 100644 --- a/games/skully_escape/skully_escape.c +++ b/games/skully_escape/skully_escape.c @@ -2,7 +2,7 @@ * * SKULLY ESCAPE [KING GAME JAM 2015] * -* This game has been created using raylib (www.raylib.com) +* 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 (Ray San - [email protected]) @@ -32,6 +32,8 @@ int transFromScreen = -1; int transToScreen = -1; static int framesCounter = 0; + +Music music; //---------------------------------------------------------------------------------- // Local Functions Declaration @@ -57,7 +59,8 @@ int main(void) // Global data loading (assets that must be available in all screens, i.e. fonts) InitAudioDevice(); - PlayMusicStream("resources/audio/come_play_with_me.ogg"); + music = LoadMusicStream("resources/audio/come_play_with_me.ogg"); + PlayMusicStream(music); font = LoadSpriteFont("resources/textures/alagard.png"); doors = LoadTexture("resources/textures/doors.png"); @@ -93,6 +96,8 @@ int main(void) UnloadSound(sndDoor); UnloadSound(sndScream); + UnloadMusicStream(music); + CloseAudioDevice(); CloseWindow(); // Close window and OpenGL context @@ -368,7 +373,7 @@ void UpdateDrawFrame(void) UpdateTransition(); } - UpdateMusicStream(); + UpdateMusicStream(music); //---------------------------------------------------------------------------------- // Draw |
