Difference between revisions of "love.math.random"
m (→See Also) |
Flamingarrow (talk | contribs) m (The func is no longer in seeded at the top of love.run) |
||
Line 1: | Line 1: | ||
{{newin|[[0.9.0]]|090|type=function}} | {{newin|[[0.9.0]]|090|type=function}} | ||
− | Generates a pseudo-random number in a platform independent manner. | + | Generates a pseudo-random number in a platform independent manner. This function is seeded at startup, so you generally don't need to seed it yourself. |
== Function == | == Function == |
Revision as of 14:34, 20 July 2020
Available since LÖVE 0.9.0 |
This function is not supported in earlier versions. |
Generates a pseudo-random number in a platform independent manner. This function is seeded at startup, so you generally don't need to seed it yourself.
Contents
Function
Get uniformly distributed pseudo-random real number within [0, 1].
Synopsis
number = love.math.random( )
Arguments
None.
Returns
number number
- The pseudo-random number.
Function
Get a uniformly distributed pseudo-random integer within [1, max].
Synopsis
number = love.math.random( max )
Arguments
number max
- The maximum possible value it should return.
Returns
number number
- The pseudo-random integer number.
Function
Get uniformly distributed pseudo-random integer within [min, max].
Synopsis
number = love.math.random( min, max )
Arguments
number min
- The minimum possible value it should return.
number max
- The maximum possible value it should return.
Returns
number number
- The pseudo-random integer number.
Examples
Generates a number between 1 and 100 (both inclusive).
function love.load()
randomNumber = love.math.random(1, 100)
end
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info