Hi,
Im a beginner and this is my first project, i have used very basic techniques,, lik 2-d arrays,,while loops,,
i m writing a brief code to show my logic of makin my game
i m handling my pacman(player) with arrow keys, n monsters will be moving around randomly,
my problem is that once i get a key it goes into main while loop,,then it gets key again n call rightghost(),,in rightghost() therez a while loop to move the monster,when the loop terminates,,it calls another ghost function for keep moving randomly,,,n it goes on in these while loops n never come back to get key again for my player,,I want that my ghosts will keep moving randomly n select their path accordingly when a wall comes(I have done it,but that is violating my main loop)n my pacman is controlled by my with keys aswell .can u plz solve my problem
CODE
int main()
{
ch=getch();
while(ch!=27)
ch=getch();
if(a==1)//declare for making condition
{
rightghost();//(calling my monster function)
}
a=0;//initialized it again so it wont call ghost after every key
if(key==77)
{
//code for moving my pacman
}
and code for rest of the keys,,left,upndown.
return 0;
}
NOW my monster function is
void righghost()
{
while(arr[x][y]!='*')//[i]this is the itterative loop that is moving
// my ghost until a wall of asteriks come[/i]
{
code for movement
}
if(arr[x][y]=='*')
{
a=rand()%3[i];//a random number is generated to
//help random movement of monster[/i] if(a==0)
{
leftghost[i]();//it will work on same condition
//as rightghost did i-e generate
// a random numbre if a wall of "*" comes[/i] }
if(a==1)
{
upghost();
}
if(a==2)
{
downghost();
}