mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-31 22:56:04 +00:00
Userland: Replace arc4random() with get_random<u32>()
This commit is contained in:
parent
5a0468c21f
commit
090936e424
Notes:
sideshowbarker
2024-07-18 18:08:51 +09:00
Author: https://github.com/boricj
Commit: 090936e424
Pull-request: https://github.com/SerenityOS/serenity/pull/7105
8 changed files with 19 additions and 12 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "Game.h"
|
||||
#include "LevelSelectDialog.h"
|
||||
#include <AK/Random.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
|
@ -191,11 +192,11 @@ void Game::reset_ball()
|
|||
{
|
||||
int position_x_min = (game_width / 2) - 50;
|
||||
int position_x_max = (game_width / 2) + 50;
|
||||
int position_x = arc4random() % (position_x_max - position_x_min + 1) + position_x_min;
|
||||
int position_x = get_random<u32>() % (position_x_max - position_x_min + 1) + position_x_min;
|
||||
int position_y = 200;
|
||||
int velocity_x = arc4random() % 3 + 1;
|
||||
int velocity_x = get_random<u32>() % 3 + 1;
|
||||
int velocity_y = 3 + (3 - velocity_x);
|
||||
if (arc4random() % 2)
|
||||
if (get_random<u32>() % 2)
|
||||
velocity_x = velocity_x * -1;
|
||||
|
||||
m_ball = {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue