mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-05 05:39:18 -05:00
Updated games to latest raylib version
Updated to new audio system
This commit is contained in:
@ -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
|
||||
|
||||
@ -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?
|
||||
|
||||
@ -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?
|
||||
|
||||
Reference in New Issue
Block a user