⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shadow.cpp

📁 一个游戏 F1:记分模式,过关加500分
💻 CPP
📖 第 1 页 / 共 5 页
字号:
      printf("\nI don't understand the object you wish me to put down?");
      return(0);
      } // end else invalid object

   } // end else

} // end Verb_PUT

////////////////////////////////////////////////////////////////////////////////

int Verb_GET(void)
{
// this function will get the object in the current square

object objects[8];  // the objects within reaching distance of player

// this look up table is used to convert object token numbers into object id's

static char object_to_id[]={'l','s','k'};

int token_index=0,   // current token being processed
          index,     // loop index
          index_2,   // loop index
          num_items; // number of items found during vision scan

char object;       // item we are currently looking at

// first test for a object

if (num_tokens==1)
   {
   // no object, so ask what get

   printf("\n%s, what do you want me to pick up?\n",you.name);

   return(1);

   } // end if only get
else
   {
   // check if the next word is an object

   // first test if the word 'the' is inserted bewteen action
   // verb and noun (object)

   token_index=1;

   if (Check_For_Phrase(PHRASE_THE,token_index))
      {
      // consume article since it has to bearing on the final
      // meaning sentence

      // index token scan to directon

      token_index=2;

      } // end if article

   // at this point the token_index is pointing to the object to pick up

   if (sentence[token_index] >= OBJECT_START &&
       sentence[token_index] <= OBJECT_END)
      {
      // at this point we finally know what the user is asking for, so
      // let's do it

      // using vision system scan forward a depth of 2 units this will simulate
      // the player reaching for the object within a reasonable radius

      // convert object to id

      object = object = object_to_id[sentence[token_index]-OBJECT_START];

       // do forward radial scan

      if (Vision_System(3,you.direction,objects,&num_items))
         {

         // test if the object we desire to pick up is within the objects array

         for (index=0; index<num_items; index++)
             {
             // is this what player wants to pick up?

             if (object==objects[index].thing)
                {

                // remove object from universe

                universe_objects[objects[index].y][objects[index].x] = EMPTY_ID;

                // update players inventory (find an empty pocket and place
                // object in it)

                for (index_2=0; index_2<8; index_2++)
                    {
                    if (you.inventory[index_2]==EMPTY_ID)
                       {
                       // put it in pocket

                       you.inventory[index_2]=object;

                       you.num_objects++;

                       break;

                       } // end if an open spot was found

                    } // end for index_2

                // let user know it was picked up

                printf("\nGot it!\n");

                return(1);

                } // end if object found

             } // end for index

         } // end if any objects within reach
      else
         {

         printf("\nYou are too far from it!\n");
         return(0);

         } // end else can't reach

      } // end if object is valid
   else
      {
      printf("\nI don't understand what you want me to pick up?");
      return(0);

      } // end else invalid object

   } // end else

return(0);

} // end Verb_GET

////////////////////////////////////////////////////////////////////////////////

int Verb_EAT(void)
{
// the function will eat the object it is directed to

// this look up table is used to convert object token numbers into object id's

static char object_to_id[]={'l','s','k'};

int token_index=0, // current token being processed
          index;   // loop index

char object;       // object we are currently looking at

// first test for a direction

if (num_tokens==1)
   {
   // no object, so ask what to eat

   printf("\n%s, what do you want me to eat?\n",you.name);

   return(1);

   } // end if only eat
else
   {
   // check if the next word is an object

   // first test if the word 'the' is inserted bewteen action
   // verb and noun (object)

   token_index=1;

   if (Check_For_Phrase(PHRASE_THE,token_index))
      {
      // consume article since it has to bearing on the final
      // meaning sentence

      // index token scan to directon

      token_index=2;

      } // end if article

   // at this point the token_index is pointing to the object to eat

   if (sentence[token_index] >= OBJECT_START &&
       sentence[token_index] <= OBJECT_END)
      {
      // at this point we finally know what the user is asking for, so
      // let's do it

      // scan thru the inventory and test if the player is carrying the
      // object.  Actually, the only thing he can eat is the sandwich, but
      // we need a little comedy relief and this is a good place for it

      for (index=0; index<8; index++)
          {

          // test if this pocket has object we are interested in


          // first convert object token to object id

          object = object_to_id[sentence[token_index]-OBJECT_START];

          if (you.inventory[index]==object)
          {

          switch(you.inventory[index])
                {

                case LAMP_ID:
                     {
                     printf("\nI don't think I can fit this 6 foot long lamp in my mouth!\n");
                     return(1);
                     } break;

                case KEYS_ID:
                     {
                     printf("\nIf you say so...gulp\n");

                     // extract keys from pocket

                     you.inventory[index]= EMPTY_ID;

                     // decrement number of objects on player

                     you.num_objects--;

                     return(1);

                     } break;

                case SANDWICH_ID:
                     {
                     printf("\nThat was good, but it needed more mustard.\n");

                     // extract sanwich from pocket

                     you.inventory[index]= EMPTY_ID;

                     // decrement number of objects on player

                     you.num_objects--;

                     return(1);

                     } break;

                } // end switch pockets

          } // end if this is the object

          } // end for index

      // didn't find the object

      printf("\nI would really like to eat that, but you don't seem to have one.\n");

      return(1);

      } // end if object is valid
   else
      {
      printf("\nI don't understand what you want me to eat?");
      return(0);

      } // end else invalid object

   } // end else

} // end Verb_EAT

