Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rcore] Calls to GetRandomValue(min, max) will always return min, if not call to InitWindow() #3954

Closed
ChinaBackGo opened this issue May 1, 2024 · 1 comment

Comments

@ChinaBackGo
Copy link

ChinaBackGo commented May 1, 2024


Please, before submitting a new issue verify and check:

  • [x ] I tested it on latest raylib version from master branch
  • [x ] I checked there is no similar issue already reported
  • [x ] I checked the documentation on the wiki
  • [x ] My code has no errors or misuse of raylib

Issue description

Multiple calls to GetRandomValue without a call to InitWindow() first will always yield the min value. For example:

GetRandomValue(10, 100);
GetRandomValue(10, 100);
GetRandomValue(10, 100);
GetRandomValue(10, 100);

will always yield 10.

Expected behaviour even without setting the seed would yield a number other than 10.

Environment

Windows 11

Issue Screenshot

image

Code Example

#include "raylib.h"
#include "raymath.h"


int main() {
    
/*
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] - GetRandomValue bug");
*/
    int rand = 0;
    for (int i = 0; i < 10; i++)
    {
        rand = GetRandomValue(10, 100);
        printf("Rand %d\n", rand);
    }

}
raysan5 added a commit that referenced this issue May 1, 2024
@raysan5
Copy link
Owner

raysan5 commented May 1, 2024

@ChinaBackGo Fixed!

@raysan5 raysan5 closed this as completed May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants