The colision detection function runs inside the game loop that controls movement, map transitions, keyboard inputs and other things I don´t remember right now.
This function receives as parameter the return of another function that check wich is the current map (so that only that specific map stuff is displayed and only the colisions valid for that map are verified)
function colisionDetection(var id_map)
{
var identifier = id_map
if (identifier == 1)
{
if (character is at a certain position && npc is visible)
{
if (key_space)
{
dialogue_pan.flags = VISIBLE;
while(character is at a certain position && npc is visible)
{
drawText(some parameters);
wait(-1);
}
}
dialogue_pan.flags = 0;
}
... other situations within this map...
}
else if (identifier == X)
{...}
... other maps situations
}
This is an example wich I can remember right now... but there are other worst cases...