The issue I'm having is I'm get a zero value returned, no list, just a zero. I break inside of the script right before the return and there is nothing in it. That's why I'm trying to find more documentation or samples. There are values for x,y,hspeed,vspeed,gravity,gravity_direction and spd. Here is how I'm calling it. I'm calling it in the Draw event of my player instance.
if mouse_check_button(mb_left) {
direction = point_direction(o_player.x, o_player.y, mouse_x, mouse_y );
draw_set_colour(c_lime);
draw_line(o_player.x, o_player.y - 30, mouse_x, mouse_y );
}
//are we in firing mode
if mouse_check_button_released(mb_left){
var tra_list = ds_list_create();
spd = 1;
hspeed = 1;
vspeed = -.5;
gravity = .12;
gravity_direction = 270;
tra_list = motion_predict(o_stone,5);
var pos_x, pos_y;
}
Here is the script as it is in my game:
/// motion_predict(instance,steps)
//
// Returns a list data structure populated with the predicted
// positions {x1,y1, x2,y2, ... , xsteps,ysteps} of an instance
// with regard to its current motion, friction, and gravity.
//
// instance instance id, real
// steps number of steps to look ahead, real
//
/// GMLscripts.com/license
{
var instance,steps,dsid,posx,posy,hspd,vspd,grvx,grvy,spd,dir;
instance = argument0;
steps = argument1;
dsid = ds_list_create();
with (instance) {
posx = x;
posy = y;
hspd = hspeed;
vspd = vspeed;
grvx = lengthdir_x(gravity,gravity_direction);
grvy = lengthdir_y(gravity,gravity_direction);
repeat (steps) {
spd = point_distance(0,0,hspd,vspd);
spd = max(0, spd-friction)/spd;
hspd *= spd;
vspd *= spd;
hspd += grvx;
vspd += grvy;
posx += hspd;
posy += vspd;
ds_list_add(dsid,posx);
ds_list_add(dsid,posy);
}
}
var bogus = 1;
return dsid;
}
the var bogus line is just so I can put a breakpoint in before the return.
Thanks,
Joe B