Hello!
I'm currently writing my first proper 2D game (integrated in a custom built engine) using C++ and SDL. I have a question about how to script certain events though. The engine itself is state based.
My game state is made up like this:
class PlayState : State
{
private:
Camera* camera;
Player* player;
Map* map;
}
In turn, the map is primarily a manager of tiles (Tile*** tiles; which get initiated in accordance with the map file).
Now to the problem! When I step on, let's say tile [25][100], I would like the game to change to a certain state (declared either in the map file or in some script). What's the best way to do this?
PlayState holds a pointer to the engine, and it would be possible for it to pass a ChangeStateEvent to it, but then I have clutter the map file with both info about what event to send and possibly a parameter to the same (i.e. ChangeStateEvent, Cutcene(cutscene nr 725)). Instead I was thinking about having some kind of script trigger every time I step onto a new tile and check if the tile is a trigger tile. If so, the script will handle everything necessary to view the cutscene.
So, what do you suggest? Is scripting the way to go, or am I completely off?
PS
I own all of the code myself (and the game art is all Creative Commons licensed), and wouldn't mind sharing it if necessary (it'll most likely cause a headache for the more advanced game devs though).






