Original Post
Okay, I''ve got as far as I''m going to wite some simple collision detections, but all they do is giving me pain in the ass. It first seemed simple enough, check if the ball position is lower than one of the sides, if it is then make the ball bounce. I wrote down all the if''s I thought might be usefull.. But there seems like there''s something crucial I''ve missed, the boat left and I wasn''t on the fucking boat! The problem is the following; If I only do a check with ONE of the sides active everythings seems to be just fine. But if I combine the oposite side of that all hell breaks loose. And if I dont include the oposite side, but use the side "Top" and "Left" the ball dosesn''t go in the direction it''s supposed to, instead it goes in the direction it came from in the first place and that''s not what I want! :/ So if anyone out there can hear me lying on my knees begging for help to sort out theese rather lousy if''s I''ve written please, pretty please with pink jelly on the top and sugar help me out. If I am totally lost on the concept with collision detection here do please tell me.
Thanks in advance..
And for those who wants to help me, here is the code I''ve written..
Kenneth Wilhelmsen
I''m working on a new 3d engine, this one is going to be opensource and all that.. But first I just want to show the executable off. Try out my Engine
Or just visit my site -------------------------- He who joyfully marches to music in rank and file has already earned my contempt. He has been given a large brain by mistake, since for him the spinal cord would fully suffice. This disgrace to civilization should be done away with at once. Heroism at command, senseless brutality, deplorable love-of-country stance, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action! It is my conviction that killing under the cloak of war is nothing but an act of murder
// Top
if((Ball->position.y - Ball->size) < (Paddle->position.y + Paddle->heigth))
{
if((Ball->position.x - Ball->size) < (Paddle->position.x + Paddle->width))
Ball->direction = -Ball->direction;
if((Ball->position.x + Ball->size) < (Paddle->position.x - Paddle->width))
Ball->direction = -Ball->direction;
}
// Bottom
if(( Ball->position.y + Ball->size) > (Paddle->position.y - Paddle->heigth))
{
if((Ball->position.x -Ball->size) < (Paddle->position.x + Paddle->width))
Ball->direction = -Ball->direction;
if((Ball->position.x + Ball->size) < (Paddle->position.x - Paddle->width))
Ball->direction = -Ball->direction;
}
// Right Side
if((Ball->position.x-Ball->size) < (Paddle->position.x+Paddle->width))
{
if((Ball->position.y-Ball->size) < (Paddle->position.y+Paddle->heigth))
Ball->direction = 180-Ball->direction;
if((Ball->position.y - Ball->size) < (Paddle->position.y - Paddle->heigth))
Ball->direction = 180-Ball->direction;
}
// Left Side
if((Ball->position.x + Ball->size) > (Paddle->position.x - Paddle->width))
{
if((Ball->position.y - Ball->size) < (Paddle->position.y + Paddle->heigth))
Ball->direction = 180-Ball->direction;
if((Ball->position.y - Ball->size) < (Paddle->position.y - Paddle->heigth))
Ball->direction = 180-Ball->direction;
}
// Rigth Side
if ((Ball->position.x+Ball->size) < (Paddle->position.x-Paddle->width))
{
if((Ball->position.y-Ball->size) < (Paddle->position.y+Paddle->heigth))Ball->direction= 180-Ball->direction;
if((Ball->position.y-Ball->size) < (Paddle->position.y-Paddle->heigth))
Ball->direction= 180-Ball->direction;
} Or just visit my site -------------------------- He who joyfully marches to music in rank and file has already earned my contempt. He has been given a large brain by mistake, since for him the spinal cord would fully suffice. This disgrace to civilization should be done away with at once. Heroism at command, senseless brutality, deplorable love-of-country stance, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action! It is my conviction that killing under the cloak of war is nothing but an act of murder