Thursday, July 5, 2012

EPI #12.5: Events, part 2

Okay!  I implemented the changes I mentioned last post:
  • EPIEventListener
    • event - The exact event the listener listens for.
    • verb - the category of action to take
    • direct object(s), depending on the verb
    • prepositional phrase(s), depending on the verb
Now, to see if it needs to interpret an EPIEventListener, the EPIEventHandler compares the EPIEvent it's handling to the EPIEventListener.event in question.  If they're the same, it calls eval_listener() on that EPIEventListener.  This also means that I needed to override EPIEvent.__eq__().  I don't care that the EPIEvent instances are identical, only that they carry the exact same data.  This will probably come back to haunt me later when I implement new event types and find out that their listeners don't work because I've implemented EPIEvent.__eq__() wrong.

So, in order to test my event system, I added a listener to my test map:

<listener type='move' x='0' y='1'>CHANGE_MAP TO 11 2 IN ./content/test/zone_01/map_02.xml</listener>

I also added a new map, ./content/test/zone_01/map_02.xml, which also has a listener:

<listener type='move' x='11' y='2'>CHANGE_MAP TO 0 1 IN ./content/test/zone_01/map_01.xml</listener>

These two listeners allow the player to move back and forth between maps as he pleases.  So, if we position Kenfold at (1, 1) on map_01:


And move him one step west to (0, 1) on map_01...


He teleports to (11, 2) on map_02!  Cool stuff!  You'll have to take my word for it, but when he moves away and then moves back to (11, 2), he'll teleport back to (0, 1) on map_01.  He doesn't immediately enter a teleporting loop because the CHANGE_MAP action doesn't itself emit a move event.  Move events are only caused by movement as a result of player keystrokes.

This example might seem trivial, but it's actually all the infrastructure I need to design the EPI's entire map system.

Side note:  you may have noticed that these maps don't appear to be rectangles, and you may be confused because I said in my post about maps that they were required to be rectangular.  Well, actually, these maps are rectangles.  I lined the necessary edges with impassable transparent tiles.  This lets me emphasize which tiles will take the player to a new area.

One other thing:  I've mentioned before that the event system is the heart and soul of compelling scenarios.  The more events and listener verbs I implement, the more creative designers can be with their scenarios.  More creativity leads to more interesting stuff, which leads to more fun.  This is where you, dear readers, come in.  I can't think of all the different events or verbs designers are going to want to be able to work with.  What I'm trying to say is that your ideas are welcome.  Think about what you, as a designer, would like to be able to manipulate, and what events you, as a designer would like to be able to work with.  Let me know in the comments!

No comments:

Post a Comment