Events mean you can now do this:-
on_something = function( )
{
print("Oh no! Something happened to " + .target.props["name"] );
}
ent = ent_create();
ent.events["on_something"] = on_something;
ent.props["name"] = "Billy";
trg = trg_create_entity_position_trigger( ent, vertex( 50, 60 ), "on_something" );
trg.activate();
When the entity reaches position 50,60 an event 'on_something' is fired for the entity we created and named as 'Billy'. If we set the trigger to 'never expiring' (or otherwise reactivate it) we can fire this event whenever this entity steps on 50,60 (bear in mind we also have area tests for circles, rectangles and more) - this makes it ideal for switches and various other game triggers :)
We can now use it to start defining various collision callbacks; so setting an "on_collided" callback will result in that being called whenever two entities collide:-
on_collided_player = function()
{
ent1 = .props["entity"];
print( ent1.props["name"] + " has collided with " + .target.props["name"] );
};
Neat, huh?
I really need to start crafting the tilemap stuff so I can throw out a simple pacman clone to test all the things we have so far.
The Future
So far this GMGX engine experiment is turning out to be something special. What we have right now is a simple 2d engine that runs entirely on scripts written in a simple yet powerful language. My intention is to now bolster the graphical ability of this engine, providing tile mapping, parallax scrolling and other goodies so that it can be used in 'real 2d games'...
I'm definitely thinking that this sort of scripting should feature in some future work of mine yet. Don't know what it is, but it'll have scripting.
Can you combine event triggers together? Say...
Also, probably related to the same thing, but can you define a sequence of events that lead up to a trigger.
For example, in order for event Z to be raised they must have completed Objective A, Objective B and Objective C. However those objectives may not have happened at the same time, and might have had other things occur in-between...
Keep up the good work!
Jack