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

Leonardo Miliani leonardo at ...1237...
Thu Apr 16 15:06:35 CEST 2009


Doriano Blengino ha scritto:
> jbskaggs ha scritto:
>> 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!
>>   
> I think that GOTOs have nothing to do with OO programming, but instead 
> they relate to "structured programming".
> In C and Pascal (and many many others), which are structured, you can 
> totally avoid GOTOs, if you want. But, as Nando says, sometimes GOTOs 
> are clearer that while-do-loop-if-elseif-elseif and so on.
> The real thing is to have *both* structures and GOTOs; if either is 
> missing, then the language is poor.
> 
> Regards,
> Doriano
> 
> ------------------------------------------------------------------------------
> 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
> 

You are OT.
Subject was how to write an adventure game, not how to program with or
without GOTO's ;-)

Coming back to the original post, a lot of years ago I wrote a couple ob
text-based adventure games based on "rooms".
I created a little matrix (the "rooms") with a basic description of what
was the room, then I had another array that contained the rooms of the
game where the items were located.

Everytime that the player entered a room the game:
- loaded the default description of the room;
- checked if there was an item in that particular room: if yes, it then
loaded the description of the object;
- printed the available exits.

If the player typed to get an object, the program simply checked if that
object was present in the room; if the player asked to go in a
particular direction, the program checked if that exit was present too.

This prehambol to say that it is not difficult to implement such kind of
games: you just have to create a general interface and then modify the
available actions depending on what the room contains.


-- 
Ciao.
Leo.

Web: www.leonardomiliani.com
E-mail: leonardo at ...1237...
Scegli software opensource - Choose opensource software

Co-fondatore di Gambas-it.org
Il sito di riferimento della comunità italiana degli utenti di Gambas
www.gambas-it.org




More information about the User mailing list