DEV Community

Cover image for Introduction to User Immersion through TTY:Prompt

Introduction to User Immersion through TTY:Prompt

A Full Stack Engineer who like Batman, has many tools in his utility belt, but always needs more to adapt with the ever changing environment.
Updated on ・5 min read


The thought of creating an interactive application has been a dream of mine since starting this rigorous journey through understanding how to read, conceptualize and write programming languages.

With Ruby, I found it to be a great programming language to start understanding how to interact with users and understanding bare basic concepts of game development and creating an immersive experience for the user. You might be asking yourself, "But John, C# is a programming language that is commonly used throughout the video game industry, why are you using Ruby to understand game development?!"

Ruby itself is a great introductory language and has the ability to do a multitude of different tasks including user interaction through the command prompt utilizing powerful tools called gems.

Gems contain a packaged ruby application or library that can simplify completing tasks. The gem I specifically want to highlight was an easy to use independent prompt component for the TTY toolkit called TTY:Prompt which allowed me as the developer to create a menu system for user interaction thus creating an immersive experience.

How to Use TTY:Prompt

For one to understand how to use TTY:Prompt in creating a robust Command Line Interface Application(CLI), we should first know what it does. What TTY:Prompt creator Piotr Murach says in his how to guide, TTY:prompt is "A beautiful and powerful interactive command line prompt." This allows us the developer to create an interactive and immersive CLI removing hundreds of lines of potential code to gain the same results, thus gaining user input whether for login credentials, searching for a certain stock price, getting a yes or no response, or in our case to progress through a simple text based game utilizing the arrow keys and a selection list, and everything in between.

Steps to using TTY:prompt:

  1. In your app's Gemfile add this gem by typing gem 'tty-prompt'.
  2. Run in your Bash bundle install or bundle to use the gem.
  3. (Optional) You could also manually install the gem by typing gem install tty-prompt in your Bash.

To run this gem throughout your application just put $prompt = manually installed, require 'tty-prompt') in your run.rb file.

Alt Text

You now have the power to call a prompt in any method so get weird!

Alt Text

Functions of TTY:Prompt

TTY:Prompt has many different methods for prompting the user for interaction. Depending on how one wishes to interact with the user would be dependent on the type of prompt method one would use. Let's take a look at some of the different methods we could use to prompt interaction.

ask - Ask a question to the user, this allows for the most dynamic choices and could give the user the most ownership/power and freedom.

Alt Text

yes? - Ask a yes or no question to the user, this is great when you would need a true or false answer, or to confirm an action.

Alt Text

mask - Covers up any input the user places for this prompt, this is great for passwords, secrets, or keys.

Alt Text

select - Creates a list for the user to choose one item from, this is great for a multitude of different reasons such as choosing a character, itemized listing, guided selections, and etc. Great for easily keeping users on a linear path when progressing through a text based game.

Alt Text

multi-select - Creates a list which the user can choose multiple items from, this is great when making a multiple choice question with multiple answers, or selecting multiple items in an item menu to use.

Alt Text

enum-select - Create a list which allows the user to choose an item with a enumerator(number), this is great as an alternative to using the arrow keys for having the user choose amongst the list.

Alt Text

Creating User Immersion

Video Game Immersion as described by Jamie Madigan PH.D. of Psychology Today states, this is derived from "spatial presence". To create spatial presence we should:

  1. Build a rich story
  2. Have consistent behaviors in the game world
  3. Unbroken presentation of the game world
  4. Be able to interact with the game world

Alt Text

Creating an immersive video game might seem like a long shot when developing a CLI, text based game, especially with the technological advancements made in modern day titles including graphically advanced front-end features, and player interactivity through advanced controls/peripherals, UI/HUD elements, interaction choices, and etc. To no surprise though, some of these elements are accessible through CLI and with your keen world building skills and programming through the backend, you might just be able to create an immersive and fun experience for your user.

How TTY:Prompt creates User Immersion

TTY:Prompt allows the user to interact with the Console allowing them to have the power of choice. When a user is given choice, they now have to interact with the system in place. This is important because the user now has the opportunity to become immersed in the experience whether it would be simply to log-in, or tell a secret, to creating a full fledged user driven experience such as a text-based game.

The most immersive video games allow players to make constant choices, either in the perspective of a character or as themselves. With TTY:Prompt we have the ability to do this, we are able to ask players questions leading them to interact with an answer. In the Activision classic, Zork, players had to interact with the console in order to progress through the game. We could use the ask prompt method to recreate this and allow players to make choices by typing a solution such as "open door" or "use rope" to develop a meaningful interaction with them.

Alt Text

Creating a player menu is as simple as using the the select method. This could have a list of items collected like you would imagine to see in a game such as Final Fantasy, or Earthbound. The player in turn would have a choice in selecting an item or spell that they could use.

Alt Text

User and player immersion starts from interacting with the user/player, but develops more deeply as the user/player reciprocates that interaction. We can start developing complex trees of stories, delivering content, or insight on a horror in an abandoned mansion, or adventuring through Dwarven mines that hold a rich secret. The extent of the immersion comes from our own and our user's imagination, and TTY:Prompt allows us to more effectively and easily prompt for user interaction. Immersion comes with interaction, and we now have the tools to create these interactions with a little elbow grease.

Alt Text

Revision(9/17) - Updated 2 images multi-select, enum-select

Discussion (0)