Simplified SDL random function names and added thread-safe versions

This commit is contained in:
Sam Lantinga
2024-06-23 12:11:33 -07:00
parent d013ac80ef
commit 96f2f23240
12 changed files with 167 additions and 90 deletions

View File

@@ -74,8 +74,8 @@ static void DrawPoints(SDL_Renderer *renderer)
SDL_SetRenderDrawColor(renderer, 255, (Uint8)current_color,
(Uint8)current_color, (Uint8)current_alpha);
x = (float)SDL_rand_n(viewport.w);
y = (float)SDL_rand_n(viewport.h);
x = (float)SDL_rand(viewport.w);
y = (float)SDL_rand(viewport.h);
SDL_RenderPoint(renderer, x, y);
}
}
@@ -231,20 +231,20 @@ static void loop(void *arg)
break;
case SDLK_l:
add_line(
(float)SDL_rand_n(640),
(float)SDL_rand_n(480),
(float)SDL_rand_n(640),
(float)SDL_rand_n(480));
(float)SDL_rand(640),
(float)SDL_rand(480),
(float)SDL_rand(640),
(float)SDL_rand(480));
break;
case SDLK_R:
num_rects = 0;
break;
case SDLK_r:
add_rect(
(float)SDL_rand_n(640),
(float)SDL_rand_n(480),
(float)SDL_rand_n(640),
(float)SDL_rand_n(480));
(float)SDL_rand(640),
(float)SDL_rand(480),
(float)SDL_rand(640),
(float)SDL_rand(480));
break;
default:
break;