Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Too fast 4 me :) #138146
06/26/07 09:56
06/26/07 09:56
Joined: Mar 2007
Posts: 27
P
PeterM Offline OP
Newbie
PeterM  Offline OP
Newbie
P

Joined: Mar 2007
Posts: 27
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.

Re: Too fast 4 me :) [Re: PeterM] #138147
06/26/07 21:45
06/26/07 21:45
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
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

Last edited by Manslayer101; 06/26/07 21:52.

- aka Manslayer101

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1