Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development

Trouble with building a text based game using multiple choice-ending outcomes...

Hello, I am a bit rusty/semi-beginner in coding--specifically Java OOP (object- oriented programming) methods--and took a year of AP Comp Sci in high school. I've graduated but never finished one of my projects that I've decided to finish, and quite don't know how to go about it. I noticed there a game building classes here--and java and OOP--but they don't focus on anything text based game making related topics and/or a java OOP class either (just separated). So basically, what I'm looking for is some help on getting my game working and/or help in general. I am going to post my code for this question and if you need a copy of the file(s), I'll send you some.

Plus, I am working with BlueJ (which I was using in my high school course) with Java. Therefore, I would like to not stray too much from what I kind of know what to do--a.k.a. Java OOP coding...

p.s. I've tried asking github, codestack, and quora already with no success (they just deleted and/or voided my questions as irrelevant), so now I'm trying here.

The game is suppose to have multiple choice--er--choices where depending on what choices you choose, they will give you a ending result.

Ex.: You choose A, B, A, C for Questions 1-4 = You get Ending 1

or

You choose B, A, B, D for Questions 1-4 = You get Ending 2

etc.

P.S.S. This not an adventure dungeon-type of text based game, like Zork; rather using similar aspects of certain choices lead to certain outcomes, as I've provided in the comments above.

5 Answers

Sorry for answering a week after.

If you are looking for good Unity tutorials, you could try Brackeys. He has a lot of tutorials already out on his Youtube channel, including 2 or 3 about dialogue systems, quiz games, etc... using Unity's built-in UI. He writes his code in C#, but as long as you understand the logic you can replicate it in Java.

If you want personal help, you can contact me, I have a lot of free time these days. Sorry if the whole answer feels like advertising myself and that Youtube guy, I'm just trying to give my best advice. https://www.youtube.com/watch?v=_nRzoTzeyxU

UPDATE I watched the video you recommended and it helped a lot! I am currently working on the process of formatting it to my BlueJ Java engine and building upon it. I'll get back to you as soon as I can when I manage to fix and possibly get something out of the mess of my actual code for it!

Update 2 I've re-watched the video and now I'm completely confused on how to take the gist from the video and implement it into Java on BlueJ. I kind of understand of what he's doing, but I don't know how to... work it into Java/BlueJ formatting. Can I get your contact information please? Let me know when you can please!

Thank you! I'm sorry for not seeing your response until today! You've might have also noticed that I don't have my code layout/outline posted yet; I was trying to see if I could post a picture of it, or upload it as the .txt format it is in (on BlueJ). I been quite busy, too. I appreciate your advice and look into the video you suggested! If I require further assistance, what may I contact you at? Let me know what is easiest way for you!

P.S. My email is whitesideanton@gmail.com and phone number is 408-442-0014 P.S.S. UPDATE Unable to have contact by phone because I misplaced it! Sorry!

Figured it out!... At least to post the code as pictures to post...

Here It Is: coding for game help coding for game help coding for game help coding for game help

This is text dialogue I want to have and appear as such.

FYI the "....." between each dialogue in the code **ISN"T* suppose to appear; I just put it there to help separate the "thought process" of how AND when the dialogue/options appear/disappear as the player plays...

**Ex.

  1. Game Starts
  2. (after 5 seconds) The 1st line of speech appears (i.e. Unless)
  3. (3 seconds later) 2nd line of speech appears (i.e. Unless what? you may ask?)
  4. (5 seconds later) 3rd line of speech appears (i.e. Unless you have...) -> while the 3rd line appears, the 1st line disappears
  5. ETC. -> after the 1st line disappears, the next one disappears when a new line appears

*Ex. **Process: Line 1 appears -> Line 2 appears -> Line 3 appears & Line 1 disappears -> Line 4 appears & Line 2 disappears -> etc.

Sorry for suddenly posting all of this at once, but this is what I am fully asking of my entire question for this topic.