   game engine
  I am developing a game engine for a breakout game using c++ and directx9. I am working on a  program that will detect if a ball hits a brick and makes that brick disappear.I am using a boolean to set the brick to on or off. However my question is how do I get the boolean to set the  brick on or off and make it a permanent decision.Here is the code I have developed so far.#include <iostream>#include <time.h>using namespace std;int main(){srand(time(NULL));int bricks[3][4];int ball_left = rand()%800;int ball_top = rand()%600;cout << ball_left << endl;cout << ball_top << endl;int  col_index = 0.005 * ball_left;int row_index = 0.02 * ball_top;cout << col_index << endl;cout << row_index << endl;bool blue_brick = true;bool red_brick = true;bool green_brick = true;bool blue_two_brick = true;bool green_two_brick = true;bool red_two_brick = true;if(row_index==2){switch (col_index){case 0:cout << "Turn Off Blue Brick" << endl;blue_brick=false;break;case 1:cout << "Turn Off Red Brick" << endl;red_brick=false;break;case 2:cout << "Turn Off Green Brick" << endl;green_brick=false;break;case 3:cout << "Turn Off Second Blue Brick" << endl;blue_two_brick=false;break;}}if(row_index==1){switch (col_index){case 0:cout << "Turn Off Green Brick" << endl;green_brick=false;break;case 1:cout << "Turn Off Blue Brick" << endl;blue_brick=false;break;case 2:cout << "Turn Off Red Brick" << endl;red_brick=false;break;case 3:cout << "Turn Off Second Green Brick" << endl;green_two_brick=false;break;}}if(row_index==0){switch (col_index){case 0:cout << "Turn Off Red Brick" << endl;red_brick=false;break;case 1:cout << "Turn Off Green Brick" << endl;green_brick=false;break;case 2:cout << "Turn Off Blue Brick" << endl;blue_brick=false;break;case 3:cout << "Turn Off Second Red Brick" << endl;red_two_brick=false;break;}}return 0;}I used a rand function just to test the program.   
[deleted : sorry, misread the code];  all your code is in main, which runs only once.   At the top of main, you set all the bricks to true, then randomly turn one off.   But, then the program ends, and if you want to see it again you have to rerun it, which repeats the above process.So, what you need is a modification.   First, you need what's sometimes referred to as the "main loop", which will allow you to maintain a permanent state for your bricks while the program is running (while the main loop is repeating over and over again)Also, make sure to have a way to exit out of the main loop.   I would suggest for starters that you use a simple counter, and only iterate through the loop maybe only 4 or 5 times.in psuedo-code, the basic structure might look something like this:count = 0// outside the loop, the code to initialize //    all bricks to true goes herewhile (count < 5)  count = count +1  // code to choose a random screen position here  // code to update the brick state goes here  // if count < 5, we'll repeat the loopend//  all done - any cleanup code can go here