I'm writing a space game, it's a cross between a game I wrote in the 80's (FOFT) and a sort of Star Control 2 type of thing.
In FOFT I actually wrote a programming language (SIMPLE) and gave the user the ability to write programs for the ships computer (EDI) . A bit over the top I admit.
In the new version I still wanted the ships computer to be an important part of the game, though not programmable.
So I wrote a computer class that has memory, offline storage, and processor speed, so the player can buy new computers for his ships.
Then I wrote a program class so the player can buy new programs for his ships.
So I needed an interface to let the ships computer run programs, and gui elements can get values from these programs. This turned out to be very easy. A couple of base classes and and a couple of vectors can model the whole thing.
The first program I wrote was a scanner app, basically the ships radar. While doing it I realised that I needed the alien ships in the game to have computers as well, and that triggered a bit of a brain wave.
This can do all my basic AI.
All I need to do is write behaviours as programs for the ships computer, and they can do everything.
At the moment I just have a radar scanner written and an ecm prog, it works beautifully. Now I'm going to do a prog for heat seeking and radar seeking missiles so the ecm can really have a work out.
Has anyone else used this sort of system?