wordshooter.cpp
void MouseClicked(int button, int state, int x, int y) {
	if (game_start==false)
		game_start=true;
	else if (second_click==false) //avoid bug due to double click detection
	{
		second_click=true;
		//checks any combinations formed in the random letters
		while (popped)
		{
			popped=false; //continues checking until no more words are formed
			for (int i=0; i<nfrows; i++)
			{
				for (int j=0; j<cells-9; j++)
				{
					tile_y=i;
					tile_x=j;
					temp_word=form_word(4); //forms horizontally right combinations of letters
					check_pop_word(temp_word); 
				}
			}
			for (int i=0; i<nfrows; i++)
			{
				for (int j=0; j<cells; j++)
				{
					if (Alphabets[i][j]==27)
						Alphabets[i][j]=GetAlphabet(); //generates new letters for the popped indices in the array
				}
			}
		}
	}
	else
	{
		if (button == GLUT_LEFT_BUTTON) // dealing only with left button
		{
			if (state == GLUT_UP && moving_ball==false && y<=height-bheight-10)
			{
				slope=float(x-ball_x)/(height-y-ball_y);
				moving_ball=true;
			}
		}
		else if (button == GLUT_RIGHT_BUTTON) // dealing with right button
		{//right click swaps the two shooter balls
			if (swapped==false)
			{
				int temp=AlphShooter;
				AlphShooter=AlphSecond;
				AlphSecond=temp;
				swapped=true;
			}
			else
				swapped=false;
		}
	}
	glutPostRedisplay();
}
/*This function is called (automatically) whenever your mouse button is clicked witin inside the game window
*
* You will have to add the necessary code here for shooting, etc.
*
* This function has four arguments: button (Left, Middle or Right), state (button is pressed or released),
* x & y that tells the coordinate of current position of move mouse
*
* */
This function is called (automatically) whenever your mouse button is clicked witin inside the game window
You will have to add the necessary code here for shooting, etc.

This function has four arguments: button (Left, Middle or Right), state (button is pressed or released),
x & y that tells the coordinate of current position of move mouse
This function is called ( automatically ) whenever your mouse button is clicked witin inside the game window You will have to add the necessary code here for shooting etc . This function has four arguments : button ( Left Middle or Right ) state ( button is pressed or released ) x & y that tells the coordinate of current position of move mouse
void MouseClicked(int button, int state, int x, int y) {
	if (game_start==false)
		game_start=true;
	else if (second_click==false) 
	{
		second_click=true;
		while (popped)
		{
			popped=false; 
			for (int i=0; i<nfrows; i++)
			{
				for (int j=0; j<cells-9; j++)
				{
					tile_y=i;
					tile_x=j;
					temp_word=form_word(4); 
					check_pop_word(temp_word); 
				}
			}
			for (int i=0; i<nfrows; i++)
			{
				for (int j=0; j<cells; j++)
				{
					if (Alphabets[i][j]==27)
						Alphabets[i][j]=GetAlphabet(); 
				}
			}
		}
	}
	else
	{
		if (button == GLUT_LEFT_BUTTON) 
		{
			if (state == GLUT_UP && moving_ball==false && y<=height-bheight-10)
			{
				slope=float(x-ball_x)/(height-y-ball_y);
				moving_ball=true;
			}
		}
		else if (button == GLUT_RIGHT_BUTTON) 
		{
			if (swapped==false)
			{
				int temp=AlphShooter;
				AlphShooter=AlphSecond;
				AlphSecond=temp;
				swapped=true;
			}
			else
				swapped=false;
		}
	}
	glutPostRedisplay();
}
void MouseClicked ( int button , int state , int x , int y ) { if ( game_start == false ) game_start = true ; else if ( second_click == false ) { second_click = true ; while ( popped ) { popped = false ; for ( int i = 0 ; i < nfrows ; i ++ ) { for ( int j = 0 ; j < cells - 9 ; j ++ ) { tile_y = i ; tile_x = j ; temp_word = form_word ( 4 ) ; check_pop_word ( temp_word ) ; } } for ( int i = 0 ; i < nfrows ; i ++ ) { for ( int j = 0 ; j < cells ; j ++ ) { if ( Alphabets [ i ] [ j ] == 27 ) Alphabets [ i ] [ j ] = GetAlphabet ( ) ; } } } } else { if ( button == GLUT_LEFT_BUTTON ) { if ( state == GLUT_UP && moving_ball == false && y <= height - bheight - 10 ) { slope = float ( x - ball_x ) / ( height - y - ball_y ) ; moving_ball = true ; } } else if ( button == GLUT_RIGHT_BUTTON ) { if ( swapped == false ) { int temp = AlphShooter ; AlphShooter = AlphSecond ; AlphSecond = temp ; swapped = true ; } else swapped = false ; } } glutPostRedisplay ( ) ; }
This function is called (automatically) whenever your mouse button is clicked witin inside the game window
You will have to add the necessary code here for shooting, etc.
This function is called ( automatically ) whenever your mouse button is clicked witin inside the game window You will have to add the necessary code here for shooting etc .
//avoid bug due to double click detection //checks any combinations formed in the random letters //continues checking until no more words are formed //forms horizontally right combinations of letters //generates new letters for the popped indices in the array // dealing only with left button // dealing with right button //right click swaps the two shooter balls