• Advertisement
Sign in to follow this  

Trigger System Design

This topic is 4226 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, I am designing my Entity and Trigger system at the moment. So far I have this (I'll show you in pseudo code). First when I load a map, I will create definitions for entities as such: // for constructing an entity object <entity> <name> "lamp" </name> <states> <idle> <dir> <north> // for constructing Animation object <image> "/data/entities/images/north.jpg"</image> <frametime> 0.10 </frametime> </north> </dir> </idle> <lite> <dir> <north> // for constructing Animation object <image> "/data/entities/images/north.jpg"</image> <frametime> 0.10 </frametime> </north> </dir> </lite> ... //various other states and such <states> // Run lua script <trigger> "/data/triggers/lamp.lua" </trigger> </entity> Now when I create my entity I build it off of the XML info. Here is my Base Entity: IEntity { GetID(); SetID(); Update( long ); Trigger(); SetTrigger( str filename); CollideWith( IEntity ); IsActive(); SetActive(bool); MoveTo( Vector2D ); GetBounds(); GetCurrentState(); GetStateMachine(); SetStateMachine( StateMachine ); } The real point of interest lies with the Trigger() methods. What do you guys think of this: IEntity::SetTrigger( string luascript ) { string trigger = luascript; } IEntity::Trigger() { Scripter.RunScript ( trigger ); } So for instance when I want to activate a trigger: if ( player lites Lamp ) Lamp.Trigger(); // will run the lua script What do you guys think of this?

Share this post


Link to post
Share on other sites
Advertisement
Maybe I worded this poorly, are there major flaws with this design? Is there a better alternative? Any sugguestions would be greatly appreciated.

BTW, This is for a 2D zelda like game.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement