Status Update (October 23)

Worked on porting the infamous panda demo to use the new event classes and handler system. I'm also cleaning it up and doing some reorganization and documentation of it — about time, too! I don't think that demo has even seen a proper cleanup in 3 years.

I also made a few changes to the API as I was working on the demo:

First, I renamed AllTrigger to AndTrigger and AnyTrigger to OrTrigger. "And" and "Or" just feel more natural to me. I actually wrote AndTrigger instinctively while coding the demo, before I remembered that it wasn't called that. "And" and "Or" are more familiar logical concepts, too: "This trigger and that trigger match the event", or "This trigger or that trigger matches the event." So, they should be memorable.

Second, HasEventHandler no longer needs to be initialized; that means, no need for super() in your #initialize method. Before I made the change, I ran into a mysterious "nil has no method" error while coding the demo, because I forgot to initialize it. Well, having to explicitly initialize it is just silly and leads to errors like I myself ran into. So, now it initializes itself the first time it needs to.

The mechanism for that is simple. For example:

def handle( event )
  @event_handler.handle( event )
rescue NoMethodError
  @event_handler = EventHandler.new() if @event_handler.nil?
  retry
end

Anyway, I'm still planning to release the new version tomorrow. There will also be another important announcement tomorrow.


Comments

ippa submitted a comment on #

Great work jac. And about super(), I’ve ran into the super() problem just about every time I subclass Sprite and every time it was very confusing before I found it.

John Croisant submitted a comment on #

@ippa: Yeah, I dislike how I did that with sprites, it’s annoying. Maybe a future version will fix that.

Have something interesting to add to the discussion? Email your thoughtful comments to comments@rubygame.org.