Remainder challenge

I wrote this code for raylib in c++ as example of remainder:

#include "raylib.h"
#include "raymath.h"
#include <cmath>

int main()
{

    const int winWidth {1920};
    const int winHeight {1080};
    InitWindow(winWidth, winHeight, "..::Math Raylib::..");

    SetTargetFPS(60);

    int rand {};
    int shuffleNumber {};
    const int numberPlayers {4};

    while(!WindowShouldClose())
    {
         BeginDrawing();
            ClearBackground(WHITE);
            
            Vector2 v1 { 4.0f, 5.0f };
            Vector2 v2 { 1.0f, 3.0f };

            Vector2 add = Vector2Add(v1,v2);
            Vector2 sub = Vector2Subtract(v1, v2);
            Vector2 sub2 = Vector2Subtract(v2, v1);
            Vector2 normalizing = Vector2Normalize(Vector2 {5.0f, 12.0f});

            float dot = Vector2DotProduct(Vector2{1.f,0.f}, Vector2{-3.f, 4.f});

            DrawRectangle( 10, 10, 400, 120, Fade(RED, 0.4f));
            DrawRectangleLines( 10, 10, 400, 120, RED);

            DrawText(TextFormat("v1 + v2: [%3.2f, %3.2f]", add.x, add.y), 15, 15, 20, BLACK);
            DrawText(TextFormat("v2 - v1: [%3.2f, %3.2f]", sub.x, sub.y), 15, 35, 20, BLACK);
            DrawText(TextFormat("v1 - v2: [%3.2f, %3.2f]", sub2.x, sub2.y), 15, 55, 20, BLACK);
            DrawText(TextFormat("normalize: [%3.2f, %3.2f]", normalizing.x, normalizing.y), 15, 75, 20, BLACK);
            DrawText(TextFormat("dotProduct: [%3.2f]", dot), 15, 95, 20, BLACK);

            DrawRectangle(0, 125, winWidth, 80, BLACK);
            DrawText("Random a start player pressing G key!", 10, 135, 25, WHITE);

            // Updates
            if(IsKeyPressed(KEY_G))
            {
                rand = GetRandomValue(1, 100);
                shuffleNumber = (rand % numberPlayers)+1;
            }

            // Drawing
            DrawText(TextFormat("Selected Player is: %d", shuffleNumber), 10, 165, 25, RED);

         EndDrawing();
    }

    return 0;
}

I put another code beyond the challenge asked for. Only some lines are necessary!

Probably in wrong forum!

Privacy & Terms