locked
How to make a Text adventure? RRS feed

  • Question

  • Hello again,
    I hope i am not bugging people with my questions. I have another one for you all.

    How can i make a text adventure?

    I have been programming for, about maybe a month now. and i want to make a more, complex game, instead of a simple number guessing game. (well, i had trouble with it, but i pushed through. :p)
    So, how do i? i had this basic idea:

    'Text adventure 0.1
    'let's hope this works!
    TextWindow.Title = "Text"
    TextWindow.WriteLine("You wake up in a dark forest, with a wound in your leg. You are thirsty,and could use some water.")
    TextWindow.WriteLine("Commands: Search for water , cover your wound")
    Com = TextWindow.Read()
    If Com = "search for water" Or "Search for water" Then 
      Goto page1
      EndIf
      If Com = "Cover your wound" Or "cover your wound" Or "cover wound" Then
        Goto page2 
      EndIf
      
      
      page1:
    TextWindow.WriteLine("You should probly cover your wound first.")
    TextWindow.WriteLine("Commands: Cover your wound ")
    
    page2:
    TextWindow.WriteLine("You grab a near by leaf, and cover the wound in you leg.")
    TextWindow.WriteLine("Commands: Search for water , lay there")
    But i didn't get far. i apreciate any help, but please don't lead me to extensions. thanks!

    Small Basic Beginner. :3

    Saturday, April 6, 2013 4:11 AM

Answers

  • Hi 8BiT

    As well as the good advice by LitDev and effective sample by Nonki can I recommend this article by LitDev on "Small Basic Programming Tips". Has some great tips for structuring your programs.

    http://social.technet.microsoft.com/wiki/contents/articles/15081.small-basic-programming-tips.aspx

    I like Nonkis sample of the nested While loops because I've got a nested while problem right at the moment. So asking questions on the forum not only helps the person asking the question but can benefit others. Thanks for asking.

    • Marked as answer by 8Bit Pony Monday, April 8, 2013 12:34 AM
    Sunday, April 7, 2013 10:25 PM
  • Your program looks fine and I suggest you keep going like you have for a bit to get the game ideas started.

    At some point it will get complicated and you will want to consider try a more structured approach.  This will involve:

    1] Creating a mind map or drawing of the game and all the paths the user can go and their actions at each stage and what the game will do.  Think up a good story in some detail.

    2] Finding some way to store each position in the story the user is at and what options are available at each point.

    3] White some subroutines to ask appropriate questions at the current point and get on of the options to move to the next part of the story.  Perhaps just enter a number for each of the available options.

    4] You will want to store the current positions in the game and available options and their path to the next point in the story efficiently (perhaps in a file) that you can easily edit and run the game from this data.  In this way you can change the game story easily without changing the code that runs the game.

    5] Perhaps then even add graphics or a map to show progress and make it more interactive.

    A lot of work, but the key is to get started and create something, then be prepared to rewrite as you get a better idea of how to structure it more efficiently.  Don't spend too much effort adding loads detail at this stage, just enough to see how to improve the design bit by bit.

    • Marked as answer by 8Bit Pony Monday, April 8, 2013 12:34 AM
    Saturday, April 6, 2013 9:59 AM
  • If I make a text adventure, I will separate program and story data such as follows.

    TextWindow.Title = "Text"
    CRLF = Text.GetCharacter(13) + Text.GetCharacter(10)
    InitStory()
    scene = 1
    While story[scene] <> ""
      TextWindow.Write(story[scene])
      If ask[scene] <> "" Then
        ans = ""
        While jump[scene][ans] = ""
          TextWindow.Write(ask[scene])
          ans = Text.ConvertToLowerCase(TextWindow.Read())
        EndWhile
        scene = jump[scene][ans]
      Else
        scene = scene + 1
      EndIf
    EndWhile
    Sub InitStory
      story[1] = "You wake up in a dark forest, with a wound in your leg.  "
      story[2] = "You are thirsty, and could use some water." + CRLF
      ask[2] = "Commands: Search for water , cover your wound" + CRLF
      jump[2] = "search for water=3;cover your wound=4;cover wound=4;"
      story[3] = "You should probly cover your wound first." + CRLF ' page 1
      ask[3] = "Commands: Cover your wound" + CRLF
      jump[3] = "cover your wound=4;cover wound=4;"
      story[4] = "You grab a near by leaf, and cover wound in you leg." + CRLF ' page 2
      ask[4] = "Commands: Search for water , lay there" + CRLF
      jump[4] = "search for water=5;lay there=5;"
      story[5] = "The End" + CRLF
    EndSub
    


    Nonki Takahashi

    • Marked as answer by 8Bit Pony Monday, April 8, 2013 12:34 AM
    Sunday, April 7, 2013 5:06 AM

