A little brain for the enemies


As the title says I'm working on the enemies and after a couple of days deciding the best approach to use I decided to go with a mixed solution: a part in the main AMOS code that parse a brain script and a part as AMAL program that handle the movements and the animations.

The idea was to build a skeleton AMAL  program and interact with it during the interpretation of the brain script using the AMAL registers.
So I defined the rules, the registers to use as signal codes that make possible acommunication between the AMAL program and the AMOS source.
Bidirectional communication is necessary because if I send a "move" command I cannot go further with the script until the movement has been completed, unless something special happen (like a collision).

After some struggle with implementing this solution, now it seems to work, in the second screenshot you can see a very simple "brain script".
This script is interpreted by the main AMOS program with a frequency that can be tuned (right now every 4 cycles).
In the other screenshot there is some commands I implemented for the for the brain scripts, that will be interpreted by a "generic" AMAL program using the autotest feature to monitor the register R8 (used by the main program to signal an incoming input) while R9 is used by the AMAL program to signal the main source that the task has been completed.

If you are curious and want to see some movement there are two short videos I've uploaded on my Mastodon account that can be viewed clicking in the following links:

  • First test : an enemy with a very simple brain moving left & right using recycled frames
  • Second test : an enemy with its frames with little more complex brain that try to catch the player if he is near enough to be detected. During the video you can also see some triggers activated (the dialog that starts, the opening door and the same door closing).

Some enemies can ignore walls but the one in the second video cannot so you can also see how I implemented walls avoidance, it's not a "path finding" routine, but a more simple (and fast) solution that seems to just work.

Leave a comment

Log in with itch.io to leave a comment.