Hello all, I have started a small "game" where you have a bitmap loaded as the background (it is a racing track like) and one small image loaded as the car. I am able to move the car but I want to do a collision test. How would I do this. The Bitmap only has two colours in use: gray as the street and the green as .. well as the green ;) Can I do this with MaskBlt to not allow the car to go into the masked part or is there another way. Ohh, there is to say that it uses GDI32.DLL for creating a region and so on, and that the background is BitBlt-ed, so there is no DirectX or so. Please help me anyone (or all?). It is not that I want you to do my work but to get the idea behind it. Short code snippets would be okay too. Stefan
Posted on 2001-01-14 10:53:00 by Stefan Krause
The only way I know to accurately test for collisions is to compare the x1, x2, y1, and y2 coordinates of the 'sprite' for every possible direction (up, down, left, and right). Obviously, if there's a collision to the upper left, both left or up would return true. If you need a more detailed collision (ie: the cars bounce off each other), you'll have to evaluate the degree of the collision (how much is overlapped), the relative speed, etc. However, since I'm not really a game writer, there's probably a better way to do it. :)
Posted on 2001-01-14 21:30:00 by Racso