Posted By: GameScore
bounce move - 06/23/09 16:57
hi, i got 2 problems and need a little bit help
i wrote a bounce function for a puk in a hockey game
and my problems are
if my player hits the puk ,the puk does not change his direction where the player kicked him, the puk choose a direction by pure chance and he doesn`t picks up the player speed
last thing i need is, if the puk dont get kicked he should loose speed till he stands still
hope some one can help me with this function
here`s the code
i wrote a bounce function for a puk in a hockey game
and my problems are
if my player hits the puk ,the puk does not change his direction where the player kicked him, the puk choose a direction by pure chance and he doesn`t picks up the player speed
last thing i need is, if the puk dont get kicked he should loose speed till he stands still
hope some one can help me with this function
here`s the code
Code:
function bounce_off()
{
vec_set(temp, bounce);
vec_normalize(temp, vec_length(my._vel_x));
vec_set (my._vel_x, temp);
}
// uses _start_speed
action bouncer()
{
my._start_speed=40;
if (vec_length(my._start_speed) > 0)
{ vec_set(my._vel_x, my._start_speed); }
else { my._vel_x = 40; my._vel_y = 40; my._vel_z =0; }
my._direction = 1;
my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY);
// my.push=1;
set(my,SHADOW);
my.event = bounce_off;
while (1)
{
my._vel_z = 0;
vec_set(temp, my._vel_x);
vec_scale(temp, time_step);
ent_move(nullvector, temp);
my.pan -= my._direction * roll_factor * sign(my._start_speed);
wait(1);
}
}