Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Text-Based Adventure I was working on last year, figured I'd look over it and ask for some opinions on it
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mattlap




PostPosted: Fri Jun 01, 2012 11:44 pm   Post subject: Text-Based Adventure I was working on last year, figured I'd look over it and ask for some opinions on it

Hey everyone, I'm Matt. I had this semi-complete text-based adventure game sitting in my Turing folder on my computer and I thought I'd take a look at it.
I've went through it and I'd like some opinions on the code its self and the game.
Thanks.



Text_adventure polished-ish.t
 Description:

Download
 Filename:  Text_adventure polished-ish.t
 Filesize:  50.77 KB
 Downloaded:  664 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Aange10




PostPosted: Sat Jun 02, 2012 1:23 pm   Post subject: RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it

Opinions on game = You'd have to write something very enticing to make me play a text adventure.

Opinions on code = Would be much smoother to put the text in a text file and read it. Bulletproofing the get commands wouldn't hurt either.

The program could easily look like
Turing:

proc readFile
readFile, store stuff
end readFile

proc getPassage (passage : int)
get passage # passage
end getPassage
var answer : int := 1
loop % Main program
getPassage (answer)
get answer
end loop
Mattlap




PostPosted: Sun Jun 03, 2012 12:25 am   Post subject: RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it

Alright well I'm kind of a super noob when it comes to programming so would you mind explaining what all of that means? =S
Aange10




PostPosted: Sun Jun 03, 2012 1:05 am   Post subject: RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it

Sure, no problem. That's just psuedo code, meaning it's not actually functioning code. It's just there to give you a basic idea.


But basically what I was saying is that you could get every 'passage' of text from a text file. From there you could lable the passages. After you've done that, all you'd have to do was loop through 2 lines of code to run your game

1) Display the passage with the number the user's answer gave you
2) Get a new answer
jr5000pwp




PostPosted: Sun Jun 03, 2012 11:23 am   Post subject: Re: Text-Based Adventure I was working on last year, figured I'd look over it and ask for some opinions on it

Or you could do something like this:

Turing:

type choices:
     record
          message : string
          choice1 : choices
          choice2 : choices
          choice3 : choices
          choice4 : choices
     end record

var currentChoices : choices
choice : int
loop
     put currentChoices.message
     get choice
     if choice = 1 then
          currentChoices:=currentChoices.choice1
     elsif choice = 2 then
          currentChoices:=currentChoices.choice2
     elsif choice = 3 then
          currentChoices:=currentChoices.choice3
     elsif choice = 4 then
          currentChoices:=currentChoices.choice4
     end if
end loop


You would have to populate them in reverse order, which could be done using a text file, but will probably be easiest done manually in an initializing method, which can be put into another file and pulled in using an include statement to make your main code look neat.

I would have suggested classes, because those allow for custom events for different choices, but turing's class system is so bad that it's not worth it trying to figure it out. (atleast for me)
Aange10




PostPosted: Sun Jun 03, 2012 1:20 pm   Post subject: RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it

The only problem with that data structure, Jr5000, is 1) It's pretty complex for the problem. It's also hard to read all the data in it, given how its dynamically nested. But the biggest problem, would be that there isn't an easy way to go backwards.

With a procedure to correlate a number to a message, you could skip around as you like. You'd also be able to easily tell which number goes to which message.
Mattlap




PostPosted: Sun Jun 03, 2012 4:23 pm   Post subject: RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it

So, Aange10, what would I have to do to use that in my program. Like what is readFile and getPassage? What do they do? That kind of thing. Again exuse the ignorance Razz
Aange10




PostPosted: Sun Jun 03, 2012 4:54 pm   Post subject: RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it

Do you know what procedures are?
Sponsor
Sponsor
Sponsor
sponsor
jr5000pwp




PostPosted: Sun Jun 03, 2012 7:42 pm   Post subject: RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it

I hadn't thought of backtracking, that would require a List of all the previous states, or recursion, which could get messy. The reading could be done, although it may end up reading in like your solution. Regardless, your solution is more practical and easy.
Aange10




PostPosted: Sun Jun 03, 2012 8:01 pm   Post subject: RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it

Mirhagk wrote:

Just remember Occam's razor.

All other things being equal, the simplest solution is best.



Though I am sure there is a more elegant solution than my suggestion too.
jr5000pwp




PostPosted: Sun Jun 03, 2012 9:35 pm   Post subject: RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it

True, I'm sure you can create a more intricate game if you choose an OOP solution, but it wouldn't be very pretty at all the way that turing implements classes. And that is not the kind of solution that Mattlap is requesting.

BTW, what did you intend with "get passage # passage". Is that meant to represent retrieving the passage from an array of passages?
Aange10




PostPosted: Sun Jun 03, 2012 9:46 pm   Post subject: RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it

Pretty much.
Aange10




PostPosted: Mon Jun 04, 2012 1:40 am   Post subject: Re: Text-Based Adventure I was working on last year, figured I'd look over it and ask for some opinions on it

I made an example, try looking at this.

Also, idk why, but Turing's escape keys don't seem to be working for me. Everywhere you see \t there should be a tab, and everywhere you see \n there should be a new line.



A Text Adventure.rar
 Description:

Download
 Filename:  A Text Adventure.rar
 Filesize:  1.95 KB
 Downloaded:  298 Time(s)

Raknarg




PostPosted: Mon Jun 04, 2012 8:11 am   Post subject: RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it

this might be a bit late... but
@jr5000pwp
I think what you're looking for are linked lists, it would be basically the same thing but more organized.
Mattlap




PostPosted: Mon Jun 04, 2012 7:40 pm   Post subject: RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it

So, Raknarg, what are those rofl

edit: Do you remember me? You help me on both this and another project last year Very Happy
My profile pic used to be a lemur sitting cross-legged with its tounge out and then a communist lemur lol
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: