How to use the raylib.ClearBackground function in raylib

To help you get started, we’ve selected a few raylib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RobLoach / node-raylib / examples / textures / textures_image_loading.js View on Github external
r.UnloadImage(image);   // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
//---------------------------------------------------------------------------------------

// Main game loop
while (!r.WindowShouldClose())    // Detect window close button or ESC key
{
    // Update
    //----------------------------------------------------------------------------------
    // TODO: Update your variables here
    //----------------------------------------------------------------------------------
console.log('5')
    // Draw
    //----------------------------------------------------------------------------------
    r.BeginDrawing();

        r.ClearBackground(r.RAYWHITE);

        r.DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, r.WHITE);

        r.DrawText("this IS a texture loaded from an image!", 300, 370, 10, r.GRAY);

    r.EndDrawing();
    //----------------------------------------------------------------------------------
}

// De-Initialization
//--------------------------------------------------------------------------------------
r.UnloadTexture(texture);       // Texture unloading

r.CloseWindow();                // Close window and OpenGL context
//--------------------------------------------------------------------------------------
github RobLoach / node-raylib / examples / models / models_billboard.js View on Github external
r.SetTargetFPS(60)                       // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

// Main game loop
while (!r.WindowShouldClose())            // Detect window close button or ESC key
{
    // Update
    //----------------------------------------------------------------------------------
    //r.UpdateCamera(camera);              // Update camera
    //----------------------------------------------------------------------------------

    // Draw
    //----------------------------------------------------------------------------------
    r.BeginDrawing()

        r.ClearBackground(r.RAYWHITE)

        r.BeginMode3D(camera)

            r.DrawGrid(10, 1.0)        // Draw a grid

            r.DrawBillboard(camera, bill, billPosition, 2.0, r.WHITE)

        r.EndMode3D()

        r.DrawFPS(10, 10)

    r.EndDrawing()
    //----------------------------------------------------------------------------------
}

// De-Initialization
github RobLoach / node-raylib / templates / simple_game / simple_game.js View on Github external
// Press enter to return to TITLE screen
            if (r.IsKeyPressed(r.KEY_ENTER) || r.IsGestureDetected(r.GESTURE_TAP))
            {
                currentScreen = 'TITLE'
            }
        } break;
        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)