Make a text console game

Text console games are simpler than graphical ones and help you to learn fundamental C# programming concepts like data structures.

Create a text-only game using the Debug.Log console

The simplest possible game we can make in Unity is one that uses Debug console output and single keys as input.

  1. Make a new scene.
    1. Copy the code for Presser.cs from the pastebin link.
    2. In Project > Create > C# Script
    3. Name it Presser and hit return
    4. Open it in your code editor
    5. Paste the Presser code
    6. Save it
    7. In Unity, Hierarchy > Create > Create Empty
    8. Name it Presser and hit return
    9. Drag the Presser script onto the empty game object
    10. Save the scene, name it Presser
  2. Arrange your Editor to be able to see
    1. Make sure your Game view has focus
    2. Make sure you can see several lines of the Debug Console
    3. In Console panel, disable Collapse because we do not want to combine similar debug messages.
  3. Hit play to test the game
    1. Press RETURN to start the game timer
    2. Press SPACE 10 times as fast as you can
    3. Try to get the fastest time
  4. Hit STOP to end the game
  5. Hit PLAY again
    1. Notice that it saves our high scores from before and remembers them using PlayerPrefs

Presser 2 – The Sequel

  1. Duplicate the Presser script in the Project view
  2. Rename it Presser2
  3. Open it and rename the class at the top to Presser 2
  4. Save the script
  5. Create a new scene
  6. Create an empty game object
  7. Name it Presser2
  8. Drag the Presser2 script onto the object

Making a text console with input

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s