mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-23 13:09:11 +00:00
Added algorithm comments to SDL_rand_*()
This commit is contained in:
parent
8f29f8cae5
commit
38cac043af
2 changed files with 14 additions and 9 deletions
|
@ -188,15 +188,15 @@ int main(int argc, char *argv[])
|
|||
quit(2);
|
||||
}
|
||||
for (i = 0; i < NUM_SPRITES; ++i) {
|
||||
positions[i].x = (float)(SDL_rand_n((window_w - (int)sprite_w)));
|
||||
positions[i].y = (float)(SDL_rand_n((window_h - (int)sprite_h)));
|
||||
positions[i].x = (float)(SDL_rand_n(window_w - (int)sprite_w));
|
||||
positions[i].y = (float)(SDL_rand_n(window_h - (int)sprite_h));
|
||||
positions[i].w = sprite_w;
|
||||
positions[i].h = 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_n(MAX_SPEED * 2 + 1) - MAX_SPEED);
|
||||
velocities[i].y = (float)(SDL_rand_n(MAX_SPEED * 2 + 1) - MAX_SPEED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue