ippa / chingu

OpenGL accelerated 2D game framework for Ruby
http://ippa.se/chingu
GNU Lesser General Public License v2.1
309 stars 66 forks source link

Changing state directly via input does nothing with indirect inheritance from GameState (0.7.6.6) #9

Closed bil-bas closed 14 years ago

bil-bas commented 14 years ago

The input system checks to see if a class given is directly inheriting from GameState, so if you have

self.input = { :space => StartGame }

where:

StartGame < MyGameState < Chingu::GameState

then StartGame won't get recognised as a GameState (Not a priority for me since you can just use a very simple #new to get around the issue; just something I noticed). InputDispatcher.rb line 96, anyway.

EDIT: Could also raise an exception if they pass the wrong value, rather than just ignoring it.

erisdev commented 14 years ago

I've pushed a commit to my fork that fixes this problem and also allows String and Method objects as actions. I'll see if ippa likes what I've done.

ippa commented 14 years ago

merged, tnx eris.

... hm, in a perfect world there would be some tests too heh :). Chingu lacks a lot of tests as it is now though.

erisdev commented 14 years ago

Yessir. I'm not really sure how to write a decent automated test for something that requires user interaction. Hmmm.

bil-bas commented 14 years ago

@erisdiscord: Yeah, you thought about it even more than I did, but...erm, I was too lazy to fork. Thanks! You are quite right that the incorrect parameters should ideally raise an error when input is set, not when the input is being handled. Hadn't considered that :$

@ippa: Tests would be nice, though I can imagine they would be really messy in this sort of app.