JavaScript EditorFree JavaScript Editor     Ajax Editor 

Main Page
  Previous Section Next Section

Building and Playing Shadow Land

Shadow Land is the only game so far that is almost totally portable. This is due to the fact that the game is text only. The only two things that might change this statement are that Shadow Land uses kbhit() and the ANSI color text driver. The ANSI color driver was used back in DOS days to allow special escape sequences to be used to change colors in pure text applications. To enable it, simply add the line


to your config.sys file. If there's a problem, then simply search on your system for ANSI.SYS and use the proper path. Other than that, the code is straight C/C++ without any graphics or machine-dependent calls. To build the program, use the source module called SHADOW.CPP, compile it as a CONSOLE application (not a win32 .EXE), and link it with the standard C/C++ libraries and that's all you need to do. I have created an executable called SHADOW.EXE for you already, if you don't want to do this.

You already know just about everything you need to know to play. However, here are a few tips. The game will begin by asking for your name. Then it will ask you what you want to do. At this point in the game, you are standing in the entryway to my apartment. To your left is a kitchen and to the north is a hallway. Move around in the environment with the "move" command and be sure to listen and smell everything. Remember "move" by itself will always move you in the direction you are currently facing, and "look" needs to be qualified by a nautical direction if you wish to see the objects in the room.

Shadow's Game Loop

The game loop for Shadow Land is extremely simple since it's not in real-time. Here it is in Listing 14.12.

Listing 14.12 The Game Loop of Shadow Land
void main(void)

// call up intro

printf("\n\nWelcome to the world of  S H A D O W  L A N D...\n\n\n");

// obtain users name to make game more personal
printf("\nWhat is your first name?");

// main event loop,note: it is NOT real-time
     // put up an input notice to user

     printf("\n\nWhat do you want to do?");

     // get the line of text

     // break the text down into tokens and build up a sentence

     // parse the verb and execute the command

     }  // end main event loop

printf("\n\nExiting the universe of S H A D O W  L A N D...
see you later %s.\n",;

// restore screen color

}  // end main

The main() begins by printing an introduction screen and then asking the player for his name. At this point, the game falls into the main event loop, which is static. The loop will wait for the user to type in a string which is returned from Get_Line(). Then the string is tokenized by Extract_Tokens() and finally parsed and acted upon the verb parser named Verb_Parser(). That's all there is to it. This cycle will occur every time the player enters a line of text until he types "exit".

Winning the Game

I think I already told you how to do this, but if I didn't, then good luck figuring it out! Also, try adding features to the game. For example, more objects, verbs, a help system. And if you're really up to it, create a graphical display of the room, player, position, and so forth and update the game to a graphic adventure!

      Previous Section Next Section

    JavaScript EditorAjax Editor     JavaScript Editor