All replies

  • Your program looks fine and I suggest you keep going like you have for a bit to get the game ideas started.

    At some point it will get complicated and you will want to consider try a more structured approach.  This will involve:

    1] Creating a mind map or drawing of the game and all the paths the user can go and their actions at each stage and what the game will do.  Think up a good story in some detail.

    2] Finding some way to store each position in the story the user is at and what options are available at each point.

    3] White some subroutines to ask appropriate questions at the current point and get on of the options to move to the next part of the story.  Perhaps just enter a number for each of the available options.

    4] You will want to store the current positions in the game and available options and their path to the next point in the story efficiently (perhaps in a file) that you can easily edit and run the game from this data.  In this way you can change the game story easily without changing the code that runs the game.

    5] Perhaps then even add graphics or a map to show progress and make it more interactive.

    A lot of work, but the key is to get started and create something, then be prepared to rewrite as you get a better idea of how to structure it more efficiently.  Don't spend too much effort adding loads detail at this stage, just enough to see how to improve the design bit by bit.

    • Marked as answer by 8Bit Pony Monday, April 8, 2013 12:34 AM
    Saturday, April 6, 2013 9:59 AM
  • If I make a text adventure, I will separate program and story data such as follows.

    TextWindow.Title = "Text"
    CRLF = Text.GetCharacter(13) + Text.GetCharacter(10)
    InitStory()
    scene = 1
    While story[scene] <> ""
      TextWindow.Write(story[scene])
      If ask[scene] <> "" Then
        ans = ""
        While jump[scene][ans] = ""
          TextWindow.Write(ask[scene])
          ans = Text.ConvertToLowerCase(TextWindow.Read())
        EndWhile
        scene = jump[scene][ans]
      Else
        scene = scene + 1
      EndIf
    EndWhile
    Sub InitStory
      story[1] = "You wake up in a dark forest, with a wound in your leg.  "
      story[2] = "You are thirsty, and could use some water." + CRLF
      ask[2] = "Commands: Search for water , cover your wound" + CRLF
      jump[2] = "search for water=3;cover your wound=4;cover wound=4;"
      story[3] = "You should probly cover your wound first." + CRLF ' page 1
      ask[3] = "Commands: Cover your wound" + CRLF
      jump[3] = "cover your wound=4;cover wound=4;"
      story[4] = "You grab a near by leaf, and cover wound in you leg." + CRLF ' page 2
      ask[4] = "Commands: Search for water , lay there" + CRLF
      jump[4] = "search for water=5;lay there=5;"
      story[5] = "The End" + CRLF
    EndSub
    


    Nonki Takahashi

    • Marked as answer by 8Bit Pony Monday, April 8, 2013 12:34 AM
    Sunday, April 7, 2013 5:06 AM
  • Hi 8BiT

    As well as the good advice by LitDev and effective sample by Nonki can I recommend this article by LitDev on "Small Basic Programming Tips". Has some great tips for structuring your programs.

    http://social.technet.microsoft.com/wiki/contents/articles/15081.small-basic-programming-tips.aspx

    I like Nonkis sample of the nested While loops because I've got a nested while problem right at the moment. So asking questions on the forum not only helps the person asking the question but can benefit others. Thanks for asking.

    • Marked as answer by 8Bit Pony Monday, April 8, 2013 12:34 AM
    Sunday, April 7, 2013 10:25 PM
  • Thank you every one! you all have helped me very much. @ Jibba Jabba That article really helped. it will really make my codes neater, and less confusing to me! @ Nonki Takahashi That will help me alot. thanks! @ Litdev Those tips help, thank you! 


    Small Basic Beginner. :3

    Monday, April 8, 2013 12:34 AM