Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Optmization of code

Author
Message
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 22nd Apr 2008 22:22
Hi everyone, Zombie here today with a question about shortening my code up. I have found some computer time and have begun work again on my clickable menu/text story system which seems like its going to work, yay! But, the method I am using requires many subroutines and can eventually become messy, is there another way I could call all of my images up without the use of the subroutines. Any help would be appreciated but for once in my programming experience I am able to do the coding on my own, well except for this haha. Its not essential I just wanted to know if it could be done. The code is here, its not a lot and its been festering for a couple of months and I've been studying off-compy time so I'm sure it could be improved quickly, I just want a second opinion from the heroes of DBC.




Thanks guys and gals,

Ian


Coffee coffee coffee coffee coffee coffee cappacino, JAVA!
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 23rd Apr 2008 02:30
WHERE ARE YOUR RETURNS!!!

slightly over the top but you'll remember to end your subs with returns now :p

I don't see the problem?
If you're going to have lots of choices you're going to have lots of subs.
Are you worried that you'll branch off lots and get into spaghetti land?
To avoid this you could handle the multiple directions/choices by mapping out their data in an array.
Say you start the game in square B,6 the text stored for this square is: "You stand in the centre of a small bustling town, the cobbled stones of the road press through you boots, and the heat of the sun sticks to your cloak like hot tar."
If you want something to interact with I'd keep that in a separate string so you can turn it off when that action can no longer be performed. There is an active action available here: "Stanley, the local blacksmith, is cooling his irons in a pot outside the smithy. Do you wish to talk with him?" - talking to the smith would give us a mission or something.

It is far better to complete a 10 line program than to start a 10,000 line program.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 23rd Apr 2008 02:52
[sorry I had to double post]

In addition to information on the current square, there'd also be a brief synopsis of what lies in the adjacent territories, these would be short strings called by altering the "pointer" to look at the adjacent fields in the array.

To cut a long story short, the benefit is that you don't have to keep track of everywhere the player has been, all you need to do is move between squares and the information will be there.
The trick is to apply this method to the storyline too, it's just an idea I had but It would be pretty cool. I you made a storymap instead of a storyline, you could have many routes to the conclusion, or even several conclusions.
Let's say you talk to the smith and he gives you a quest: "Go to Falencourt and deliver this letter to George Castellan." - accepting the quest would move your story array pointer to the appropriate field. While on the mission you'd have several story fields open to you; deliver the letter, read the letter yourself

It is far better to complete a 10 line program than to start a 10,000 line program.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 23rd Apr 2008 02:58
[sorry guys PS3 limitations]

... or throw away the letter and tell the smith you've delivered it. Each of these actions would lead to different story fields.
It would be hard to organise but much freer to play.

I'll make an example as an experiment

If I haven't helped at all, sorry for the jabbering :p

It is far better to complete a 10 line program than to start a 10,000 line program.
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 23rd Apr 2008 03:52 Edited at: 24th Apr 2008 20:53
Quote: "Are you worried that you'll branch off lots and get into spaghetti land?
"


Yes, very much so, as I am so inexperienced I do not want to end up with a jumbled mess, which can happen quickly if you cannot organize your code properly.

As to the arrays, that sounds wonderful, I've already read TDKs' tut on strings, the only one I have not read is ch. 4 file access, I think that will come into play as well here. So I could have a giant string array and just pick and choose from that pool of data when I need it, that sounds great and much better than ten thousand subroutines. Thank you obese, I have found some more computer time so I will work with this now and give you a report with updated code if you like, if not then thank you very much for the suggestion.

Here we go, couple minutes gave me this .




Ian


Coffee coffee coffee coffee coffee coffee cappacino, JAVA!

Login to post a reply

Server time is: 2025-06-07 17:12:34
Your offset time is: 2025-06-07 17:12:34