Page 2 of 3

Re: beginners text adventure problem

Posted: Thu Aug 07, 2014 4:47 am
by MarcWalters
I think a more precise description of Shaun's example is that it lessens the amount of memory occupied by the program.

Garbage is generated when a string variable or string array element that has an existing value is assigned a new value. Garbage collection speed won't be affected by the LOC array if its elements are assigned a value once only, and before other variables are assigned their initial values.

However, the use of string storage memory could be lessened, at the cost of a slight performance hit, by generating the room descriptions during a print operation.

Re: beginners text adventure problem

Posted: Thu Aug 07, 2014 7:29 am
by Shaun_B
MarcWalters wrote: However, the use of string storage memory could be lessened, at the cost of a slight performance hit, by generating the room descriptions during a print operation
If you are going to use this method then I would suggest using on...gosub like:

Code: Select all

10 loc = 1
20 on loc gosub 100, 200, 300
30 rem logic
99 end
100 print "location 1"
110 print "description"
199 return
200 print "location 2"
210 print "description"
299 return
300 print "location 3"
310 print "description"
399 return
Regards,

Shaun.

Re: beginners text adventure problem

Posted: Thu Aug 07, 2014 5:53 pm
by dudz
the most important tip to give at this point is to NOT hardcode things like that, but write an actual game engine that reads everything from a common data format which you then can easily extend if needed.

Re: beginners text adventure problem

Posted: Sat Aug 09, 2014 11:28 am
by drpump
Some questions.

1. How do you define rooms with objects in them? and a player?
2. How do you define multiple possible inputs, each with their own response?
3. Do you have the source code to a game that you programmed? If so could you post it?

Re: beginners text adventure problem

Posted: Sat Aug 09, 2014 12:58 pm
by drpump
Oh and how do you change variables to equal something else later on? Sorry for the very basic questions, I understand these may be far below you, but I couldn't find any truly beginners documentation online.

Re: beginners text adventure problem

Posted: Sat Aug 09, 2014 2:55 pm
by MarcWalters
There are many different and equally valid answers to those questions.

If you simply wish to create a limited adventure that uses a simple verb-noun input then check out one of the books that detail the development of such a game from beginning to end. Archive.org hosts some good ones.

Such as:
1) "Commodore 64 Adventures: A Guide To Playing And Writing Adventures" (Mike Grace, 1983, Sunshine Books, ISBN 0946408114)
Read online.
2) "Adventure Gamewriter's Handbook" from Abacus.
Read online
Download the game system
3) "Creating Adventure Games On Your Computer" (Tim Hartnell, 1983)

As you can see, should you peruse them online, implementations vary. But generally the implementation accommodates the BASIC 2.0 language rather than use BASIC to simulate non-native (and more useful) processes and data structures. Despite this, these books from the 1980s are still useful for exploring BASIC implementation and game design.

IMO, a modern adventure game engine, written in BASIC 2.0 would be one based on the Inform system - declarative, object-oriented and event-driven. Writing an engine based on those concepts, cut-down for BASIC 2.0, in 64K at 1Mhz, would be a challenging, non-trivial exercise.
1. How do you define rooms with objects in them? and a player?
2. How do you define multiple possible inputs, each with their own response?
3. Do you have the source code to a game that you programmed? If so could you post it?
1. Perhaps use a 2-dimensional array. The first subscript would indicate the room, the second subscript the room's object. The object's unique ID (an index) would be stored in the array. The object index could then be used to access the item's properties (name, type, etc) which would be stored in other arrays.
The player? Define his inventory as an array and store object IDs in it. Have another array for state information such as location index.

2. There are many ways. Some are elegant, others ugly.
A simple method might use an encoded format that encapsulated the basic rules of each possible action. If the rules were read from DATA statements they could be processed a bit before being stuffed into arrays. But it would still be an ugly brute-force approach. Fortunately, the books listed above have some better ideas.

3. Nope.
Oh and how do you change variables to equal something else later on?
Use the assignment operator, "=". As in
10 A$="red"

Fundamentals for BASIC programming can be found in the Users' Guide.
Go to chapter 4.5: How To Use Variables.

Everything you do towards the goal of writing an adventure program needs to be ordered so that each step is built upon its predecessors. If you skip something, then you'll stall. Once you understand the BASIC language you'll be able to combine that knowledge with imagination and creativity to develop solutions.

Re: beginners text adventure problem

Posted: Sun Aug 10, 2014 10:56 am
by Shaun_B
On the train back last night I started to write a light weight text adventure engine, I'll post the snippets with examples and explanations if you like?

Regards,

Shaun.

Re: beginners text adventure problem

Posted: Tue Aug 12, 2014 3:41 am
by iceout0002
Take a look at my game "Valley Of Treasures" if you need help. It's pretty simplfied but has a decent game in its small size.

Re: beginners text adventure problem

Posted: Tue Aug 12, 2014 6:56 pm
by jonnypencils
Shaun_B wrote:On the train back last night I started to write a light weight text adventure engine, I'll post the snippets with examples and explanations if you like?

Regards,

Shaun.
I'd be very interested to see those please.

Re: beginners text adventure problem

Posted: Mon Aug 18, 2014 10:03 am
by Shaun_B
jonnypencils wrote:
Shaun_B wrote:On the train back last night I started to write a light weight text adventure engine, I'll post the snippets with examples and explanations if you like?

Regards,

Shaun.
I'd be very interested to see those please.
I got distracted for a short while but I have begun writing the documentation for it as my methods might not be immediately obvious.

Edit: aside from the documentation, I've also put the project under version control (something that I would have done but I didn't have an Internet connection on the train) - when it's nearing a public airing I'll put the details here.

Regards,

Shaun.