JavaScript EditorFree JavaScript Editor     Ajax Editor 



Main Page
  Previous Section Next Section

Making It Real-Time

The text game technology we have been considering thus far is not real-time. This is because the game logic waits for the user to input the text string, the string is processed, the game logic executes, and the cycle starts over. The problem is that during the text input phase, the game logic is in a wait state. This has two effects on the game. First, time stops until the player inputs a string and presses return. Secondly, dynamic objects in the game can't move around; in essence, the game universe can't evolve while the player is "thinking." This may or may not be desired. There are some text games that stop and wait and others run while waiting for text input.

For example, in a real-time text game, the player may sit at the command prompt for ten minutes, but as he does this, he is being surrounded by orcs! To make a game real-time is very easy: All you need to do is slightly change the input function so that it resembles a keyboard handler that only sends the string to the input parser when the Enter key is hit. So, the game event loop might look like this:

while(!done)
   {
   Get_Next_Input_Character();

        if (user has typed in a whole string)
      {
      Parser_Logic();
      } // end if an input was entered
     // whatever happened above, let's move all the

     // objects in the game universe
     Move_Objects();
     } // end main loop

The real-time aspect of this structure is that the input character is not waited for. If there is one, fine; otherwise, game logic continues in real-time.

      Previous Section Next Section
    



    JavaScript EditorAjax Editor     JavaScript Editor