vg4->misc->moving_one_step()
Get positions when moving in x-/y-direction.
SYNTAX
int
vg4->misc->moving_one_step(const struct VG_RectCent *rectc_start,
int angle,
int factor,
struct VG_RectCent **rectc_pos)
FUNCTION PARAMETERS
rectc_start | Starting position |
angle | Moving-angle in degrees |
factor | Factor in 1/10 pixel to multiply moving |
rectc_pos | For returning allocated array with moving positions, must be freed with free() |
RETURN VALUE
Returns the number of elements in rectc_pos
DESCRIPTION
Get positions when moving in x-/y-direction.
The factor controls the velocity.
The end-position of an moving object is calculated according to the angle and the factor.
A factor of 1 would move a the object 1/10th pixel.
E.g. an angle of 90 and a start-x-position of 18
and a factor of 10 sets the end-x-position to 19.
E.g. an angle of 270 and a start-x-position of 18
and a factor of 10 sets the end-x-position to 17.
Example:
- angle = 60, factor = 55
moving 0.87 pixels in x-direction and -0.5 pixels in y-direction multiplied with 5.5
=> moves 5 pixels in x-direction and 3 pixels in y-direction
and sets an array of 6 positions:
- start-x-position + 1 (0.87 * 1), start-y-position - 0 (-0.5 * 1)
- start-x-position + 2 (0.87 * 2), start-y-position - 1 (-0.5 * 2)
- start-x-position + 3 (0.87 * 3), start-y-position - 1 (-0.5 * 3)
- start-x-position + 3 (0.87 * 4), start-y-position - 2 (-0.5 * 4)
- start-x-position + 4 (0.87 * 5), start-y-position - 2 (-0.5 * 5)
- start-x-position + 5 (0.87 * 5.5), start-y-position - 3 (-0.5 * 5.5)
This function can be combined with vg4->misc->move_and_check_collisions().
SEE ALSO