Moving around a dungeon.
This really irritated me at first and I thought the program had a bug. I double checked with Paul Robsons C version (running on my Mac).
After each door (or secret door) I got heavily disoriented. This was because I expected doors to be features BETWEEN two dungeon locations, this is NOT the case. A door occupies one complete dungeon square. So within the game you can reside “inside” a doorway and look in different diections. Once you know that and get used to it it feels ok (-ish), but expecting otherwise and experiencing this is really weird (it gets even creepier with secret doors).
Anyways – displaying monsters using the above type of lists is now also a straight forward thing:
(already included some optimization regarding positioning and scaling)
Next on the “todo” list was enabling us to attack monsters. While theoretically all easy going… it was not as easy as expected.
- this is sort of a “game interruption” – meaning we enter attack mode, and after the attack finished we return to the main “loop”. For that to work we must build a new “display loop” for the attacks, since we always need to refresh the screen
- input… the original uses a key press to select weapons – the first letter of the weapon is used. Naturally on the vectrex we do not have “letter” buttons. But more importantly we only have four buttons and in Aklabeth you can attack with 6 different “weapons”. We had to devise a playable way to do this…
- unexpected… but not surprising… I had to “debounce” buttons… I hate this, IMHO debounce code always looks bad/stupid…
The ways I do it right now is:
- button 4 to enter attack mode
- use a mixture of button presses of Button 1, 2 and 3 to select the weapon
(keep 1 or more buttons pressed, shows the selected wepon on screen)
- button 4 to execute the attack
This sounds complicated, but after fighting a few battles you get used to it… and it is quicker than a selection menu.
Weapon usage is surprisingly “complex”:
- there are weapons that are only usable by a specific class
- there are melee weapons, distance weapons and both (you can either throw an axe or swing it)
- the amulet is usable by both classes, but behaves differently
- stats of your character influence usage:
– amulet damage depends on dungeon depth
– weapon damage depends on strength
– whether you hit depends on your dexterity
As an “example” – a part of the attack function:
(Chose the weapon – and build a display loop around it. DDAWDraw() – displays the current dungeon.)
The rest of the attack code are mainly these small display loops, which ask for some input. After the attack is calculated and the monster stats are updated, the attack function ends and returns to main loop.
Beware they live!
At the moment the monsters are a dumb bunch, which just stand in the way. Now we have to add Monster AI!
Ok, yes. AI is a big word. But again for a small BASIC program from 1979 – this is cool!
Each time the player moves – all monsters in the current dungeon get a chance to do something. A monster can (depending on circumstances and type):
- attack the player
- move towards the player
- run away from the player
- recover hit points
- steal food (half of the food!)
- steal objects you carry
Implementation wise, this was more of the same. basically “normal” C code – which was mainly used as it was… so there is nothing much to talk about.
This also was no major hassle, basically much text output, done in intertwined display rounds. First time you enter you are supposed to enter your name. For this functionality I have not done a counterpart yet… so you are unnamed :-(.
This was the first version I did. Just all parts transcoded to Vectrex – and got everything running.
You can download the “first version”:
(this version, though feature complete, runs at a terrible frame rate, comments are rare and sometimes missleading – the code is not cleaned up.
To use this you need VIDE installed.
Copy the contents to the “projects” directory and open the contained project file.)
to be continued
(next is optimizing the above)