////////////////////////////////////////////////////////////////////////////////

int Verb_WHERE(void)
{
// the function tells the player where he is

// based on the tile the player is standing on in the geometry array
// indicate where he is

if (num_tokens==1)
    {
    // what room is player in

    switch(universe_geometry[you.y][you.x])
          {

          case 'l': //- living room
             {
             printf("\n\nYou are in the living room");
             } break;

          case 'b': //- bedroom
             {
             printf("\n\nYou are in the bedroom");
             } break;

          case 'k': //- kitchen
             {
             printf("\n\nYou are in the kitchen");
             } break;

          case 'w': //- washroom
             {
             printf("\n\nYou are in the washroom");
             } break;

          case 'h': //- hall way
             {
             printf("\n\nYou are in the hallway");
             } break;

          case 'r': //- restroom
             {
             printf("\n\nYou are in the master bathroom");
             } break;

          case 'e': //- entry way
             {
             printf("\n\nYou are in the entry way");
             } break;

          case 'o': //- office
             {
             printf("\n\nYou are in the computer office");
             } break;

          default:break;

          } // end switch


    // now state the direction

    switch(you.direction)
          {

          case EAST:
               {
               printf(" facing East.\n");
               } break;

          case WEST:
               {
               printf(" facing West.\n");
               } break;

          case NORTH:
               {
               printf(" facing North.\n");
               } break;

          case SOUTH:
               {
               printf(" facing South.\n");
               } break;

          default:break;

          } // end switch
    return(1);
    } // end if a valid sentence structure
else
   {

   printf("\n%\"%s\" is an invalid sentence.",global_input);
   printf("\n%s, I just don't get it?",you.name);
   return(0);
   } // end else invalid

} // end Verb_WHERE

////////////////////////////////////////////////////////////////////////////////

int Verb_INVENTORY(void)
{
// this function will print out the current inventory

int index; // loop index


// print out the inventory and then test if the player typed too many words
// if so complain a little

printf("\nYou have the following items within your possesion.\n");

// scan thru inventory array and print out the objects that the player is
// holding

for (index=0; index<8; index++)
    {

    // test if this "pocket" has an object in it

    switch(you.inventory[index])
          {

          case LAMP_ID:
               {
               printf("\nA torch lamp.");
               } break;

          case KEYS_ID:
               {
               printf("\nA set of car keys.");
               } break;

          case SANDWICH_ID:
               {
               printf("\nA turkey sandwich.");
               } break;

          default:break;

          } // end switch

    } // end for index

// test if player has nothing on him

if (you.num_objects==0)
   printf("\nYour pockets are empty %s.",you.name);

// test if there are too many words

if (num_tokens>1)
   printf("\n%s, all you hade to say was \"Inventory!\"",you.name);

return(1);

} // end Verb_INVENTORY

////////////////////////////////////////////////////////////////////////////////

int Verb_EXIT(void)
{
// this function sets the global exit and terminates the game

global_exit=1;

return(1);

} // end Verb_EXIT

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -