Originally Posted by
gcarreno
Hey peeps,
I played an Amiga space exploration game in the mid 90' that frustrated me for not being able to finish it.
Is that game perhaps Elite or Elite2?? Spent countless of hours playing both of them.. Now to the questions:
Sounds like using an embedded script language might overshoot the target, could you perhaps settle for some basic database instead? I used Json for something similar (not in pascal, but the principles are the same)
Json makes it easy to store key/value pairs, and it also has (limited) support for conditional branching.
A quickie:
Code:
{
"technology": [{
"id": "hyperdrive_1",
"name": "Basic FTL drive systems",
"prereq": ["playtime", 1],
"researched": true
}, {
"id": "wormhole_1",
"name": "Wormhole Navigation for Dummies",
"prereq": ["playtime", 2],
"reserached": false
}, {
"id": "wormhole_2",
"name": "Advanced Wormhole Navigation",
"prereq": ["wormhole_1", "hyperdrive_1"],
"researched": false
}]
}
Provided that you're using OPascal, you can then fairly easy map each Json-entry to an object, which you then can store away in an array or linked list.
I would parse the file like this (in pseudo-code)
Code:
Load Json-file
Get Json-object count
Make place for them (I've got a sweet spot for dynamic arrays)
For each Json object do
TechID:=id
TechName:=name
for each req in prereq
if prereq-field contains "playtime" then parse next field member as integer
else add TechID;s to list of prerequisits.
TechResearched:=researched
This would also make it easy to serialize all the data for saving and loading purposes, the memory footprint of the json-object isn't an issue as long as you're running on anything else then a C64, or a Casio pocket calculator. When you've researched a technology, change the "researched"-field of that object to true, and at the end of the game write the modified Json-file back to disk. Then the next time you load the game you will start from where you left instead of having to research all techs all over again.
Bookmarks