Skip to content

Commit 6824b18

Browse files
committed
Replace Raylib.get_random_value with rand
1 parent 8affd52 commit 6824b18

File tree

7 files changed

+34
-34
lines changed

7 files changed

+34
-34
lines changed

examples/audio/audio_module_playing.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
circles = Array.new(MAX_CIRCLES) do
4141
CircleWave.new(
4242
Raylib::Vector2.create(
43-
Raylib.get_random_value(10, SCREEN_WIDTH - 40),
44-
Raylib.get_random_value(10, SCREEN_HEIGHT - 40)
43+
rand(10..(SCREEN_WIDTH - 40)),
44+
rand(10..(SCREEN_HEIGHT - 40))
4545
),
46-
Raylib.get_random_value(10, 40).to_f,
46+
rand(10..40).to_f,
4747
0.0,
48-
Raylib.get_random_value(1, 100) / 2000.0,
48+
rand(1..100) / 2000.0,
4949
colors.sample
5050
)
5151
end
@@ -98,13 +98,13 @@
9898
circle.speed *= -1
9999
elsif circle.alpha <= 0.0
100100
circle.alpha = 0.0
101-
circle.radius = Raylib.get_random_value(10, 40).to_f
101+
circle.radius = rand(10..40).to_f
102102
circle.position = Raylib::Vector2.create(
103-
Raylib.get_random_value(circle.radius, SCREEN_WIDTH - circle.radius),
104-
Raylib.get_random_value(circle.radius, SCREEN_HEIGHT - circle.radius)
103+
rand(circle.radius..(SCREEN_WIDTH - circle.radius)),
104+
rand(circle.radius..(SCREEN_HEIGHT - circle.radius))
105105
)
106106
circle.color = colors.sample
107-
circle.speed = Raylib.get_random_value(1, 100) / 2000.0
107+
circle.speed = rand(1..100) / 2000.0
108108
end
109109
end
110110
# ----------------------------------------------------------------------------------

examples/core/core_2d_camera.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@
3232
spacing = 0
3333

3434
MAX_BUILDINGS.times do |i|
35-
buildings[i].width = Raylib.get_random_value(50, 200).to_f
36-
buildings[i].height = Raylib.get_random_value(100, 800).to_f
35+
buildings[i].width = rand(50..200).to_f
36+
buildings[i].height = rand(100..800).to_f
3737
buildings[i].y = SCREEN_HEIGHT - 130.0 - buildings[i].height
3838
buildings[i].x = -6000.0 + spacing
3939

4040
spacing += buildings[i].width.to_i
4141

4242
build_colors[i] = Raylib::Color.create(
43-
Raylib.get_random_value(200, 240),
44-
Raylib.get_random_value(200, 240),
45-
Raylib.get_random_value(200, 250),
43+
rand(200..240),
44+
rand(200..240),
45+
rand(200..250),
4646
255
4747
)
4848
end

examples/core/core_3d_camera_first_person.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@
3333

3434
camera_mode = Raylib::CAMERA_FIRST_PERSON
3535

36-
heights = Array.new(MAX_COLUMNS) { Raylib.get_random_value(1, 12) }
36+
heights = Array.new(MAX_COLUMNS) { rand(1..12) }
3737
positions = Array.new(MAX_COLUMNS) do |i|
3838
Raylib::Vector3.create(
39-
Raylib.get_random_value(-15, 15),
39+
rand(-15..15),
4040
heights[i] / 2.0,
41-
Raylib.get_random_value(-15, 15)
41+
rand(-15..15)
4242
)
4343
end
4444
colors = Array.new(MAX_COLUMNS) do
4545
Raylib::Color.create(
46-
Raylib.get_random_value(20, 255),
47-
Raylib.get_random_value(10, 55),
46+
rand(20..255),
47+
rand(10..55),
4848
30,
4949
255
5050
)

examples/core/core_window_letterbox.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
colors = []
4040
10.times do
41-
colors << Raylib::Color.create(Raylib.get_random_value(100, 250), Raylib.get_random_value(50, 150), Raylib.get_random_value(10, 100), 255)
41+
colors << Raylib::Color.create(rand(100..250), rand(50..150), rand(10..100), 255)
4242
end
4343

4444
Raylib.set_target_fps(60)
@@ -54,7 +54,7 @@
5454
if Raylib.is_key_pressed(Raylib::KEY_SPACE)
5555
# Recalculate random colors for the bars
5656
for i in 0...10
57-
colors[i] = Raylib::Color.create(Raylib.get_random_value(100, 250), Raylib.get_random_value(50, 150), Raylib.get_random_value(10, 100), 255)
57+
colors[i] = Raylib::Color.create(rand(100..250), rand(50..150), rand(10..100), 255)
5858
end
5959
end
6060

examples/shapes/shapes_top_down_lights.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@ def setup_boxes(boxes)
236236

237237
(5...MAX_BOXES).each do |i|
238238
boxes[i] = Raylib::Rectangle.create(
239-
Raylib.get_random_value(0, Raylib.get_screen_width),
240-
Raylib.get_random_value(0, Raylib.get_screen_height),
241-
Raylib.get_random_value(10, 100),
242-
Raylib.get_random_value(10, 100)
239+
rand(0..Raylib.get_screen_width),
240+
rand(0..Raylib.get_screen_height),
241+
rand(10..100),
242+
rand(10..100)
243243
)
244244
end
245245

examples/textures/textures_bunnymark.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ def self.create(position, speed, color)
6868
position = Raylib.get_mouse_position
6969

7070
speed = Raylib::Vector2.create(
71-
Raylib.get_random_value(-250, 250) / 60.0,
72-
Raylib.get_random_value(-250, 250) / 60.0
71+
rand(-250..250) / 60.0,
72+
rand(-250..250) / 60.0
7373
)
7474

7575
color = Raylib::Color.create(
76-
Raylib.get_random_value(50, 240),
77-
Raylib.get_random_value(80, 240),
78-
Raylib.get_random_value(100, 240),
76+
rand(50..240),
77+
rand(80..240),
78+
rand(100..240),
7979
255
8080
)
8181
bunnies << Bunny.create(position, speed, color)

examples/textures/textures_particles_blending.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ def active=(new_active) self[:active] = new_active end
5555
mouse_tail.each do |particle|
5656
particle.position = Raylib::Vector2.create(0, 0)
5757
particle.color = Raylib::Color.create(
58-
Raylib.get_random_value(0, 255),
59-
Raylib.get_random_value(0, 255),
60-
Raylib.get_random_value(0, 255),
58+
rand(0..255),
59+
rand(0..255),
60+
rand(0..255),
6161
255
6262
)
6363
particle.alpha = 1.0
64-
particle.size = Raylib.get_random_value(1, 30) / 20.0
65-
particle.rotation = Raylib.get_random_value(0, 360)
64+
particle.size = rand(1..30) / 20.0
65+
particle.rotation = rand(0..360)
6666
particle.active = false
6767
end
6868

0 commit comments

Comments
 (0)