Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


little help


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
32 replies to this topic

#21 L. Spiro   Crossbones+   -  Reputation: 14215

Like
0Likes
Like

Posted 11 December 2012 - 11:59 PM

Of the block.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

Sponsor:

#22 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 16 December 2012 - 06:59 PM

well I have tried spiro's code but still can't get the collision detection to work.

#23 L. Spiro   Crossbones+   -  Reputation: 14215

Like
0Likes
Like

Posted 16 December 2012 - 07:19 PM

This is the last time I am going to remind you to 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:
  • 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
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#24 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 16 December 2012 - 07:29 PM

sorry spiro, here is the code I am still working on.
void drawScene() {

	glClear(GL_COLOR_BUFFER_BIT);
	
	glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

for ( int I = 0; I < ENUM_TOTAL_BLOCKS; ++I ) {
	 if ( g_bBlock[I].m_bActive ) {
		  glBegin(GL_QUADS);
		  glTexCoord2f(-1.0f, 0.0f);
		  glVertex3f(g_bBlock[I].m_fX, 4.0f, 0.0f);
		  glTexCoord2f(-1.0f, 1.0f);
		  glVertex3f(g_bBlock[I].m_fX+2.0f, 4.0f, 0.0f);
		  glTexCoord2f(0.0f, 1.0f);
		  glVertex3f(g_bBlock[I].m_fX+2.0f, 3.5f, 0.0f);
		  glTexCoord2f(0.0f, 0.0f);
		  glVertex3f(g_bBlock[I].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.

#25 L. Spiro   Crossbones+   -  Reputation: 14215

Like
0Likes
Like

Posted 16 December 2012 - 07:33 PM

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
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#26 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 16 December 2012 - 07:40 PM

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.

#27 L. Spiro   Crossbones+   -  Reputation: 14215

Like
0Likes
Like

Posted 16 December 2012 - 07:53 PM

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
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#28 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 16 December 2012 - 07:58 PM

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


#29 L. Spiro   Crossbones+   -  Reputation: 14215

Like
0Likes
Like

Posted 16 December 2012 - 08:01 PM

I see no collision code there at all.


Us: Provide more information.
You: Here is 30% of the information you requested.
Us: Provide more information.




L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#30 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 16 December 2012 - 08:11 PM

ok here is the collision detection I am using
	if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f)
	{
	bricks[3][5]=0;
	glColor3f(0.0f,0.0f,0.0f);
	glRectf(3.0f,4.0f,5.0f,3.5f);
	}
in this code the screen blinks on and off and on again.

#31 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 16 December 2012 - 09:25 PM

I have integrated spiros code into my code but it still does not do collision detection.
[source = c++]void drawScene() { glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); 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 ( int I = 0; I < ENUM_TOTAL_BLOCKS; ++I ) { if ( g_bBlock[I].m_bActive ) { glBegin(GL_QUADS); glTexCoord2f(-1.0f, 0.0f); glVertex3f(g_bBlock[I].m_fX, g_bBlock[I].m_fY, 0.0f); glTexCoord2f(-1.0f, 1.0f); glVertex3f(g_bBlock[I].m_fX+2.0f, g_bBlock[I].m_fY, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(g_bBlock[I].m_fX+2.0f, g_bBlock[I].m_fY-0.5f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(g_bBlock[I].m_fX, g_bBlock[I].m_fY-0.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 ( int I = 0; I < ENUM_TOTAL_BLOCKS; ++I ) { if ( g_bBlock[I].m_bActive ) { glBegin(GL_QUADS); glTexCoord2f(-1.0f, 0.0f); glVertex3f(g_bBlock[I].m_fX, g_bBlock[I].m_fY-0.5f, 0.0f); glTexCoord2f(-1.0f, 1.0f); glVertex3f(g_bBlock[I].m_fX+2.0f, g_bBlock[I].m_fY-0.5f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(g_bBlock[I].m_fX+2.0f, g_bBlock[I].m_fY-1.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(g_bBlock[I].m_fX, g_bBlock[I].m_fY-1.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 ( int I = 0; I < ENUM_TOTAL_BLOCKS; ++I ) { if ( g_bBlock[I].m_bActive ) { glBegin(GL_QUADS); glTexCoord2f(-1.0f, 0.0f); glVertex3f(g_bBlock[I].m_fX, g_bBlock[I].m_fY-1.0f, 0.0f); glTexCoord2f(-1.0f, 1.0f); glVertex3f(g_bBlock[I].m_fX+2.0f, g_bBlock[I].m_fY-1.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(g_bBlock[I].m_fX+2.0f, g_bBlock[I].m_fY-1.5f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(g_bBlock[I].m_fX, g_bBlock[I].m_fY-1.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); if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f) { bricks[3][5]=0; glColor3f(0.0f,0.0f,0.0f); glRectf(3.0f,4.0f,5.0f,3.5f); } //draw ball glColor3f(1.0f,1.0f,1.0f); glRectf(x,y,x+rsize,y-rsize); glutSwapBuffers();}[/source]
I made some adjustments to her code.

#32 L. Spiro   Crossbones+   -  Reputation: 14215

Like
0Likes
Like

Posted 16 December 2012 - 09:26 PM

Look at the rendering code.
if ( g_bBlock[I].m_bActive ) {

Do you not understand what this does?
Obviously if you want a brick to stop being drawn you have to set this to false.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#33 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 16 December 2012 - 09:39 PM

this is a Boolean array object if it is true then it draws a brick, if it is false then it does not draw a brick. my question is where do I put this code into.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS