Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Main game loop
while (!r.WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (r.IsKeyPressed(r.KEY_SPACE)) r.PlaySound(fxWav) // Play WAV sound
if (r.IsKeyPressed(r.KEY_ENTER)) r.PlaySound(fxOgg) // Play OGG sound
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
r.BeginDrawing()
r.ClearBackground(r.RAYWHITE)
r.DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, r.LIGHTGRAY)
r.DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, r.LIGHTGRAY)
r.EndDrawing()
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
r.UnloadSound(fxWav) // Unload sound data
r.UnloadSound(fxOgg) // Unload sound data
r.CloseAudioDevice() // Close audio device
r.CloseWindow() // Close window and OpenGL context
//--------------------------------------------------------------------------------------
while (!r.WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (r.IsKeyPressed(r.KEY_SPACE)) r.PlaySound(fxWav) // Play WAV sound
if (r.IsKeyPressed(r.KEY_ENTER)) r.PlaySound(fxOgg) // Play OGG sound
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
r.BeginDrawing()
r.ClearBackground(r.RAYWHITE)
r.DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, r.LIGHTGRAY)
r.DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, r.LIGHTGRAY)
r.EndDrawing()
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
r.UnloadSound(fxWav) // Unload sound data
r.UnloadSound(fxOgg) // Unload sound data
r.CloseAudioDevice() // Close audio device
r.CloseWindow() // Close window and OpenGL context
//--------------------------------------------------------------------------------------
default: break;
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
r.BeginDrawing()
r.ClearBackground(r.RAYWHITE)
switch(currentScreen)
{
case 'LOGO':
{
// TODO: Draw LOGO screen here!
r.DrawText("LOGO SCREEN", 20, 20, 40, r.LIGHTGRAY)
r.DrawText("WAIT for 2 SECONDS...", 290, 220, 20, r.GRAY)
} break
case 'TITLE':
{
// TODO: Draw TITLE screen here!
r.DrawRectangle(0, 0, screenWidth, screenHeight, r.GREEN)
r.DrawText("TITLE SCREEN", 20, 20, 40, r.DARKGREEN)
r.DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, r.DARKGREEN)
} break
case 'GAMEPLAY':
{
// TODO: Draw GAMEPLAY screen here!
r.DrawRectangle(0, 0, screenWidth, screenHeight, r.PURPLE)
r.DrawText("GAMEPLAY SCREEN", 20, 20, 40, r.MAROON)
if (((framesCounter/120)%2) == 1)
{
randValue = r.GetRandomValue(-8, 5)
framesCounter = 0
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
r.BeginDrawing()
r.ClearBackground(r.RAYWHITE)
r.DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, r.MAROON)
r.DrawText(r.FormatText("%i", randValue), 360, 180, 80, r.LIGHTGRAY)
r.EndDrawing()
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
r.CloseWindow() // Close window and OpenGL context
//--------------------------------------------------------------------------------------
// Main game loop
while (!r.WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
r.BeginDrawing()
r.ClearBackground(r.RAYWHITE)
r.DrawText("Congrats! You created your first window!", 190, 200, 20, r.LIGHTGRAY)
r.EndDrawing()
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
r.CloseWindow() // Close window and OpenGL context
//--------------------------------------------------------------------------------------