[Gambas-user] Writing a "Choose Your Own Adventure" prototype

jbskaggs jbskaggs at ...1871...
Thu Apr 16 06:21:14 CEST 2009


I am not saying goto isnt needed at all-  just that to do what he is doing it
isn't.  Furthermore too many goto's create spaghetti code which becomes
really hard to follow. :)


But I do get what your saying and I have used goto's the same way- though
not in a while.  For me it was when I began to think less sequentially and
more interconnectedly that my code became clearer and my need for goto's
became less.  And it was hard for me to overcome my habit of:

10 input x
20 if x = 0 then goto 40
30 goto 10
40 print "yeah"
and so on...

I seriously had a hard time grasping that OO was pseudo nonsequential!

JB Skaggs


nando-7 wrote:
> 
> The following is not a true statement:
>    'Becuase Gambas is object oriented  goto's aren't needed.'
> 
> I use Gambas in an OO way and sometimes GOTO is very clear and I use it.
> I also use GOTO when I control to go exactly someplace and (possibly) not
> test or run unnecessary code in-between. 
> I also use GOTO in a soft-real-time (as real as can be).
> 
> A whole bunch of GOTO's can be very confusing.
> OO does require planning though.
> 
> ---------- Original Message -----------
> From: jbskaggs <jbskaggs at ...1871...>
> To: gambas-user at lists.sourceforge.net
> Sent: Wed, 15 Apr 2009 12:39:21 -0700 (PDT)
> Subject: Re: [Gambas-user] Writing a "Choose Your Own Adventure" prototype
> 
>> That would be really easy in Gambas!
>> 
>>
>> 
>> Let me give you a step by step how to do one screen and you can then
>> change
>> it or redo it how you like.
>> 
>> step 1:
>> 
>> create a form with a textbox, a picture box, and three buttons.
>> 
>> Put your reading selection in the textbox, the image in the picture box
>> and
>> the three options on the buttons
>> 
>> so button1.text="Open door."
>> button2.text="Scream for help"
>> etc..
>> 
>> Now in your form editor double click one of the buttons and it will take
>> you
>> to the code page and automatically create an event code:
>> 
>> public sub button1_click()
>> 
>> End
>> 
>> Now between those two lines you would put your code to display a new
>> page. 
>> You have two options really:
>> 
>> 1.  Goto a new form with new controls or
>> 2. Change the data for the controls (ie the text, the picture, and the
>> button labels)
>> 
>> I have done something like this in the past and I stored my texts in
>> small
>> files.  so my button code looked like this:
>> 
>> public sub button1_click()
>> textarea1.text=file.load(user.home &/ "scene1.txt")
>> picturebox1.picture = picture.load(user.home &/ "thispic.png")
>> button1.text="You have been killed!"
>> button2.text="Go back?"
>> Button3.text="Quit."
>> End
>> 
>> I will be glad to help you if you want more help.
>> 
>> JB Skaggs
>> 
>> Marc Carson-3 wrote:
>> > 
>> > I want to make a short adventure game that lets users read text and
>> look 
>> > at an image that explains where they are in the story, and then lets 
>> > them make a decision like, 1) get in the car or 2) run and call the 
>> > police. These choices then branch into other choices, and at many
>> points 
>> > the player may die or complete the adventure in different ways. I hope 
>> > that makes sense...
>> > 
>> > What I'm wondering is, what sort of data structures and approaches to 
>> > this type of software should I use? The last time I did something like 
>> > this, as a youngster, I used GOTO everywhere. :-) But I've heard there 
>> > are better ways.
>> > 
>> > Thanks for any tips for a beginner...
>> > 
>> > Marc
>> > 
>> >
>> ------------------------------------------------------------------------------
>> > This SF.net email is sponsored by:
>> > High Quality Requirements in a Collaborative Environment.
>> > Download a free trial of Rational Requirements Composer Now!
>> > http://p.sf.net/sfu/www-ibm-com
>> > _______________________________________________
>> > Gambas-user mailing list
>> > Gambas-user at lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/gambas-user
>> > 
>> >
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Writing-a-%22Choose-Your-Own-
>> Adventure%22-prototype-tp23064077p23065712.html Sent from the gambas-user 
>> mailing list archive at Nabble.com.
>> 
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by:
>> High Quality Requirements in a Collaborative Environment.
>> Download a free trial of Rational Requirements Composer Now!
>> http://p.sf.net/sfu/www-ibm-com
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
> ------- End of Original Message -------
> 
> 
> ------------------------------------------------------------------------------
> Stay on top of everything new and different, both inside and 
> around Java (TM) technology - register by April 22, and save
> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
> 300 plus technical and hands-on sessions. Register today. 
> Use priority code J9JMT32. http://p.sf.net/sfu/p
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 

-- 
View this message in context: http://www.nabble.com/Writing-a-%22Choose-Your-Own-Adventure%22-prototype-tp23064077p23071197.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list