why is my collision like this??
hello i''m just starting to learn opengl and 3d so i figured i would make a simple pong game just to get used to moving objects in 3d the way i''m doing it is i set up a 2d ortho viewing projection using gluOrtho2d(-90, 90, -90, 90) set it MatrixMode to GL_MODELVIEW and draw my paddles and ball around the origin using GL_QUADS
paddle 1 & 2 =
-5.0f, 20.0f,
-5.0f, -20.0f,
5.0f, -20.0f,
5.0, 20.0f
so the width is 10 and the height should be 40?
and the ball is draw with
-5.0f, 5.0f,
5.0f, -5.0f,
5.0f, -5.0f
5.0, 5.0f
so it should have a width and height of 10?
i then translte them into there places now on to that actual question when i got to do my collsion dection at the top of the screen this happens
i want to use this for the top of the screen
pad.height i''m hoping is 40 buy the way i set up the model
if( (pad.y + (pad.height / 2)) >= 90)
pad.y = (90 - (pad.height / 2));
but i have to use this
if((pad.y + 45) >= 90)
pad.y = (90 - 45);
now for at the bottom of the screen
if((pad.y - (pad.height / 2)) <= -90)
pad.y = (-90 + (pad.height / 2));
works fine so i''m wondering if anybody can tell me how come this happens?
sorry if i put to much info but i think its better having a bunch of usles stuff then not enough...thx for any help
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement