Repeating actions

Started by markcullinane, Sun 22/02/2004 13:31:13

Previous topic - Next topic

markcullinane

I'm making a Pac-Man style mini-game, which is going pretty well. I've got several ghosts moving in pre-set patterns, using MoveCharacterPath. The problem? There are only so many movements the ghosts will make before the game crashes, returning a 'too complex move' error. So, I'm wondering is there any way to repeat the same set of movements again and again infinetly?
Thanks
Mark

Scorpiorus

Try the following approach...


in (room?) repeatedly execute:


if (character[GHOST].walking == 0) { // if  ghost has stopped
   MoveCharacterPath(GHOST, ...);
   MoveCharacterPath(GHOST, ...);
   MoveCharacterPath(GHOST, ...);
   MoveCharacterPath(GHOST, ...);
   MoveCharacterPath(GHOST, ...);
   MoveCharacterPath(GHOST, ...);
}


So, after have performed all the moves the GHOST character start them once again.

~Cheers

CB..

#2
this works ok for a character that periodically picks it self up and moves towards the player..

set  timer3 in as room loads..

then in repeatedly ex

if (IsTimerExpired(3)==1)
{MoveCharacterPath(1, character[EGO].x, character[EGO].y);
SetTimer(3,400);}




///
use yur characters number instead of its name in the MoveCharacterPath(1,etc....

been experimenting with this and it doesnt ever seem to throw the too many moves error..
tho this might hapen with the wrong timer settings and or character movement speeds..
got to allow the following character to stop before it moves again(?) or perhaps this doesnt matter as it goes to the x,y position of the player character as selected when the timer expired..in which case it's probably perfectly reliable no matter what the timer /character speed is (within reason?)

i did try this as well for something else


if (character[EGO].walking!=0){
if (IsTimerExpired(2)==1)
{int ran=Random(3);
if (ran==0) MoveCharacter(DD,character[DD].x,character[DD].y-70);
else if (ran==1) MoveCharacter(DD,character[DD].x,character[DD].y+70);
else if (ran==2) MoveCharacter(DD,character[DD].x+70,character[DD].y);
else MoveCharacter(DD,character[DD].x-70,character[DD].y);
SetTimer(2,200);}
}    
if (character[EGO].walking!=1){
if (IsTimerExpired(3)==1)
{MoveCharacterPath(1, character[EGO].x, character[EGO].y);
SetTimer(3,200);}}



////

but it doesnt work as yud expect..the DD character starts to move towards the ego character when the ego character is stopped...which seems to be the wrong way round?
i wanted the DD charater to wander randomly when the player is stationary and only start to move towards th player if he starts to move...(motion sensor in effect) but the opposite happens..and the random movements still occur canceling out the movecharacterpath command . meaning that im confused..as usual



ok this seems to work..enemy character (DD) moves randomly when player is stationary. and moves to the last checked player x y position when the player moves...

if (character[EGO].walking==0){
if (IsTimerExpired(2)==1)
{int ran=Random(3);
if (ran==0) MoveCharacter(DD,character[DD].x,character[DD].y-70);
else if (ran==1) MoveCharacter(DD,character[DD].x,character[DD].y+70);
else if (ran==2) MoveCharacter(DD,character[DD].x+70,character[DD].y);
else MoveCharacter(DD,character[DD].x-70,character[DD].y);
SetTimer(2,200);}
}    
else if (IsTimerExpired(2)==1)
{MoveCharacterPath(1, character[EGO].x, character[EGO].y);
SetTimer(2,200);}


//////

its still a little bit odd in that the DD characters speed seems to be alered slowed down but thats probably something simple ive not understood    

SMF spam blocked by CleanTalk