Skip to content

Commit

Permalink
reset & WindowSize
Browse files Browse the repository at this point in the history
  • Loading branch information
Himanshu4746 committed Jul 25, 2017
1 parent d5c690b commit f04d83d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignore/
21 changes: 20 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ void myinit()
glutPostRedisplay();
}

void reshape(int w,int h)
{
glutReshapeWindow(500,500);
}

bool mouseBtnTest(int btn,int state){
if(btn==GLUT_LEFT_BUTTON && state==GLUT_DOWN && evaluate(board)==0)
return true;
Expand Down Expand Up @@ -142,6 +147,18 @@ void mouse(int btn,int state,int ox,int oy)
glutPostRedisplay();
}

void keyboard(unsigned char key,int x, int y)
{
if (key == 27 || key=='q'|| key=='Q') // escape key
exit(0);
else if(key=='R' || key=='r'){
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
board[i][j]='_';
glutPostRedisplay();
}
}

void drawX(int i,int j){
glLineWidth(7);
glColor3ub(0x54,0x54,0x54);
Expand Down Expand Up @@ -378,11 +395,13 @@ int main(int argc, char **argv)
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(0,0);
glutInitWindowPosition(100,100);
glutCreateWindow("TicTacToe");

myinit();
glutMouseFunc(mouse);
glutKeyboardFunc(keyboard);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
}

0 comments on commit f04d83d

Please sign in to comment.