Class Random
- Namespace
- MohawkGame2D
- Assembly
- GAME 10003 Game Development Foundations - 2D Game Template.dll
Generate random values.
public static class Random
- Inheritance
-
Random
- Inherited Members
Methods
AngleDegrees()
Get a random angle in degrees as a floating-point number.
public static float AngleDegrees()
Returns
- float
Returns a random value from 0.0f (inclusive) to 360.0f (exclusive).
AngleRadians()
Get a random angle in radians as a floating-point number.
public static float AngleRadians()
Returns
- float
Returns a random value from 0.0f (inclusive) to 6.283185307f (exclusive).
Bool()
Get a random Boolean (true or false).
public static bool Bool()
Returns
- bool
Returns a random value of either true or false.
Byte()
Get a random byte.
public static byte Byte()
Returns
- byte
Returns a random value from 0 (inclusive) to 256 (exclusive).
Byte(byte)
Get a random byte.
public static byte Byte(byte max)
Parameters
max
byteThe maximum value (excluded from range).
Returns
- byte
Returns a random value from 0 (inclusive) to
max
(exclusive).
Byte(byte, byte)
Get a random byte.
public static byte Byte(byte min, byte max)
Parameters
Returns
- byte
Returns a random value from
min
(inclusive) tomax
(exclusive).
CoinFlip()
Get a random Boolean (true or false).
public static bool CoinFlip()
Returns
- bool
Returns a random value of either true or false.
Color()
Get a random color.
public static Color Color()
Returns
- Color
Returns a random color with R, G, and B component values of different values from 0 (inclusive) to 256 (exclusive). A is always 255 (opaque).
Color(Color, Color, bool)
Get a random color.
public static Color Color(Color min, Color max, bool ignoreAlpha)
Parameters
Returns
- Color
Returns a random color with R, G, B, and A component values of different values from
min
(inclusive) tomax
(inclusive). A is always 255 (opaque) whenignoreAlpha
is true.
Direction()
Get a random direction vector.
public static Vector2 Direction()
Returns
- Vector2
Returns a random direction vector in any possible direction, where the length of the vector is always exactly 1.0f.
Float()
Get a random floating-point number.
public static float Float()
Returns
- float
Returns a random value from 0.0f (inclusive) to 1.0f (exclusive).
Float(float)
Get a random floating-point number.
public static float Float(float max)
Parameters
max
floatThe maximum value (excluded from range).
Returns
- float
Returns a random value from 0.0f (inclusive) to
max
(exclusive).
Float(float, float)
Get a random floating-point number.
public static float Float(float min, float max)
Parameters
min
floatThe minimum value (included from range).
max
floatThe maximum value (excluded from range).
Returns
- float
Returns a random value from
min
(inclusive) tomax
(exclusive).
GrayscaleColor()
Get a random grayscale color.
public static Color GrayscaleColor()
Returns
- Color
Returns a random color with R, G, and B component values of the same value from 0 (inclusive) to 256 (exclusive). A is always 255 (opaque).
GrayscaleColor(int, int)
Get a random grayscale color.
public static Color GrayscaleColor(int min, int max)
Parameters
Returns
- Color
Returns a random color with R, G, and B component values of the same value from
min
(inclusive) tomax
(inclusive). A is always 255 (opaque).
Integer()
Get a random integer.
public static int Integer()
Returns
- int
Returns a random value from 0 (inclusive) to 2,147,483,647 (exclusive).
Integer(int)
Get a random integer.
public static int Integer(int max)
Parameters
max
intThe maximum value (excluded from range).
Returns
- int
Returns a random value from 0 (inclusive) to
max
(exclusive).
Integer(int, int)
Get a random integer.
public static int Integer(int min, int max)
Parameters
Returns
- int
Returns a random value from
min
(inclusive) tomax
(exclusive).
PointInCircle()
Get a random point inside a unit circle.
public static Vector2 PointInCircle()
Returns
- Vector2
Returns a random value from (-1.0f, -1.0f) (exclusive) to (1.0f, 1.0f) (exclusive), where the max length of the vector is 1.0f.
PointOnCircle()
Get a random point on a unit circle.
public static Vector2 PointOnCircle()
Returns
- Vector2
Returns a random point on a circle, where the length of the vector is always exactly 1.0f.
Vector2()
Get a random Vector2.
public static Vector2 Vector2()
Returns
- Vector2
Returns a random value from (0.0f, 0.0f) (inclusive) to (1.0f, 1.0f) (exclusive).
Vector2(Vector2)
Get a random Vector2.
public static Vector2 Vector2(Vector2 max)
Parameters
max
Vector2The maximum value (excluded from range).
Returns
- Vector2
Returns a random value from (0.0f, 0.0f) (inclusive) to (
max
,max
) (exclusive).
Vector2(Vector2, Vector2)
Get a random Vector2.
public static Vector2 Vector2(Vector2 min, Vector2 max)
Parameters
min
Vector2The minimum value (included from range).
max
Vector2The maximum value (excluded from range).
Returns
- Vector2
Returns a random value from (
min
,min
) (inclusive) to (max
,max
) (exclusive).
Vector2(float, float)
Get a random Vector2.
public static Vector2 Vector2(float maxX, float maxY)
Parameters
maxX
floatThe maximum X value (excluded from range).
maxY
floatThe maximum Y value (excluded from range).
Returns
- Vector2
Returns a random value from (0.0f, 0.0f) (inclusive) to (
maxX
,maxY
) (exclusive).
Vector2(float, float, float, float)
Get a random Vector2.
public static Vector2 Vector2(float minX, float maxX, float minY, float maxY)
Parameters
minX
floatThe minimum X value (excluded from range).
maxX
floatThe maximum X value (excluded from range).
minY
floatThe minimum Y value (excluded from range).
maxY
floatThe maximum Y value (excluded from range).
Returns
- Vector2
Returns a random value from (
minX
,minY
) (inclusive) to (maxX
,maxY
) (exclusive).