Too fast 4 me :)

Posted By: PeterM

Too fast 4 me :) - 06/26/07 09:56

Hello!

I have a problem with my enemy. I generate enemys in my while like so:
Code:
  
while (j!=0)
{
loc.y=random(3000)-1600;
loc.x=random(10100)-5400;
ent_create(enemy,loc,enemy_action);
j-=1;
}



and i set 'j' how much of them i want... but the problem is that more i put in
faster they become. its like their speed is multiplying with their number.

They start to move towords me when im near them so i put c_scan in enemy_action
and called my.event=scan.
here is scan():
Code:
 

function scan
{
if (event_type == EVENT_SCAN && my.health>0 )
{
vec_set(angle_temp,dag.x);
vec_sub(angle_temp,my.x);
vec_to_angle(my.pan,angle_temp);

my.force_x=10*time;
if(temp2.y<150 && my.health>0)
{
if (vun==0)
{
my.skill2+=3*time;
if (my.skill2>=100)
{
my.skill2=0;
vun==1;
}
if (my.health>0)
{
ent_animate(me,"attack",my.skill2,ANM_CYCLE);
}
wait(1);
}
if (my.health<=0)
{

my.skill2=90;

ent_animate(me,"death",my.skill2,ANM_CYCLE);
}

vun==0;


}

if (my.force_x!=0 && temp2.y>150)
{
my.skill1+=10*time;
if (my.skill1>=100)
{
my.skill1=0;
}
my.skill2=0;
ent_animate(me,"walk",my.skill1,ANM_CYCLE);
ent_move(my.force_x,nullvector);
}


}
}



(temp2.y beeing the distance between me and the enemy)

thanks for your help.
Posted By: mpdeveloper_B

Re: Too fast 4 me :) - 06/26/07 21:45

if i read you correctly, you want the spawning speed to be changed? if so:

Code:

var _time;
var _speed = 5; //set the spawning speed here, higher is slower
while (j!=0)
{
_time += 1*time_step;
if (_time > _speed)
{
loc.y=random(3000)-1600;
loc.x=random(10100)-5400;
ent_create(enemy,loc,enemy_action);
j-=1;
_time = 0;
}
}



if you have a6.4 or later this will fix your problem, if not, change time_step to time

this will allow you to set a time for it to spawn each one, change the _speed value to whatever speed you want them to spawn at, the higher the number, the slower they will spawn, if you want a second before another spawn it should be set to 16, 2 seconds is 32, etc
© 2024 lite-C Forums