Collision detection - crosshair meets target image
BlitzMax Forums/BlitzMax Beginners Area/Collision detection - crosshair meets target image
| ||
Hello! I am in the process of making my first game. It's basically a target shooter whereby there are a number of bubble sprites moving around in random directions, and you have to aim shoot them using the mouse. Once this happens they disappear. I have been able to hide mouse pointer and in its place replaced the pointer with a crosshair. I know more or less how basic collision detection works.. for eg - imagescollide. I have read on this, and this would be no problem for me. However, I am aware that when image meets another, the collision would occur. But in my game I just want only the centre of the crosshair to result in a collision when it meets the bubble image. Therefore I am a bit perplexed in how I can disregard the collision detection of the outside of the crosshair image. Thanks. Nik |
| ||
Dead easy. Use your normal crosshair image when drawing. Use this code to create a proxy image to use for collisions. Method makeMouseCollider:tImage() Local px:TPixmap = CreatePixmap(2, 2, PF_BGRA8888) px.ClearPixels($FFFFFFFF) Return LoadImage(px) End Method |
| ||
Good idea, but why make it a method? You can make it a function with a global so it only creates it the first call and then returns the same iamge. |
| ||
Good idea, but why make it a method Because its part of my mousepointer class which is where the resulting image resides, as well as doing lots of other wonderful mouse-related things.Picky picky picky. :/ |
| ||
You could still make it a function within that type but oh well. |