Yes, that is exactly how you call it.
- Code: Select all
int iLoop(int xx, int ll, int ul){
if(xx>ul){xx=ll;}
else if(xx<ll){xx=ul;}
return xx;
}
is then called as
- Code: Select all
x=iLoop(x, 0, 10);
int will return an integer. Notice the 'return xx' line in the function.
You can return almost anything...
int ()
float ()
char ()
void () - has no return.
- Code: Select all
void nothing(int xx){
int i=xx;
}
- Code: Select all
nothing(0);
- Code: Select all
void evennothinger(){
}
- Code: Select all
evennothinger();
Note: The iLoop function is how you might make pac-man move from one side of the screen to the other. (value, lower limit, upper limit); Will loop the integer if it is out of bounds.
x=iLoop(x, 0, view.width);
You could call this at the end of draw actor, after all the normal x functions were called (you can move pacman at will, then call this event at the end of draw actor just to make sure pacman stays onscreen).
x+=5;
x=iLoop(x, 0, view.width);
Once you make the function, it's name should be yellow when you type it in a normal script window (you may have to save and close the global code window first).