little help
This is the last time I am going to remind you to [color=#ff0000][size=8]PROVIDE SOME INFORMATION.
Look at not just this thread but any other you have started. You state you have a problem, then 2 people ask you to post extra information, and you do but it is not enough so you get more requests for information before you finally post something useful.
Why does it take 6 posts for you but only 1 for everyone else? Why can’t you ask proper questions? Why!?
Here is a very basic and easy-to-follow formula for posting a question/asking for help:
From now on, if you can’t run these 3 simple steps through your head when posting, I will ignore your posts.
I am tired of this:
You: I have a problem.
Us: Provide more information.
You: Here is 30% of the information you requested.
Us: Provide more information.
You: Here is another 30% of the information you requested.
Us: Provide more information.
You: Here is the full information.
[Repeat]
L. Spiro
Look at not just this thread but any other you have started. You state you have a problem, then 2 people ask you to post extra information, and you do but it is not enough so you get more requests for information before you finally post something useful.
Why does it take 6 posts for you but only 1 for everyone else? Why can’t you ask proper questions? Why!?
Here is a very basic and easy-to-follow formula for posting a question/asking for help:
- State the goal.
- State the problem and/or errors.
- Provide relevant code if there is any (using the proper CODE tags).
From now on, if you can’t run these 3 simple steps through your head when posting, I will ignore your posts.
I am tired of this:
You: I have a problem.
Us: Provide more information.
You: Here is 30% of the information you requested.
Us: Provide more information.
You: Here is another 30% of the information you requested.
Us: Provide more information.
You: Here is the full information.
[Repeat]
L. Spiro
sorry spiro, here is the code I am still working on.
1) I want to the ball to collide with the brick and turn off the brick.
2) The ball only bounces off the screen walls.
3) The code is above.
void drawScene() {
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
for ( int I = 0; I < ENUM_TOTAL_BLOCKS; ++I ) {
if ( g_bBlock.m_bActive ) {
glBegin(GL_QUADS);
glTexCoord2f(-1.0f, 0.0f);
glVertex3f(g_bBlock.m_fX, 4.0f, 0.0f);
glTexCoord2f(-1.0f, 1.0f);
glVertex3f(g_bBlock.m_fX+2.0f, 4.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(g_bBlock.m_fX+2.0f, 3.5f, 0.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(g_bBlock.m_fX, 3.5f, 0.0f);
glEnd();
}
}
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,_textureId_four);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
for(float i=-5.0f;i<=3.0f;i+=2.0f)
{
//draw bricks
glBegin(GL_QUADS);
glTexCoord2f(-1.0f, 0.0f);
glVertex3f(i, 5.0f, 0.0f);
glTexCoord2f(-1.0f, 1.0f);
glVertex3f(i+2.0f, 5.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(i+2.0f, 4.5f, 0.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(i, 4.5f, 0.0f);
glEnd();
}
glDisable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,_textureId_three);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
for(float i=-5.0f;i<=3.0f;i+=2.0f)
{
//draw bricks
glBegin(GL_QUADS);
glTexCoord2f(-1.0f, 0.0f);
glVertex3f(i, 4.5f, 0.0f);
glTexCoord2f(-1.0f, 1.0f);
glVertex3f(i+2.0f, 4.5f, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(i+2.0f, 4.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(i, 4.0f, 0.0f);
glEnd();
}
glDisable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,_textureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
for(float i=-5.0f;i<=3.0f;i+=2.0f)
{
//draw bricks
glBegin(GL_QUADS);
glTexCoord2f(-1.0f, 0.0f);
glVertex3f(i, 4.0f, 0.0f);
glTexCoord2f(-1.0f, 1.0f);
glVertex3f(i+2.0f, 4.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(i+2.0f, 3.5f, 0.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(i, 3.5f, 0.0f);
glEnd();
}
glDisable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,_textureId_two);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
//draw paddle
glBegin(GL_QUADS);
glTexCoord2f(-1.0f, 0.0f);
glVertex3f(-1.0f+j, -4.5f, 0.0f);
glTexCoord2f(-1.0f, 1.0f);
glVertex3f(1.0f+j, -4.5f, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(1.0f+j, -5.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-1.0f+j, -5.0f, 0.0f);
glEnd();
glDisable(GL_TEXTURE_2D);
//draw ball
glColor3f(1.0f,1.0f,1.0f);
glRectf(x,y,x+rsize,y-rsize);
glutSwapBuffers();
}
1) I want to the ball to collide with the brick and turn off the brick.
2) The ball only bounces off the screen walls.
3) The code is above.
Why are you doing “for(float i=-5.0f;i<=3.0f;i+=2.0f)”?
The only code that should be drawing the bricks is the first “for ( int I = 0; I < ENUM_TOTAL_BLOCKS; ++I ) {”.
That was the whole point of that loop. Draw bricks if they are active. Nothing else should be drawing bricks.
L. Spiro
The only code that should be drawing the bricks is the first “for ( int I = 0; I < ENUM_TOTAL_BLOCKS; ++I ) {”.
That was the whole point of that loop. Draw bricks if they are active. Nothing else should be drawing bricks.
L. Spiro
I am doing the for loop to draw the bricks across the top of the screen. I am sorry for being kind of dense. I just don't understand how to get the collision detection to work.
It means that if you remove “for ( int I = 0; I < ENUM_TOTAL_BLOCKS; ++I ) {” then none of the collidable bricks are drawn?
Then the problem is not in the graphics code. You will need to post your collision-detection code.
L. Spiro
Then the problem is not in the graphics code. You will need to post your collision-detection code.
L. Spiro
void Timer(int value)
{
if(x > windowWidth)
{
xstep = -xstep;
}
if( x < -windowWidth)
{
xstep=-xstep;
}
if(y > windowHeight)
{
ystep=-ystep;
}
if(y < -windowHeight)
{
ystep=-ystep;
}
x += xstep;
y += ystep*0.75f;
paddle_collision();
glutPostRedisplay();
glutTimerFunc(10,Timer,1);
}
here is my collision detection code
I see no collision code there at all.
…
L. Spiro
…
Us: Provide more information.
You: Here is 30% of the information you requested.
Us: Provide more information.
…
L. Spiro
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement