[AGDev-newbies] menu sound error

Richard Bennett rbennett at southlink.us
Fri Jun 16 19:13:53 BST 2006


Hey List, I am sorry for posting to this list so much recently, but I am just trying to get some menus or actually a single menu to work. I have posted the code below that deals with the menus. The problem is that it compiles fine with no errors, plays the first sound which a question asking do you want to play, then it will play the second sound which is "select the option you want", but then it stops running and carries me back to my IDE. I don't understand why this is and must have a while loop or something in the wrong area, but can't figure out where it should go if indeed I do have it in the wrong place. Can someone help? All I am trying to do is learn how to do menus, and I think this is the final step in me learning this, but so far, I am stuck in this area. Any help will be appreciated.
BEAN
*** code here***
/* select menu option */
void SelectMenuOption()
{
while(key[KEY_ENTER])
{
     if(g_menu == g_answer)
     {
               if(g_location == 1)
               {
                             allegro_message("This would be the yes module");
                             }
                             if(g_location == 2)
                             {
                                           allegro_message("This would be the no module");
                                           }
                                           }
                                           }
}

                                           /* speak the menu option */
                                           void SpeakMenuOption()
                                           {
                                                if(g_menu == g_answer)
                                                {
                                                          if(g_location == 0)
                                                          {
                                                                      play_sample(sounds[MENUCHOICE], VOLUME, PAN, PITCH, FALSE);
                                                                        rest(4000);
                                                                        }
                                                                        if(g_location == 1)
                                                                        {
play_sample(sounds[YESANSWER], VOLUME, PAN, PITCH, FALSE);
rest(2000);
}
if(g_location == 2)
{
              play_sample(sounds[NOANSWER], VOLUME, PAN, PITCH, FALSE);
              rest(2000);
              }
              }
              }

              
              /* menu down module */
              void MenuDown()
              {
                   g_location=g_location + 1;
while(key[KEY_DOWN])
{

                   if(g_menu == g_answer && g_location >2)
{
                   g_location=1;
}
                   SpeakMenuOption();
}
}

                   /* menu up module */
                   void MenuUp()
                   {
while(key[KEY_UP])
{
                        g_location=g_location -1;
                        if(g_menu == g_answer && g_location < 1)
{
                        g_location =2;
                        }
                        SpeakMenuOption();
                        }
}
                        
                        /* open first question */
                        void OpenFirst()
                        {
                             g_menu=g_answer;
                             g_location=0;
                             SpeakMenuOption();
                             }
                             
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.agrip.org.uk/pipermail/agdev-newbies/attachments/20060616/171b18fd/attachment.html


More information about the AGDev-newbies mailing list