Archived

This topic is now archived and is closed to further replies.

dede

Game Events and Engine Code

Recommended Posts

My original Engine code is too tied up with the content and has a few major bugs, so I''m rebuilding it with "lessons learned". My goal will be to have the engine and logic as seperate as possible, using LUA as a scripting language and C++ for the game engine. I''m having a problem designing my engine. Where events should be placed? Lets say I have a door that opens after you defeat mini-boss X. How would I tell my engine to render that door, where would I put the logic of that door, and how can I save the information that the door is opened?n And finally, how can I make it so I can have infinite doors, if I choose to do so? If I can figure this example out, I can probably apply it to every event in my game. ~~~~~ "the best thing about betting on apathy is that even when you lose, you dont care." - nethead. Download and play Slime King I.

Share this post


Link to post
Share on other sites
make your engine capable of handling any number of door (and enemies, items, boxes, etc etc tec), and make it so these things can be created and manipulated by the scripting.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Some lesssons I''ve learned from creating an event driven engine.

Each object contains a data instance. A data instance is just a generic data container which can hold any arbitray type of data. Data elements are referenced using a key, in this case a string.

So in your example:

Door object : resided within the part of the game i call the model. The model, is the simulation/logical core of the game. It holds data and manages the entites in the game, does collision detection, and save/load of the game etc..

So within the model, the entity Door resides. And within the entity Door is a catch all data container. Another object, trigger, or script can insert into the Door data container a value like "door_unlocked" "true". Another object,trigger,or script can then query for that data element using the "door unlocked" key. It that matches its expected value "true" then it does its thing( like moving a door object to the open position ).

So where the events come in? Each Entity has a table of event_handlers which listen to events from that entity. These events can be anything. For instnace one event could be Data Changed Event. When that event is sent through the event handlers on response to a change of data, the approriate handler can then query for the "door unlocked" value and see if its in the appropriate state. That way no unnessecay data polling is used to drive the states of the entity or its event listeners.

This is the basis for an event driven design im using and it seems to work well.

Good Luck.

-ddn

Share this post


Link to post
Share on other sites
Thanks ccn & Krez.

I think I was trying to put too much in the script, and not enough in the actual game code. Thanks

~~~~~
"the best thing about betting on apathy is that even when you lose, you dont care." - nethead.
Download and play Slime King I.

Share this post


Link to post
Share on other sites