Introduction to Text Games

A text game is a turn-based text-only game that uses line-input.


Text Games are Text Only

Text games are text only. This makes them easy to program and are a great way to explore the fundamental programming concepts you learned in the Basic4GL Tutorial where you learned the core language.1

Text games are also a great way to learn the core concepts of game programming that are used in all types of games including all kinds of ASCII games, 2D games and 3D games — even those programmed using OpenGL — without having to mess with more complicated concepts that those types of games require.

Text Games are Turn-Based

Text games are turn-based. Each "turn" has these stages :

  • The computer prompts the player for input.
  • The player enters input.
  • The computer performs calculations.
  • The computer displays the results of the calculations.
  • Repeat

To illustrate this concept, let's look at the transcript of a classic text game "Guess My Number."

I'M THINKING OF A NUMBER BETWEEN 1 AND 100,
WHAT DO YOU THINK IT IS?

> 50

NO, TOO LOW, YOU HAVE 2 GUESSES LEFT.

I'M THINKING OF A NUMBER BETWEEN 1 AND 100,
WHAT DO YOU THINK IT IS?

>

First, the computer prompts the player for input.

I'M THINKING OF A NUMBER BETWEEN 1 AND 100,
WHAT DO YOU THINK IT IS?

>

The prompt clearly lets the player know what kind of input is expected and shows where the players cursor is with the > prompt.

Then, the player enters input. In this case, a number between 1 and 100

> 50

The computer takes this input and does calculations. In this case, it will compare the number 50 with the number it has randomly chosen between 1 and 100. Nothing is seen by the player at this point. The calculation happens "behind the scenes."

When the computer compares the number it has chosen to the player's guess, it finds that the number is too low and reports that back to the player.

NO, TOO LOW, YOU HAVE 2 GUESSES LEFT.

Finally, the process repeats and the computer prompts the player for input again.

I'M THINKING OF A NUMBER BETWEEN 1 AND 100,
WHAT DO YOU THINK IT IS?

>
page_revision: 12, last_edited: 1209386531|%e %b %Y, %H:%M %Z (%O ago)