PV_Random

Category: Particles
Since engine version: 3.3 OC

Description

The value will be a random number in the interval from start_value to (not including) end_value. The values in between are not whole integers, but are also in fraction of integers. This means that PV_Random(0, 1) can not only return one value (the 0) but a lot of different values in the interval between 0 and 1.

Syntax

array PV_Random(int start_value, int end_value, int reroll_interval, int seed);

Parameters

start_value:
[opt] Begin of the interval to draw the random number from.
end_value:
[opt] End of the interval to draw the random number from.
reroll_interval:
[opt] Interval in frames after which a new random number will be drawn.
seed:
[opt] Particle-local seed that is used for the random rool. Can be used to draw the same random number two times (see example).

Remark

See the particle documentation for further explanations of the particle system.

Examples

CreateParticle("MagicRing", 0, 0, PV_Random(-100, 100), -20, 100, {Prototype = Particles_Glimmer(), Size = PV_Random(0, 3, 10)}, 100);
Creates 100 particles with a random speed in X direction and a random size (which changes every ten frames).
var min_speed = 50;
var max_speed = 100;
var min_angle = 0;
var max_angle = 360;
CreateParticle("SphereSpark", 0, 0, 
	PV_Sin(PV_Random(min_angle, max_angle, 0, 1), PV_Random(min_speed, max_speed, 0, 2)),
	PV_Cos(PV_Random(min_angle, max_angle, 0, 1), PV_Random(min_speed, max_speed, 0, 2)),
	PV_Random(10, 200),
	Particles_Glimmer(), 400);
Uses the particle-local seed to draw the same angle and radius for the X and Y speed of the particle. This leads to a radial distribution (instead of a square). The seed parameter is set to the same number (here 1 and 2) where the same result should be drawn.
See also: CreateParticle, PC_Bounce, PC_Die, PV_Cos, PV_Direction, PV_KeyFrames, PV_Linear, PV_Sin, PV_Speed, PV_Step
Zapper, 2013-10