View Full Version : tell me some more about collision detection

Sunder Sha
09-15-2009, 11:46 AM
i use this openGl forum first time.hope u all are help me here.i read all algorithms about collision detection but could not understand how to apply in my game.my game is gold finder.i load a image and and that move and collide with a gold piece then score incress.this is my theme.plz help me how to apply collision detection in this.can i give you my code??

Sunder Sha
09-15-2009, 11:47 AM
thnx in advance.....

09-16-2009, 04:10 AM
in your case the simplest one would be to check the distance between your avatar and each pice of gold, if it's close enough you count it as a hit.

Sunder Sha
09-16-2009, 04:51 AM
thnx 4 reply my question.i made a class of gold and pass the position where it place on the game screen.and moving image is continously move through arrow keys up,down,left or right...then how i find distance between them??this is basic problem .i know.but i m not good in c++ or programming.give idea of thz.i know how to find distance between two points in maths but not at there.thnx if you solve my this problem.

09-16-2009, 07:33 AM
it's exactly the same, though i suspect that this is not your main problem, that would be trying to make a game without a simple scenegraph, so simply put this is what you should be doing.

1. the game should run as a simulation
2. this simulation has objects like gold, enemies, players and cameras with properties such as possition, direction, speed, state and so on.
3. you change various states(like up-speed if your holding the up key) in it and then evaluate it (ie. making everything move based on these new states).
4. you then use these coordinates to render everything

then when this is done you can just use this
sqrt((a[0]*a[0]) + (a[1]*a[1]) + (a[2]*a[2]))
to get the distance

Sunder Sha
09-16-2009, 11:42 AM
thnx 4 your coperate..
i'll try this.in my game camera is not enable till now.now i'll do.and think in a such way.then tell you about my progress.ok

09-16-2009, 06:05 PM
This is not an OpenGL question. You could perhaps post this tyope of question to our math & algorithms forum or a more general game programming forum like those on gamedev.net.

Please restrict posts here to the OpenGL API and topics more directly related.