I’m trying to write a simple 2D game that has flashing squares of different colors, that once clicked on with the mouse disappear. I have the squares flashing on screen in random positions, but can’t get them to change colors and I also don’t know how to have the mouse function work with something like this. Can anyone help me??
if your are using glut it is really easy
Do a seach or glutMousefunc(), it is a easy way to setup the mouse.
As for changing colors, just use a varaible.
GLfloat color_select[2][3] ={{ 1.0, 0.0, 0.0},{0.0, 1.0, 0.0}};
// Also above could be used to flash the squares
//draw square 1
if(selected == TRUE )
{
square1 = 1;
}else square1 = 0;
glColor3fv( color_select[square1]); Set color based on selected or unselected.
draw_square();
Originally posted by aj3732:
I’m trying to write a simple 2D game that has flashing squares of different colors, that once clicked on with the mouse disappear. I have the squares flashing on screen in random positions, but can’t get them to change colors and I also don’t know how to have the mouse function work with something like this. Can anyone help me??