I like the type of coding in a game that lends itself to low, or 1 set of code. But I have a problem, I'm not exactly sure how to go about that.
I'm making a game right now that has enemies that run away from you, and so far I have made 1 AI with : "detectors, health bar, and other items". Question is, How would I go about copying this enemy around. All the code I wrote pertains to just this enemy, and I imagine if I were to copy it; what happens to one will happen to the other.
So, how do you guys make a really complex enemy with grouped events, health bars, detectors, etc and then mass produce it without copying events and/or changing the active object/counter which goes with it.
I just want one set of enemies per enemy type. I guess that would be the summary of this post.
Whatever makes level design easier is what I want to use.(codewise and design wise)
**I mean mass producing as a general phrase for copying out of run time, not in.**
...sorry about my broken English I'm actually attending a writing class right now so I'm hoping that improves.
It should be possible to do this. However it can be quite tricky. Using detectors for every enemy is possibly the most difficult one, so I advice to read this article: http://www.create-games.com/article.asp?id=1639 where you embed the detectors in the animation of every enemy.
Obviously, health and such things should be organized by using alterable values. I'm not sure what you mean with health bar, like every enemy should display its health above them? (sorta like in RTS games) In that case, it's possible to create multiple counters that follow and display each enemy's health.
eg:
Number of counter< Number of enemies => create counter at (0,0) of enemy
Always => set position etc.. and set value to Alterable Value etc...
So if you understand what I said above: it's completely possible, but you'll probably need to recode some stuff.
One of the things I hate about mmf is the lack of control over object instances. Specifically the whole 'object focus' thing pisses me off.
Anyways...
Consider how many enemies you will have at the same time on-screen or active at the same time. Many games never have the player engaging in more than 5 or 6 enemies at the same time. In this case you can just have 5 sets of enemies, detectors, health bars etc. Not very elegant but effective. It also allows for VERY complex AI/detector operations. But ya, this depends on what kind of game your making.
Use alterable values.
*Alterable Value x = 0: Destroy enemy
*Collisions between Weapon and Enemy: Subtract x from alterable value x
*(When you wana make and enemy): Create enemy at where ever (out of frame for random position) set Alterable Value x to x.
Anything else need at start up can be added to another Alterable Value. To give an enemy a tag so it can be found later, on creation: Set alterable value x to Counter. Add 1 to counter. If you want them to fire at certain times,
*Always: Add 1 to Alterable Value x (Repeats 50 times a second)
*Alterable Value x = x: Set alterable value x to 0, Shoot an object from enemy.
If the enemies have a lifespan or something to make them massively do something loop:
*Alterable value x = 0: do ____, set Alterable value x to 1.
Then loop
*Alterable value x = 1: Set alterable value x to 0.
If it's timed then use a counter.
Also you can use arrays (You might need a 3D array though)
"last one left to die, please turn out the light."
The human child body template used in my avatar was made by Show Kaizer who can be found on rmxp.org forums.