collosion detection
Can someone please help me!!!!
I am writing a game call smash, The game is a cross between Air Hockey and Breakout. Just like air hockey I want the mouse I want the mouse to hit the ball. I''ve tried different source codes, but still no joy. So please help me.
Well, it would help if you were a little more specific...
------------------------------
#pragma twice
------------------------------
#pragma twice
quote:
I want the mouse I want the mouse to hit the ball. I've tried different source codes, but still no joy. So please help me.
![](tongue.gif)
Matthew Fitzgerald (Maketty),
Knightvision Games
Edited by - maketty on October 5, 2000 3:19:26 PM
Maketty (Matthew FitzGerald) The meaning of Life part 5:Live organ transplants...
I would never start a post like this. This way you'' ve got a 99.9% chance that no one answers. And the 00.01% will probably play jokes on you ...
Because of the fact that I answered I am one of the 00.01%. But I can''t remember of any joke right now, sorry!
Next time you''ll get your joke, just make your headline 500 billion pixel big, promised!
Because of the fact that I answered I am one of the 00.01%. But I can''t remember of any joke right now, sorry!
Next time you''ll get your joke, just make your headline 500 billion pixel big, promised!
Ok, here are a few questions for you:
1.) Are you already having your paddle or ''avatar'' move(track) with the mouse.
2.) Is this game 2d or 3d or somewhere in between?
If it is 2d and you already have the paddle track the mouse you just need to have the ''ball'' or whatever store its own position and do the same with your paddle. More than likely the position of the two objects will actually only be the point at there top left corner. From that point you need to make a bounding rectangle to check for a collision.
Take the x position point and store it in a variable that represents the left edge of the object. Do the same for the y position point(it represents the top. Now add the width of the object to the original point and store it in a variable for the right side. Find the bottom end of the object by adding the height and storing it like you have stored all the other variables.
You now have a bounding rectangle. If all objects have this same scheme, it becaomes trivial to check to see if they have collided. i.e.
if (player.top > missle.bottom)
collision = false;
etc etc.....
This is a poor way to check for a collision, but it should help you get some basics in your game. You can refine it later. There are lots of papers on the net on collision detection, you should try finding some. There are even some on this site. If I misunderstood your question be a little more clear and re post your q. If I have time i''ll try and answer it. Good luck with your game....
1.) Are you already having your paddle or ''avatar'' move(track) with the mouse.
2.) Is this game 2d or 3d or somewhere in between?
If it is 2d and you already have the paddle track the mouse you just need to have the ''ball'' or whatever store its own position and do the same with your paddle. More than likely the position of the two objects will actually only be the point at there top left corner. From that point you need to make a bounding rectangle to check for a collision.
Take the x position point and store it in a variable that represents the left edge of the object. Do the same for the y position point(it represents the top. Now add the width of the object to the original point and store it in a variable for the right side. Find the bottom end of the object by adding the height and storing it like you have stored all the other variables.
You now have a bounding rectangle. If all objects have this same scheme, it becaomes trivial to check to see if they have collided. i.e.
if (player.top > missle.bottom)
collision = false;
etc etc.....
This is a poor way to check for a collision, but it should help you get some basics in your game. You can refine it later. There are lots of papers on the net on collision detection, you should try finding some. There are even some on this site. If I misunderstood your question be a little more clear and re post your q. If I have time i''ll try and answer it. Good luck with your game....
Mike BarelaMikeB@yaya.com
I wrote a game like that long ago.
Here is the source code:
http://photoneffect.com/download/demos/stanga.zip
(It won''t run without the libCON.dll though)
Here is the source code:
http://photoneffect.com/download/demos/stanga.zip
(It won''t run without the libCON.dll though)
? Shadrack never got back to the board about wot happened to his game ? .. hmm ..
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement