So i'm working on a 2D top-down space-shooter, and i've gotten to the part where all i need to do is integrate the logic for enemy movement and weapon upgrades etc.
The way i was thinking about doing it, is to have a Lua script for each different kind of enemy defining how they move and how they shoot and so on, and then just calling that script everytime i update my entities.
The thing is i might have alot of entities moving about on the screen, and the update happens once every frame for every entity, which in turn happens (hopefully) 60 times a second.
My concern is that the Lua-code will slow my main gameloop down to a complete halt, i'm thinking Lua calls are fairly expensive to do a few thousand times a second. Is this something to be concerned about? I'm planning to use Luabind to export my C++ objects to the Lua scripts, but i don't want to implement it all just to find out i'm never going to get anywhere near an acceptable framerate.
The other way i was thinking of doing it is to forget about Lua and then just use XML to define the behaviour of the different enemies and weapons and so on. At the moment i have a single config.xml file, which i load into a boost :: property_tree at the beginning, and then pass around by reference to each entity upon creation. This config file has everything from screen resolution to the width of the player ship and the clipping regions for the enemyships and so on. I was thinking about just hardcoding the different enemy behaviours and weapon types, and then just defining which enemies get which weapons and behaviours in my config.xml.
Then if i ever wanted to define a new type of enemy for a new level, i could just combine the different components that i've got defined in C++, within the XML file, without ever having to recompile. This approach will be easier to implement, but less flexible, and i'm afraid the code will be a mess.