Difference between revisions of "love.math.random"
m (Fixing my own dumb typo) |
(clarify codomain of functions) |
||
Line 2: | Line 2: | ||
Generates a pseudo random number in a platform independent way. | Generates a pseudo random number in a platform independent way. | ||
== Function == | == Function == | ||
− | Get uniformly distributed pseudo random number in [0,1]. | + | Get uniformly distributed pseudo random real number in [0,1]. |
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 12: | Line 12: | ||
{{param|number|number|The pseudo random number.}} | {{param|number|number|The pseudo random number.}} | ||
== Function == | == Function == | ||
− | Get uniformly distributed pseudo random | + | Get a uniformly distributed pseudo random integer in [0,max] |
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 22: | Line 22: | ||
{{param|number|number|The pseudo random number.}} | {{param|number|number|The pseudo random number.}} | ||
== Function == | == Function == | ||
− | Get uniformly distributed pseudo random | + | Get uniformly distributed pseudo random integer in [min, max]. |
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> |
Revision as of 07:30, 4 July 2014
Available since LÖVE 0.9.0 |
This function is not supported in earlier versions. |
Generates a pseudo random number in a platform independent way.
Contents
Function
Get uniformly distributed pseudo random real number in [0,1].
Synopsis
number = love.math.random( )
Arguments
None.
Returns
number number
- The pseudo random number.
Function
Get a uniformly distributed pseudo random integer in [0,max]
Synopsis
number = love.math.random( max )
Arguments
number max
- The maximum possible value it should return.
Returns
number number
- The pseudo random number.
Function
Get uniformly distributed pseudo random integer in [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 number.
Examples
Generates a number between 1 and 100 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