Lacewing is/will be an open source game engine or to be more precise, a game development concept, since it doesn't introduce any game engine specific stuff by itself and builds upon another frameworks.
So, what does it exactly do? Well, it creates a Component Base Entity System (just google it for more on this topic).
In my case a CBE System introduces one entity type and you can attach various components to it. The entity does nothing but calling callback functions of its components when needed, and components do the actual job, so if you wan't to have a flying, ice-breathing fire-dragon with a laser eye (maybe a bit overkill though) in your game, then just pick an entity, write appropriate components (e.g. the laser eye component) and attach them all to the entity, and voila! you've now got a that strange creature in your game. Needless to say, this is much easier and faster then implementing a separate dragon class. This brings much flexibility and reusability to your projects.
My version of this system is implemented in Lua and is also somehow inspired by unity3d (which is an awesome 3d game engine). I currently plan to make a level editor that makes use of the system and generates lua code for levels.
To show how easy everything works, consider following situation: There is a ball entity with a rigid body component attached to it. We want the entity to print out "collision!" when the ball hits something in the game world.
Well, the naive approach would be, to modify the rigid body component, to complete this task, however the results will be probably kind of annoying because each owner of the rigid body component will print "collision!" and not just the ball. So, the better approach would be the creation of a custom component. To do so, we create a .lua file. Lets call it "debug_collision.lua". Now, all we have to do is to put following code into the file:
function onCollisionEnter()
print "collision!"
end
And that's it, more code isn't required. Then we just drop the component onto the ball entity in the editor to attach it to the entity and if we start the game we will see "collision!" - in the console window, each time the ball hits some other object.
Keine Kommentare:
Kommentar veröffentlichen