Simplified SDL random function names and added thread-safe versions

This commit is contained in:
Sam Lantinga committed 2024-06-24 11:49:15 -07:00
1 parent d013ac80ef
commit 96f2f23240
12 files changed
+167 -90

No files matched your search

+10 -10
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;