Hello,
I am having issues with the collision detection routines in dark gdk, it is not doing any kind of pixel perfect collision detection, or even close. No matter which one I use either collision or hit, if I have say some ball 2d sprites, and have them shot out of an arrow like bust a move, to the elevator at the top of the screen, well the images are square, with transparent portions, except for the round ball in the center, and as the arrow rotates so does the ball, so that it will move upward at the right angle, and here is the problem, it is colliding at the corner of the rectangle bitmap no matter which call I use, making the ball sit at different distances from the elevator at the top, instead of them all being snapped up tight to the elevator. So I tried to make a work around, by doing a grid snap, until I can work out the hex snap grid code, and just basically took the X & Y coords, and multiplied them *40 to get the grid offsets, since each sprite is 40x40 and then tried to use dbPasteSprite(BallID, snapx, snapy);
and it does NOTHING! Is this a result of using dbRotateSprite and dbMoveSprite first? If I hide the sprite first then paste it will this work, we really need a sprite erase, then we could use it with sprite paste for things like this.. Also, a mask based collision detection addon or something would be great, allowing for round object or disk collision detection instead of squares.. I am wondering if I will have to figure out how to move the sprites on my own in a loop using paste etc.. and write my own collision checking routine, at least this way I could also make the balls bounce off the walls by reversing the horizonal direction or multiply the X change by -1.
I am finding things that should be entirely simple to do, rather difficult in dark gdk... I got it to sorta work, but after moving at the correct angle until collision, then I rotated the balls to 0, then setup another loop to move them again until collision, so now they are lined up with the elevator, hmmm maybe this will work with the bouncing too, I could just multiply the angle of the sprite with -1 and for instance 45% becomes -45, nice ok, so that works.. but I fear this issue with the hex grid snapping if the balls are rotated a little will make the hex grid much harder to solve, since I will have to move until collide with ball, then rotate to 0 then move again, and then offset the coords into hex coords, and for this I will need to know how to get the paste to work properly...
Thanks for listening to my ramblings, I'm sorry for the long post, but I have been coding / trial and error all day on this.. and I am sooo close, but also drained, and very mentally and physically tired.. Thanks to anyone whom can help me out with some of these issues...
Please respond here so others can learn as well, but if you don't care shoot me an email also to: storm3@twlakes.net
has anyone wrote a good library of functions for collision detection, masks, and other? Also a hex / and square grid snap function library would be very good addition as well. Square is ez enough, but hex is a little more tricky..
;') Thanks again, Cheers! I am off to beddy bye now.. Ciao'
PS. I've included my main.cpp for you to take a look at it, beware it is ugly right now, since I had all the trial and error late tonight, and haven't patched it up / and fixed comments etc.. yet..
[PKE] Pain Killa Entertainment(tm) [PKE]
Pain Brings Reality...
[PKE] Pain Killa Entertainment(tm) [PKE]