And by "practical way" I mean in such a way that it may not hinder the game's speed.
I'm programming an RPG, and as many of you know, they're FULL of events:
you walk into a new room where an event triggers
some conversation happens to develop the story between the chars and npcs
but then when you reenter that room nothing happens.
I coded my game so that every time the map changes (let's say it goes to map 6) it checks in the class EventReg.hx the Array of Bool if the value (in 6 in this case) is true and it is copied into the variable eventAvailable in PlayState.hx.
Then in the update function it runs the event according to the map number, but I feel that this approach would require a hell lot of code cramped in PlayState.hx in form of a switch (taking the value of the current map as reference).
Does anyone know of some open-source RPG, examples or tutorials that deal with this? TIA!
Example:
//Event Helper
private var eventAvailable:Bool;
private var currentMap:Int = MapReg.currentMap;
override public function create():Void
{
//Checks if there's an even in the current map.
eventAvailable = EventReg.isEvent[currentMap];
if (eventAvailable)
setupEvent();
}
private function setupEvent():Void
{
switch(currentMap)
{
case 0: //code
case 1: //code
}
}