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

@@ -97,15 +97,15 @@ static int InitSprites(void)
}
for (int i = 0; i < NUM_SPRITES; ++i) {
positions[i].x = (float)SDL_rand_n(WINDOW_WIDTH - sprite_w);
positions[i].y = (float)SDL_rand_n(WINDOW_HEIGHT - sprite_h);
positions[i].x = (float)SDL_rand(WINDOW_WIDTH - sprite_w);
positions[i].y = (float)SDL_rand(WINDOW_HEIGHT - sprite_h);
positions[i].w = (float)sprite_w;
positions[i].h = (float)sprite_h;
velocities[i].x = 0.0f;
velocities[i].y = 0.0f;
while (velocities[i].x == 0.f && velocities[i].y == 0.f) {
velocities[i].x = (float)(SDL_rand_n(MAX_SPEED * 2 + 1) - MAX_SPEED);
velocities[i].y = (float)(SDL_rand_n(MAX_SPEED * 2 + 1) - MAX_SPEED);
velocities[i].x = (float)(SDL_rand(MAX_SPEED * 2 + 1) - MAX_SPEED);
velocities[i].y = (float)(SDL_rand(MAX_SPEED * 2 + 1) - MAX_SPEED);
}
}