Edit: I solved this problem, check the devshed forum (linked below) for solution.
I am trying to write a crude game engine inspired by spritesheet animations but I'm having a problem.
I need help on a hit test.. I wrote earlier a function that works WONDERFULLY with hitting squares and telling you which side the square is being hit from and returns a value so the object could bounce away. And also wrote one with circles. (See http://omz-software.com/pythonista/forums/discussion/138/crude-hittest#Item_4) But I'm having a hell of a time with rectangles!
I wrote a thread on python forums over at devshed: http://forums.devshed.com/python-programming-11/rectangle-hit-test-937964.html
Aside from what I said in that thread, here is the project I'm working on: https://gist.github.com/278158f70872b37f70df
Please note the project is VERY messy and has some stuff I plan on deleting. It's also using a prototype sprite walk function made on these forums (http://omz-software.com/pythonista/forums/discussion/77/spritesheet-animations) But if you want to see and test my hit test function it's a good place to start. The hit test itself is on lines 77-106 and the reaction to the hittest (by the green box) is on lines 278-285 if you want to mess around.
What I need is help figuring out how to make a hit test work on two rectangular shaped objects. I want the function to return a value, between 1 and 4, representing which side object1 is being hit. It is deceptively simple and I'm sure a skilled programmer or mathematician will see the obvious solution while I'm just pounding my head against a table..
Thanks for any help!