SimFlight

Category: Objects / Movement
Since engine version: 1.0 OC

Description

Simulates the motion of a falling object with a given starting position and initial speed. The returned array will contain [int x_final, int y_final, int xdir_final, int ydir_final, int time_passed].
If the projected trajectory encounters a material of the specified density, the simulation will stop and time_passed will be non-negative. Otherwise, time_passed will be negative.

Syntax

array SimFlight(int x, int y, int xdir, int ydir, int min_density, int max_density, int iterations, int precision);

Parameters

x:
[opt] X offset of the starting position. (NOT optional if used in nil object context)
y:
[opt] Y offset of the starting position. (NOT optional if used in nil object context)
xdir:
[opt] Initial horizontal speed. If not specified this will default to the object's horizontal speed. (NOT optional if used in nil object context)
ydir:
[opt] Initial vertical speed. If not specified this will default to the object's vertical speed. (NOT optional if used in nil object context)
min_density:
[opt] Minimum density of the material which will stop the projected trajectory. If not specified this will default to value 50 (solid material).
max_density:
[opt] Maximum density of the material which will stop the projected trajectory. If not specified this will default to value 100.
iterations:
[opt] Number of simulated frames for which the projection runs. If not specified or nonpositive the simulation will run indefinitely until material or the limits of the landscape are encountered.
precision:
[opt] Precision of the velocity input and output parameters (xdir, ydir, xdir_final and ydir_final). Defaults to 10 if not specified.

Example

if (GetAction() == "Jump")
{
	var end = SimFlight()
	if (end[3] >= 80)
		Message("Oh oh, this will be a rough impact!");
}
If the calling clonk is situated in mid-air and it appears that he will hit the ground at high speed, he will call out.
Newton, 2004-03
Peewee, 2010-10