beginners text adventure problem

SYS 64738
MarcWalters
Member
Member
Posts: 55
Joined: Wed Jun 11, 2014 2:33 pm
Location: Lake Macquarie, NSW, Australia
Contact:

Re: beginners text adventure problem

Post 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.


User avatar
Shaun_B
Member
Member
Posts: 179
Joined: Tue May 06, 2014 12:12 pm
Location: UK
Contact:

Re: beginners text adventure problem

Post 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.
BASIC Programming - making the mistakes so that you don't have to.
Circles and Squares.
Nothing I post here will stand up in a court of law.
dudz
Member
Member
Posts: 140
Joined: Tue Jun 17, 2014 5:40 am
Contact:

Re: beginners text adventure problem

Post 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.
User avatar
drpump
Member
Member
Posts: 7
Joined: Mon Aug 04, 2014 5:43 pm
Location: london
Contact:

Re: beginners text adventure problem

Post 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?
User avatar
drpump
Member
Member
Posts: 7
Joined: Mon Aug 04, 2014 5:43 pm
Location: london
Contact:

Re: beginners text adventure problem

Post 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.
MarcWalters
Member
Member
Posts: 55
Joined: Wed Jun 11, 2014 2:33 pm
Location: Lake Macquarie, NSW, Australia
Contact:

Re: beginners text adventure problem

Post 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.
User avatar
Shaun_B
Member
Member
Posts: 179
Joined: Tue May 06, 2014 12:12 pm
Location: UK
Contact:

Re: beginners text adventure problem

Post 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.
BASIC Programming - making the mistakes so that you don't have to.
Circles and Squares.
Nothing I post here will stand up in a court of law.
iceout0002
Member
Member
Posts: 1
Joined: Wed Apr 16, 2014 11:49 pm
Location: United States
Contact:

Re: beginners text adventure problem

Post 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.
jonnypencils
Member
Member
Posts: 2
Joined: Tue Aug 12, 2014 6:54 pm
Location: UK
Contact:

Re: beginners text adventure problem

Post 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.
User avatar
Shaun_B
Member
Member
Posts: 179
Joined: Tue May 06, 2014 12:12 pm
Location: UK
Contact:

Re: beginners text adventure problem

Post 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.
BASIC Programming - making the mistakes so that you don't have to.
Circles and Squares.
Nothing I post here will stand up in a court of law.
Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 4 guests