Sign in to follow this  
Himura-San

Game Events and Tasks...

Recommended Posts

Hi, I´m pretty new to game programming and this is my first "professional" game. I´m having problems to peform a couple of taks when an event is triggered. There are some invisible boxes displaced around the world in the game. When the player collides with them an event is triggered, and in some events I like to make NPC´s do some tasks of kind: "NPC 'A' Go to a place 'X' and talk to NPC 'B'. Then NPC 'B' go to the player and give something to him." The problem is that I can´t find a smart way to do that kind of tasks that of course will happen in a lot of frames. This is the member function of the class that is listening to game events:
void GameEvent::handleEvent( muint eventID )
{
     switch( eventID )
     {
         case ARRIVED_AT_PLACE_X:
               // do a lot of stuff
         ...
     }
}


In most of cases I want to get control over the player while the event is happening. It means put a lock in his input ( and of course unlock it in the end ) Make some tasks: 1) NPC 'A' move from the point 'u' to 'v' 2) wait 't' seconds 3) NPC 'B' move from point 'p' to 's' 4) give item 'i' to player I know how to do all these task separately ( lock the input etc. ) How could I put it all together? Should I break down these tasks in move events? Could give em some tips and/or direct me to some kind of article/tutorial on that? Thanks in Advance Felipe.

Share this post


Link to post
Share on other sites
Have an action queue onto which you push all the actions you want to be done (in order). When you start an action, pop it from the queue; when the current action is complete, take the next one and start that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this