Hi guys,
I''m currently working on a 2D Tile Based RPG. So far, everything is great. But now I''ve come to a problem of moving different objects at any time in a very easy way. But moving objects is not the only thing i want to do . Things like, drawing text for 5 seconds or doing other things for a certain time.
Those activites all need more than 1 frame. The silliest variant would be like that:
BOOL bMovePlayerRight=TRUE;
if(bMovePlayerRight)
{
Player.MovePlayerRight();
}
That''s too static and nonflexible.
So I tought about an event handler class and an event class.
#define EVENT_MOVE_PLAYER_RIGHT 1
#define EVENT_DRAW_TEXT 2
class Event
{
private:
VOID *vObject; // Pointer to the object, we are going to draw the text with e.g.
VOID *vData; // Pointer to
int EventID; // Tell the class which event
double EventDelay;
double EventDuration;
public:
Init(VOID *vObject,VOID *vData, int EventID, double EventDelay, double EventDuration);
ExecuteEvent(); // Checks, whether it''s time (EventStartTime + EventDelay) to execute the event
};
class EventHandler
{
private:
vector<Event> EventList;
public:
AddEvent(VOID *vObject,VOID *vData, int EventID, double EventDelay, double EventDuration);
ExecuteEvents(); // loops through the events and executes them
};
I''m unsure about that, so I want to ask you guys about that idea. I don''t know how it is handled in professional designed computer games. Maybe you can tell me something about it.
Thanks