Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualslicer4ever

Posted 10 January 2013 - 02:14 PM

well I have decided to finish my breakout game using opengl and c++. I am still stuck on how to get the ball to bounce off the brick and get it to disappear. Then when it is removed I want the ball to pass through the space where the brick was. Please don't give me a lot of code. Also I am using magic numbers for now. Here is just a little bit of code.

if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f)
	{
	ystep = -ystep;
	g_bBlock[4].m_bActive_three=false;	
	}
well this code checks for a brick and then switches the ball's velocity and then turns off the brick. but it still bounces off where the brick was. I know I have asked this question before but I would like a fresh perspective. I am doing my best to finish this project.

simply check that the brick is still valid when your comparing to hit it, like so:

if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f && g_bBlock[4].m_bActive_three==true) { 
   ystep = -ystep; 
   g_bBlock[4].m_bActive_three=false; 
}

 

your naming convention is a bit odd(_three?)

 

edit: also, just to toss this out their for thought: what happens when your ball impacts the block along the side's rather than top or bottom?


#4slicer4ever

Posted 10 January 2013 - 01:32 AM

well I have decided to finish my breakout game using opengl and c++. I am still stuck on how to get the ball to bounce off the brick and get it to disappear. Then when it is removed I want the ball to pass through the space where the brick was. Please don't give me a lot of code. Also I am using magic numbers for now. Here is just a little bit of code.

if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f)
	{
	ystep = -ystep;
	g_bBlock[4].m_bActive_three=false;	
	}
well this code checks for a brick and then switches the ball's velocity and then turns off the brick. but it still bounces off where the brick was. I know I have asked this question before but I would like a fresh perspective. I am doing my best to finish this project.

 

if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f && g_bBlock[4].m_bActive_three==true) { 
   ystep = -ystep; 
   g_bBlock[4].m_bActive_three=false; 
}

 

your naming convention is a bit odd(_three?)

 

edit: also, just to toss this out their for thought: what happens when your ball impacts the block along the side's rather than top or bottom?


#3slicer4ever

Posted 10 January 2013 - 01:31 AM

well I have decided to finish my breakout game using opengl and c++. I am still stuck on how to get the ball to bounce off the brick and get it to disappear. Then when it is removed I want the ball to pass through the space where the brick was. Please don't give me a lot of code. Also I am using magic numbers for now. Here is just a little bit of code.

if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f)
	{
	ystep = -ystep;
	g_bBlock[4].m_bActive_three=false;	
	}
well this code checks for a brick and then switches the ball's velocity and then turns off the brick. but it still bounces off where the brick was. I know I have asked this question before but I would like a fresh perspective. I am doing my best to finish this project.

 

if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f && g_bBlock[4].m_bActive_three==true) { 
   ystep = -ystep; 
   g_bBlock[4].m_bActive_three=false; 
}

 

your naming convention is a bit odd(_three?)

 

edit: also, just to toss this out their for thought: what happens when your ball impacts just the side of the block?


#2slicer4ever

Posted 10 January 2013 - 01:30 AM

well I have decided to finish my breakout game using opengl and c++. I am still stuck on how to get the ball to bounce off the brick and get it to disappear. Then when it is removed I want the ball to pass through the space where the brick was. Please don't give me a lot of code. Also I am using magic numbers for now. Here is just a little bit of code.

if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f)
	{
	ystep = -ystep;
	g_bBlock[4].m_bActive_three=false;	
	}
well this code checks for a brick and then switches the ball's velocity and then turns off the brick. but it still bounces off where the brick was. I know I have asked this question before but I would like a fresh perspective. I am doing my best to finish this project.

 

if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f && g_bBlock[4].m_bActive_three==true) { 
   ystep = -ystep; 
   g_bBlock[4].m_bActive_three=false; 
}

 

your naming convention is a bit odd(_three?)


#1slicer4ever

Posted 10 January 2013 - 01:28 AM

well I have decided to finish my breakout game using opengl and c++. I am still stuck on how to get the ball to bounce off the brick and get it to disappear. Then when it is removed I want the ball to pass through the space where the brick was. Please don't give me a lot of code. Also I am using magic numbers for now. Here is just a little bit of code.

if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f)
	{
	ystep = -ystep;
	g_bBlock[4].m_bActive_three=false;	
	}
well this code checks for a brick and then switches the ball's velocity and then turns off the brick. but it still bounces off where the brick was. I know I have asked this question before but I would like a fresh perspective. I am doing my best to finish this project.

</p><pre>
if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f && g_bBlock[4].m_bActive_three==true)
	{
	ystep = -ystep;
	g_bBlock[4].m_bActive_three=false;	
	}if(x>=3.0f && x<=5.0f && y>=3.5f && y<=4.0f)
	{
	ystep = -ystep;
	g_bBlock[4].m_bActive_three=false;	
	}</pre>

 

your naming convention is a bit odd(_three?)


PARTNERS