Rubygame 3: Day 44

Several changes today. Collision events now carry references to the shapes that collided with each other, not the sprites. It's trivial to find out the sprite when given the shape (my_shape.sprite), but very difficult to go the other way. Utility wins out.

But by far the more exciting development is the addition of the contain_vect? method to Chipmunk's Circle and Segment classes (Poly as well, as soon as I get it working). As you could guess, this method returns true if the given vector point is inside (or touching) the shape. In other words, it's a point collision test.

So why is that such a big deal? Because now it's possible to check if the user has clicked on a sprite! It's quite simple to use, too; simply create a MouseClickTrigger and pass the shape as the second argument, "area" to its initialization. That will cause the trigger to only fire when the click hits the given shape.

To test this new feature out, I've updated the Panda Ball demo so that if you click on a ball, it will push the ball away from the mouse cursor. It's simple, but fun! The demo is almost turning into a minigame, to see how many you can stack before they fall down (my high score is about 32).

P.S. I loathe Comcast. They gobbled up my old ISP, and are switching over the networks. Suddenly, last night, I was unable to post or view to this blog or the wiki, or to SSH to the server. The problem has continued for over 24 hours now, and I've done some tests. All traceroutes from an outside server to my home computer get lost after hopping through a Comcast server in Michigan; I'm assuming that my return packets when viewing or posting to this blog are being lost in the same way. I'm hoping it'll resolve itself soon; in the meantime, I'm using a proxy to post.


Comments

Have something interesting to say about this post? Email your thoughtful comments to comments@rubygame.org.