Giter Club home page Giter Club logo

choose_your_own_adventure_js's Introduction

Choose Your Own Adventure!

Using what you know about data types, variables, operators, conditional blocks, and accepting user input, create a text-based game that allows the user to arrive at different "destinations" based on the inputs they type.

Rules

  • Any path the user goes down must ask them at least three questions.
  • There must be a minimum of seven total destinations the user could arrive at based on their responses.
  • For at least one of the questions asked, there must be more than two possible user responses.
  • Your code must contain at least one loop.
  • Your code must make use of both string and number user inputs.

Hint: For each small milestone you reach in your program, make a git commit

Hint: You may need parseInt() and toString()

Hint: if you finish your code, clean it up by putting certain parts inside functions. If needed they can be used again later as well.

Hint: Need a random number?

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

How to Get User Input

At any point in our JS code, if we write prompt(), a pop up box will open in our browser for a user to enter in text.

// prompts user and stores value in the variable
var valueOfPrompt = prompt()
// logs value stored
console.log(valueOfPrompt)

You can also pass in a string as an argument to have the pop up box contain that string as a ... prompt.

var age = prompt("How old are you?")
alert("You are " + age + " years old.")

Whatever we type into the textbox in the window that prompt() brings up, is returned by prompt to the variable age.

Need Some Inspiration?

How about...

  • A Lord of the Rings style adventure where the player is Frodo, and he must choose how to get to Mordor. Possible obstacles involve Orcs, Goblins and getting drunk on mead.
  • A "Top Chef" style cooking adventure where the player is the chef, trying to make dinner for an elite group of judges. Possible obstacles include overcooking the meal, running out of time or mean judges.
  • A Harry Potter themed adventure where the user is Harry and he must find all the horcruxes. Possible obstacles include He-who-must-not-be-named, Professor Snape or Ron being completely useless.

Pseudo-coded Example

What is your name?

  • Sean

Nice to meet you, Sean. What year would you like to go to? (YYYY)

  • >= 2015
    • I see you're a fan of Back to the Future 2. Would you rather deal with Biff, or Griff? (B/G)
      • Biff
        • Hmm, interesting. Biff is angry and has a cane. Do you stand and fight, or run away like a coward? (S/R)
          • Stand and fight
            • Good choice. Biff is old and feeble at this point. You push him over and he falls in a pile of manure.
          • Run like a coward
            • You get away, but your future son Marty Jr. is heckled for the rest of his days for his dad's cowardice.
      • Griff
        • Griff is asking you if you are in, or out. What do you say? (I/O)
          • In
            • Bad call. Griff and his cronies rob the Hill Valley bank and frame you for it. No more time travel for you.
          • Out
            • Good call. You deck Griff in the jaw and run away. He gives chase on his hoverboard and ends up in a pile of manure.
  • 1985-2014
    • Doc has already destroyed the Time Machine at this point. I guess you'll have to wait around until 2015. What name would you like to go by until then?
      • Calvin Klein
        • Welcome to the future, Calvin Klein.
  • 1955-1984
    • I see you're a fan of Back to the Future 1. Your future Mom has just asked you to the Enchantment Under the Sea dance. What do you do? (Y/N/S)
      • Yes
        • Creepy. I hope you have some backup plan in place to get out of this. Until then, you're stuck in 1955.
      • No
        • Honorable. But this also means that your future Dad will never meet your Mom, and therefore you cannot exist.
      • Set her up with George
        • Interesting. You set up an elaborate plan for your future Dad to surprise your Mom by beating you up. Despite going horribly awry, the plan ultimately works. You may go back to your own time.
  • < 1955
    • I see you're a fan of Back to the Future 3. You've run out of gas and can't get back to your own time! How do you power the Time Machine? (H/M/T)
      • Horses
        • Good idea, but no. The time machine needs to get to 88mph. 12 horsepower ain't gonna cut it.
      • Moonshine
        • You'd be better off drinking the moonshine. Do not pass Go, do not collect $200. Stuck in 1855.
      • Train
        • Good call! This plan seems to be working. But wait! Clara wants to go Back to the Future with you at the last moment. What do you do? (T/L)
          • Take her
            • Interesting choice. Unfortunately the Doc can't grab Clara and get back to the car in time. He ends up staying in 1855 with her.
          • Leave her
            • Smart choice. Unfortunately the Doc was deeply in love with Clara, and when he gets back to 1985 he becomes very depressed.

Part 2: Further: Name

  • Ask the player for their name at the beggining of the game and use it in the game.

Part 3: Further: Keep Score

  • Assign a score for each task in the game. Report the player's score at the end of the game.

Part 4: Further: Make Your Game Repeat as many times as the player wants

  • Have your player repeat a set of challenges or questions over again- if a player enters a situation or room, allow them to leave and come back if they want.

Pseudo-coded Example

  • You are in a dark room. Would you like to enter the left door or the right door?
    • You enter a drawing room with heavy curtains. A mage is sitting on the sofa. Would You like to talk to him? Y/Leave through the right door/Leave through the left door -----> Left door leads to the dark room

Part 5: Further: Make Your Game More Complex

  • Create enemies for your player to face. (Or a series of enemies - perhaps an array of objects)

    • Each enemy can attack your player. (Or your player can recieve powerups or points from other characters)
    • the enemies can (given some randomness- Math.random) hit or miss your player
    • Your player should have hit points that you keep track of in a variable
    • Give your game the ability to enter a "battle loop" between your player and enemy in which the player can fight back, and hurt the enemy.
      • start your enemies with one hit, one kill
    • Randomize your player's "hits" and "misses" on the enemy.
    • Add hit points to the enemies.
  • create weapons that your player can use on the enemies.

    • make those weapons work on many enemies at once.

Part 6: Further: Dynamic Game

  • How would you make your game completely dynamic?
  • Create a game that when started up, the user is presented with a different set of choices than before.
  • Those can be a set of possible choices, or they can each be completely different for every game start. (For example, if the player goes from room to room, randomize which room is next to which room every time.)

choose_your_own_adventure_js's People

Contributors

awongh avatar nickangtc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.