I've been working on setting up the base system for enemies and it's just about done. I had quite a difficult time with it, and it's still not quite how I want it but I guess I can just extend it if need be from here. Not everything is finished yet, but I want to discuss what my plans are for this enemy system.
The system is set up to handle Lua scripting. It's a big contrast from MMF2's event editor but there's a couple of reasons I chose Lua scripts over MMF2 events.
1. It's accessible.
I've mentioned this before, but one of the reasons I started the X Editor was because not everyone interested in this engine has access to MMF2. External scripting is a good method as it allows everyone to have customizable options available to them. There are plenty of guides and tutorial on Lua scripting, but I plan on making my own eventually for dedicated X Engine use.
2. It's modular.
What does that mean? Basically it means that if someone makes an enemy (let's say Sniper Joe), it can be compressed as a package and used by everyone. All it takes for you to use that Sniper Joe in your own game, is just to import it in the X Editor and plop it wherever you want. Even then you're still free to customize that Joe as you like, so if you only need it for base work and want to add in your own little features, you're perfectly free to do so.
3. It's fast.
Of course, this varies from PC to PC, but the common rule is that Lua scripts are much more optimized to run than MMF2 events. Take for example the screenshot here...
It may not look it, due to how bunched together they are, but this is approximately 100 Ray Bit enemies. All functioning at once. All at a full frame rate. Of course, as I've said, it varies from PC to PC so some people may only be able to get 50 or so enemies, but that's still quite an impressive number in my opinion.
All of this is still a work in progress, so of course, some things are susceptible to change. I still haven't included it into the X Editor yet either, so there isn't a GUI for any of this yet. Although, besides the animations, everything will be done by programming scripts, so their isn't much need for a full-on GUI. Speaking of, here is an example snippet of the code used for the Ray Bit enemies (it doesn't include their shooting action, just jumping).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | function Main(obj) -- Increment delay between each action. if obj.currentAnim==0 then obj.delay = obj.delay + 1 end if (obj.doAction==0 and obj.delay >= 40) then -- Set action to jump and change animation obj.doAction = 1 if (obj.doAction<4) then obj.changeAnim(1) end -- When next animation occurs, run Action_Hop function. if(obj.currentAnim==2 and obj.onAnimStart) then Action_Hop(obj) end -- Execute landing action if in mid-air. if (obj.collision.floor() and obj.y_vel > 0) then Action_Land(obj) end end function Action_Hop(obj) obj.y_vel = -5 obj.x_vel = 2 * obj.dir end function Action_Land(obj) obj.changeAnim(3) obj.doAction = 0 obj.delay = 0 obj.y_vel = 0 obj.x_vel = 0 end |
Hopefully that's not too overwhelming. If you have any questions, feel free to post them below as always. When this system is fully complete, I'll go into more detail the process of creating an enemy from scratch, kind of like a tutorial.
Be sure to subscribe to this blog if you want to be notified when new info is posted. Until next time guys.