PDA

View Full Version : Help please =)


Twinny
06-23-2006, 07:46 AM
What i eventually want this to do is to have 1 ball chase the mouse and have 2 ball chase 1st ball, 3 chase 2 etc.

Currently the balls float from mouse x and y to player co-ordinates. Can someone tell me whats wrong?

//#CLIENTSIDE
function onCreated()
{

for ( i = 0; i < 5; i ++ )
showimg(i,"light4s.png", mousex, mousey).follow = findimg(i - 1);
settimer(0.1);
}

function onTimeout()
{
for ( i = 0; i < 5; i ++ )
{
with ( findimg( i ))
{
if ( this.follow.type() )
{
temp.angle = getangle(( this.follow.x - this.x),( this.follow.y -this.y));
temp.distance = (( this.follow.x - this.x)^2 + ( this.follow.y - this.y)^2)^0.5;
} else {
temp.angle = getangle((mousex - this.x),(mousey-this.y));
temp.distance = ((mousex - this.x)^2 + (mousey - this.y)^2)^0.5;
}


temp.speed = (temp.distance / 15);
this.x += cos(temp.angle)*temp.speed;
this.y -= sin(temp.angle)*temp.speed;
}
}
setTimer( 0.05 );
}