Two loops at the same time
Is there some clever way to have two loops (kinda) going on at the same time? Example: While the wizard walks a fixed path he shoots fireballs every five seconds.
Sure, just make sure that both loops are in different scripts.
Something like this:
Wizard's script:
Fireloop.c:
Note: scripts have not been tested, use at own risk.
EDIT: Also, there are ways of doing this without using a global variable, but generally I use some 'general purpose globals' that can be used whenever I feel like it on a specific screen.
Something like this:
Wizard's script:
void main(void)
{
&global = ¤t_sprite;
spawn("fireloop");
loop:
move_stop(¤t_sprite,4,x,1);
move_stop(¤t_sprite,6,x,1);
goto loop;
}Fireloop.c:
void main(void)
{
script_attach(0);
int &wizx;
int &wizy;
int &sprite;
loop:
&wizx = sp_x(&global,-1);
&wizy = sp_y(&global,-1);
&sprite = create_sprite(&wizx,&wizy,brain,seq,frame);
//Fire fireball
goto loop;
}Note: scripts have not been tested, use at own risk.
EDIT: Also, there are ways of doing this without using a global variable, but generally I use some 'general purpose globals' that can be used whenever I feel like it on a specific screen.








