Bitmap Collision

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
Ti22
In need of some credit
In need of some credit
Posts: 7
Joined: Fri Apr 01, 2005 3:00 pm

Bitmap Collision

Post by Ti22 » Fri Apr 08, 2005 9:18 pm

http://www.ti-x.net/images/collision%20prob.jpg

hey guys, i've got htis problem i've been workin on for the whole of today without success

basically the bitmap is not colliding where it is, its colliding at its origin (the point where its created) and its really getting annoying.

Is there anything I can do to get the bitmap to actually be the actual size of the bitmap itself rather than just 1 pixel which is the size of the origin where the bitmap is being created.

Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Post by Tyler » Sat Apr 09, 2005 12:08 am

Hey Ti22,

Am I understanding you correctly that you want to tell when one of the person images is dragged on top of the other person image?

-Tyler

Ti22
In need of some credit
In need of some credit
Posts: 7
Joined: Fri Apr 01, 2005 3:00 pm

Post by Ti22 » Sat Apr 09, 2005 7:50 pm

no whats happening is that the collision isn't being detected at the right place, see the black bar? the bitmap is going through the black bar, when i press the move button the bitmap moves through the black bar and stops at the top of the bitmap when the first pixel of the bitmap collides with the black bar it stops,

this is the point where the bitmap is created, I want the WHOLE bitmap image to collide not just its origin.

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Sun Apr 10, 2005 7:24 am

I have not looked into bitmap collision, but isn't there a way to take the length into account of the bitmap??? If you know it is the top point, simply adding the height of the bitmap and re-checking the x pos of the bar should work ok.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Post by Tyler » Mon Apr 11, 2005 4:05 pm

Ti22 wrote: this is the point where the bitmap is created, I want the WHOLE bitmap image to collide not just its origin.
Ahh ok. When I had this problem before, I had to resolve it the nasty (but effective way). I couldn't use built-in event handling because, like you experienced, you run into these strange problems.

What I did was create a secondary structure (linked list, or wxArray variant) which held "area" classes (containing simply x, y, width, height) of all the bitmaps being painted on the screen. The main window intercepted mouse event coordinates/types, and passed them to a controller, which queried my list of objects.

Note: Here's a nifty trick that took me a minute to figure out. When you paint your scene, you can paint the objects from the tail of your list to the head. When you run mouse events against the objects, run from the head to the tail. This way, objects are painted "on top" of one another correctly, and the events are "sent down" the chain of objects correctly.

Post Reply