int TextInput::Input(char score[])
{
    Ocean2 ocean;
    ocean.ReadFigure();
    Congratulation cong;
    cong.ReadFigure();
    
    FsPollDevice();
    while(FSKEY_NULL!=FsInkey() || 0!=FsInkeyChar())
    {
        FsPollDevice();
    }
    int count=0;

    for(;;)
    {
        FsPollDevice();
        
        int key=FsInkey();
        
        switch(key)
        {
            case FSKEY_ESC:
                return 0;
            case FSKEY_ENTER:
                return 1;
            case FSKEY_BS:
                str.BackSpace();
                count--;
                break;
        }
        
        const char c=FsInkeyChar();
        
        if(0!=c && 0!=isprint(c) && count<10)
        {
            str.Add(c);
            count++;
        }
       
        glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
        
        cong.Drawcongratulation_png();
        
        glRasterPos2d(460, 200);
        YsGlDrawFontBitmap20x32("SCORE");

        glRasterPos2d(400, 200+50);
        YsGlDrawFontBitmap20x32(score);
        
        Drawocean2(450);
        ocean.Drawocean_png();
        Draw();
        
        FsSwapBuffers();
        
        FsSleep(20);
    }
    return 0;
}
Exemple #2
0
void Button::DrawModeTitle2 (void)
{
	glColor3ub(255, 255, 255);
    glRasterPos2d(80,100);
    YsGlDrawFontBitmap20x32 ("2 P");
	glRasterPos2d(79,100);
    YsGlDrawFontBitmap20x32 ("2 P");
	glRasterPos2d(81,100);
    YsGlDrawFontBitmap20x32 ("2 P");
	glRasterPos2d(80,99);
    YsGlDrawFontBitmap20x32 ("2 P");
	glRasterPos2d(80,101);
    YsGlDrawFontBitmap20x32 ("2 P");
}
void TextInput::Draw(void)
{
    
    glColor3ub(0,0,0);
    glRasterPos2d(490,250);
    YsGlDrawFontBitmap20x32(str.GetPointer());
    switch(time(NULL)%2)
    {
        case 0:
            YsGlDrawFontBitmap20x32("_");
            break;
        case 1:
            YsGlDrawFontBitmap20x32(" ");
            break;
    }
}
Exemple #4
0
void GameMenu::DrawStart(double begin)
{
		
    
        glColor3ub(0,0,0);
        glRasterPos2d((windowWid/2)-90,(windowHei/2)-16);
        YsGlDrawFontBitmap20x32("S T A R T");
        
    
}
Exemple #5
0
void drawplane(const int counter)
{
	if(counter==1)
	{
		glColor3ub(0,255,0);
		//printf("\n colour changed to green");
	}
	else if(counter==2)
	{
		glColor3ub(0,255,255);
		//printf("\n colour changed to some colour");
	}
	else if(counter==3)
	{
		glColor3ub(0,0,255);
		//printf("\n colour changed to blue");
	}
	if(counter==1)
	{
		
		glRasterPos2d(300,100);
		YsGlDrawFontBitmap20x32("THE BAT X");
	}
	if(counter==2)
	{
		
		glRasterPos2d(300,100);
		YsGlDrawFontBitmap20x32("THE FA-HORNET");
	}
	if(counter==3)
	{
		
		glRasterPos2d(300,100);
		YsGlDrawFontBitmap20x32("THE DESTROYER");
	}

}
int main(void)
{
	Frame fra;
    
	int lb, mb, rb, rx, ry;//mouse variables
	int mode=0;
	int isWarp=1;  // in the warp or compete mode
	int winner=0;
	int mouseDown=0; 

	int winWid,winHei;
	
	Button Left[4];
	Button Right[4];
	Button Menu[6];

	YsRawPngDecoder image1;
	YsRawPngDecoder image2;
	makegif gif;

	TextString FaceLocation[4];
	TextString TemplateLocation[4];

	int pos1[4];
	int pos2[4];

	int image2Pos[2][4]; //the first index is the image, the second index is the position

	int faceChosen;
	int templateChosen;
	
	////////////////////////////////////////////////////////////////////
	// initialize the positions
	////////////////////////////////////////////////////////////////////

	image2Pos[0][0]=95;
	image2Pos[0][1]=12;
	image2Pos[0][2]=153;
	image2Pos[0][3]=85;

	image2Pos[1][0]=290;
	image2Pos[1][1]=25;
	image2Pos[1][2]=410;
	image2Pos[1][3]=155;
	
	

	////////////////////////////////////////////////////////////////////
	// initialize the face & template locations
	////////////////////////////////////////////////////////////////////

	FaceLocation[0].Set("face0.png");
	FaceLocation[1].Set("face1.png");
	FaceLocation[2].Set("face2.png");
	FaceLocation[3].Set("face3.png");

	TemplateLocation[0].Set("template0.png");
	TemplateLocation[1].Set("template1.png");
	TemplateLocation[2].Set("GIF1/01.png");
	TemplateLocation[3].Set("GIF2/01.png");


	///////////////////////////////////////////////////////////////////////
	// initialize the buttons
	///////////////////////////////////////////////////////////////////////

	for (int i=0; i<4; i++)
	{
		Left[i].wid=160;
		Left[i].hei=120;
		Right[i].wid=160;
		Right[i].hei=120;
	}

    Left[0].init(20, 50, "Picture 1");
    Left[1].init(20, 200, "Picture 2");
    Left[2].init(20, 350, "Picture 3");
    Left[3].init(20, 500, "Picture 4");

	Right[0].init(1120, 50, "Template 1");
    Right[1].init(1120, 200, "Template 2");
    Right[2].init(1120, 350, "Gif 1");
    Right[3].init(1120, 500, "Gif 2");
    
	for (int i=0; i<6; i++)
	{
		Menu[i].wid=80;
		Menu[i].hei=20;
	}
	
	Menu[0].init(20, 5, "Start");
    Menu[1].init(120, 5, "Compete");
    Menu[2].init(220, 5, "Rotate");
    Menu[3].init(320, 5, "Clear");
    Menu[4].init(420, 5, "Exit");
    Menu[5].init(520, 5, "Help");

	FsOpenWindow(64,16,1300,700,1);
	fra.display();

	FsGetWindowSize(winWid,winHei);

	while(1)
	{
		mouseDown=0;
		FsPollDevice();
		glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
		fra.DrawToolbox();
        fra.DrawColum();
        fra.DrawShowWindow();
        fra.DrawExit();

		for (int i=0; i<4; i++)
		{
			Left[i].draw();
			Right[i].draw();
		}

		for (int i=0; i<6; i++)
		{
			Menu[i].draw();
		}


		////////////////////////////////////////////////////////////////////////
		// get button states
		////////////////////////////////////////////////////////////////////////

		if(FsGetMouseEvent(lb,mb,rb,rx,ry)==FSMOUSEEVENT_LBUTTONDOWN)
		{
			mouseDown=1;
			for (int i=0; i<4; i++)
			{
				Left[i].checkPressed(rx, ry);
				Right[i].checkPressed(rx, ry);
			}
			for (int i=0; i<6; i++)
			{
				Menu[i].checkPressed(rx, ry);
			}
		}


		if (Menu[3].state==1)
		{
			mode=WAIT_LEFTBUT;
			Menu[3].state=0;
			isWarp=1;
			Menu[1].state=0;
			winner=0;
		}
		
		if (Menu[1].state==1)
		{
			isWarp=0;
		}

		if (Menu[4].state==1)
		{
			break;
		}

		///////////////////////////////////////////////////////////////
		// switch among different state of the game
		////////////////////////////////////////////////////////////////
		
		if (isWarp==1) //in the warp mode
		{
			switch(mode)
			{
			case WAIT_LEFTBUT:
				{
					for (int i=0; i<4; i++)
					{
						if (Left[i].state==1) // if pressed
						{
						
							if(YSOK==image1.Decode(FaceLocation[i].GetPointer())) 
							{
								printf(FaceLocation[i].GetPointer());
								mode=WAIT_POS1;
								Left[i].state=0;
								faceChosen=i;
								break;
							}
						}

					}
					break;
				}
			case WAIT_POS1:
				{
					if (mouseDown==1)
					{
						if (rx-300<=image1.wid && 550-ry<=image1.hei && rx-300>0 && 550-ry>0)
						{
							pos1[0]=rx-300;
							pos1[1]=image1.hei-(550-ry);
							mouseDown=0;
							mode=WAIT_POS2;
							printf("first pos %d %d\n",pos1[0],pos1[1]);
						}
					
					}
					break;
				}
			case WAIT_POS2:
				{
					if (mouseDown==1)
					{
						if (rx-300<=image1.wid && 550-ry<=image1.hei && rx-300>0 && 550-ry>0)
						{
							pos1[2]=rx-300;
							pos1[3]=image1.hei-(550-ry);
							mouseDown=0;
							mode=WAIT_TEMPLATE;
							printf("second pos %d %d\n",pos1[2],pos1[3]);
						}
					
					}
					break;
				}
			case WAIT_TEMPLATE:
				{
				
					for (int i=0; i<2; i++)
					{
						if (Right[i].state==1) // if pressed
						{
						
							if(YSOK==image2.Decode(TemplateLocation[i].GetPointer())) 
							{
								mode=WAIT_WARP;
								Right[i].state=0;
								templateChosen=i;

								pos2[0]=image2Pos[i][0];
								pos2[1]=image2Pos[i][1];
								pos2[2]=image2Pos[i][2];
								pos2[3]=image2Pos[i][3];
							
								break;


							}
						}

					}

					if (Right[2].state==1)
					{
						if(YSOK==image2.Decode(TemplateLocation[2].GetPointer())) 
							{
								mode=WAIT_WARP;
								Right[2].state=0;
								templateChosen=2;
								//printf("GIF1\n");


								//char *image1String=FaceLocation[faceChosen].GetPointer();
								char gifString[]={"GIF1/01.png"};
								//char gifString[]={"GIF2/01.png"};

								gif.initial(gifString,image2,12,15,0,45,40); //initial the gif class 
								//gif.initial(gifString,image2,4,160,50,260,165); //initial the gif class 
								gif.setImage1(image1,FaceLocation[faceChosen].GetPointer()); // select the head picture

								gif.setImage1HeadLT(pos1[0],pos1[1]); // select the left top point of the head picture

								gif.setImage2HeadRB(pos1[2],pos1[3]); // select the right bottom point of the head picture
								gif.copyRGBA(image1,image2);

								break;

							}
						break;

					}

					if (Right[3].state==1)
					{
						if(YSOK==image2.Decode(TemplateLocation[3].GetPointer())) 
							{
								mode=WAIT_WARP;
								Right[3].state=0;
								templateChosen=3;
								//printf("GIF1\n");


								//char *image1String=FaceLocation[faceChosen].GetPointer();
								//char gifString[]={"GIF1/01.png"};
								char gifString[]={"GIF2/01.png"};

								printf(FaceLocation[faceChosen].GetPointer());

								//gif.initial(gifString,image2,12,15,0,45,40); //initial the gif class 
								gif.initial(gifString,image2,4,160,50,260,165); //initial the gif class 
								gif.setImage1(image1,FaceLocation[faceChosen].GetPointer()); // select the head picture

								gif.setImage1HeadLT(pos1[0],pos1[1]); // select the left top point of the head picture

								gif.setImage2HeadRB(pos1[2],pos1[3]); // select the right bottom point of the head picture
								gif.copyRGBA(image1,image2);

								break;

							}
						break;

					}
					
						
				
					break;
				}
			case WAIT_WARP:
				{
					if (Menu[0].state==1)
					{
						warpImage(image1, image2, pos1, pos2, 0.0);
						mode=FINISHED;
						Menu[0].state=0;
					}
					if (Menu[2].state==1)
					{
						warpImage(image1, image2, pos1, pos2,-20.0);
						mode=FINISHED;
						Menu[2].state=0;
					}
					break;
				
				}
			case FINISHED:
				{
					if (Menu[3].state==1)
					{
						mode=WAIT_LEFTBUT;
						Menu[3].state=0;
					}
					break;
				}
			}
		}
		else
		{
			switch(mode)
			{
			case WAIT_LEFTBUT:
				{
					for (int i=0; i<4; i++)
					{
						if (Left[i].state==1) // if pressed
						{
						
							if(YSOK==image1.Decode(FaceLocation[i].GetPointer())) 
							{
								printf(FaceLocation[i].GetPointer());
								mode=WAIT_TEMPLATE;
								Left[i].state=0;
								//faceChosen=i;
								break;
							}
						}

					}
					break;
				}
			case WAIT_TEMPLATE:
				{
				
					for (int i=0; i<4; i++)
					{
						if (Left[i].state==1) // if pressed
						{
						
							if(YSOK==image2.Decode(FaceLocation[i].GetPointer())) 
							{
								printf(FaceLocation[i].GetPointer());
								mode=WAIT_WARP;
								Left[i].state=0;
								//faceChosen=i;
								break;
							}
						}

					}
					
					break;
				}
			case WAIT_WARP:
				{
					
					if (Menu[0].state==1)
					{
						
						winner=BeautyCompetition(image1,image2);
						glRasterPos2d(300.0,(double)(winHei-50));
						if (winner==1)
						{
							YsGlDrawFontBitmap20x32("PICTURE 1 WINS!");
						}
						else if (winner==2)
						{
							YsGlDrawFontBitmap20x32("PICTURE 2 WINS!");
						}
						printf("\nWINNER:%d!!!\n",winner);
						mode=FINISHED;
						Menu[0].state=0;
					}
					break;
				
				}
			case FINISHED:
				{
					if (Menu[3].state==1)
					{
						mode=WAIT_LEFTBUT;
						Menu[3].state=0;
						winner=0;
					}
					break;
				}
			}
		}

		///////////////////////////////////////////////////////////////
		// actually draw
		//////////////////////////////////////////////////////////////

		if (mode==WAIT_LEFTBUT)
		{
			//do nothing 
		}
		else if (mode>WAIT_LEFTBUT && mode<=WAIT_TEMPLATE)
		{
			image1.Flip();
			FsGetWindowSize(winWid,winHei);
			glRasterPos2d(300.0,(double)(winHei-150));
			glDrawPixels(image1.wid,image1.hei,GL_RGBA,GL_UNSIGNED_BYTE,image1.rgba);
			image1.Flip();
		}
		else if (mode>WAIT_TEMPLATE && mode<=FINISHED)
		{
			if (templateChosen<2)
			{
				image2.Flip();
				FsGetWindowSize(winWid,winHei);
				glRasterPos2d(300.0,(double)(winHei-150));
				glDrawPixels(image2.wid,image2.hei,GL_RGBA,GL_UNSIGNED_BYTE,image2.rgba);
				image2.Flip();
			}
			else if(templateChosen==2 || templateChosen==3)
			{
				if (mode==FINISHED)
				{
				gif.draw();
				}
				else 
				{
					image2.Flip();
					FsGetWindowSize(winWid,winHei);
					glRasterPos2d(300.0,(double)(winHei-150));
					glDrawPixels(image2.wid,image2.hei,GL_RGBA,GL_UNSIGNED_BYTE,image2.rgba);
					image2.Flip();
				}
			}

			if (winner==1)
			{
				glRasterPos2d(300.0,(double)(winHei-50));
				YsGlDrawFontBitmap20x32("PICTURE 1 WINS!");
			}
			else if (winner==2)
			{
				glRasterPos2d(300.0,(double)(winHei-50));
				YsGlDrawFontBitmap20x32("PICTURE 2 WINS!");
			}
						
		}

		


		FsSwapBuffers();
		FsSleep(25);
	}

	return 0;
	
}
Exemple #7
0
void GameMenu::DrawKeyOption (void)
{
	glColor3ub(100, 255, 0);
	glRasterPos2d(159,321);
    YsGlDrawFontBitmap20x32 ("       D I N N E R");
	glRasterPos2d(161,321);
    YsGlDrawFontBitmap20x32 ("       D I N N E R");
	glRasterPos2d(159,319);
    YsGlDrawFontBitmap20x32 ("       D I N N E R");
	glRasterPos2d(161,321);
    YsGlDrawFontBitmap20x32 ("       D I N N E R");
	glRasterPos2d(158,320);
    YsGlDrawFontBitmap20x32 ("       D I N N E R");
	glRasterPos2d(162,320);
    YsGlDrawFontBitmap20x32 ("       D I N N E R");
	glRasterPos2d(160,318);
    YsGlDrawFontBitmap20x32 ("       D I N N E R");
	glRasterPos2d(160,322);
    YsGlDrawFontBitmap20x32 ("       D I N N E R");

	glColor3ub(0, 0, 0);
    glRasterPos2d(160,250);
    YsGlDrawFontBitmap20x32 ("D O N'T  b e");
	glRasterPos2d(159,250);
    YsGlDrawFontBitmap20x32 ("D O N'T  b e");
	glRasterPos2d(161,250);
    YsGlDrawFontBitmap20x32 ("D O N'T  b e");
	glRasterPos2d(160,249);
    YsGlDrawFontBitmap20x32 ("D O N'T  b e");
	glRasterPos2d(160,251);
    YsGlDrawFontBitmap20x32 ("D O N'T  b e");

	glRasterPos2d(160,320);
    YsGlDrawFontBitmap20x32 ("       D I N N E R");
	glRasterPos2d(159,320);
    YsGlDrawFontBitmap20x32 ("       D I N N E R");
	glRasterPos2d(161,320);
    YsGlDrawFontBitmap20x32 ("       D I N N E R");
	glRasterPos2d(160,319);
    YsGlDrawFontBitmap20x32 ("       D I N N E R");
	glRasterPos2d(160,321);
    YsGlDrawFontBitmap20x32 ("       D I N N E R");


	glColor3ub(255, 125, 40);
    glRasterPos2d(260,420);
    YsGlDrawFontBitmap20x28 ("D:");
	glColor3ub(255, 255, 40);
    glRasterPos2d(310,420);
    YsGlDrawFontBitmap16x20 ("Default Control");

	glColor3ub(255, 125, 40);
    glRasterPos2d(260,470);
    YsGlDrawFontBitmap20x28 ("R:");
	glColor3ub(255, 255, 40);
    glRasterPos2d(310,470);
    YsGlDrawFontBitmap16x20 ("Remapped Control");

	glColor3ub(255, 125, 40);
    glRasterPos2d(260,520);
    YsGlDrawFontBitmap16x24 ("Esc:");
	glColor3ub(255, 255, 40);
    glRasterPos2d(340,520);
    YsGlDrawFontBitmap16x20 ("end the game");

	glColor3ub(255, 255, 255);
    glRasterPos2d(520,25);
    YsGlDrawFontBitmap6x10 ("24-780 Engineering Computation Final Project");
	glRasterPos2d(600,45);
    YsGlDrawFontBitmap6x10 ("Copyright 2011 Fall");
}
Exemple #8
0
void Map::RunMap()
{
	key = 0;
	int offset=0;
	char *story[] = { 
		"Welcome to CMU Adventure!",
		"Whether you have made up your mind to come to CMU or", 
		"you are still mulling over it, you are welcome to use", 
		"this game to have a glimpse of life at CMU.", 
		" ",
		"To familiarize yourself with the CMU environment,", 
		"navigate through the satellite view map of CMU campus ", // changes by Chun Fan
		"to explore all the buildings.", // changes by Chun Fan
		" ",
		"Studying constitutes a large part of CMU student life.",
		"CMU tries to make learning fun.See how MechE students", 
		"learn CAD & gear theory by playing the CAD & Gear games",
		"at Hammerschlag Hall and Hunts library.",
		" ",
		"Sometimes massive number of assignments could means ",
		"many sleepless nights. Play the StayAwake game to see", // changes by Chun Fan
		"how CMU lecturers and students fight off sleeping bugs",
		"during lectures in Margaret-Morrison Hall.",
		" ",
		"Student life is not just about studying, recreation is", 
		"essential too. Have some fun by playing the Pool game",
		"at University Center.",
		" ",
		"At CMU, safety is utmost important.CMU provides shuttle",
		"buses to ferry students and staffs back home safely.",
		"Play the Shuttle game at Porter Hall to have a feel on",
		"how it is like to catch a shuttle bus at CMU.",
		" ",
		"Press Enter to start game!"
		};

	Building building[5];	
	building[0].set("Uiversity Center", 1374, 1239,  110, 136);
	building[1].set("Hunts Hall", 1042, 662, 70, 35);
	building[2].set("Hammerschlag Hall", 454,  984,  111, 90);
	building[3].set("Porter Hall", 626,  805,  115, 75);
	building[4].set("Margaret-Morisson", 1489, 938,  50,  90);
		
    
	if(YSOK==png.Decode("instructions_background.png"))
    {
		// changes by Chun Fan
        //printf("Read Width=%d Height=%d\n",png.wid,png.hei);
        png.Flip();
    }
    else
    {
        printf("Read Error!\n");
        return ;
    }

	// Story Cover Page
	
	glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);

	int winWid,winHei;
	FsGetWindowSize(winWid, winHei);
	glRasterPos2d(0.0, (double)(winHei-1));
	glDrawPixels(png.wid, png.hei, GL_RGBA, GL_UNSIGNED_BYTE, png.rgba);

	if(YSOK==png.Decode("map-with light.png"))
    {
		// changes by Chun Fan
        //printf("Read Width=%d Height=%d\n",png.wid,png.hei);
        png.Flip();
    }
    else
    {
        printf("Read Error!\n");
        return ;
    }

	glColor3ub(0,0,255);
	int n_line=1;
	glRasterPos2d(75,75);
	YsGlDrawFontBitmap20x32(story[0]);

	glColor3ub(0,0,0);
	for (int i=1; i<28; i++)
	{
		n_line++;			
		glRasterPos2d(75,75+16*n_line);
		YsGlDrawFontBitmap12x16(story[i]);
	}
	n_line++;
	glColor3ub(255,0,0);
	glRasterPos2d(75,75+16*n_line);
	YsGlDrawFontBitmap12x16(story[28]);

	FsSwapBuffers();
	
	
	while (key!=FSKEY_ENTER)
	{
		FsPollDevice();
		key = FsInkey();
		
		FsSleep(20);
	}

	
    
    key=FSKEY_NULL;
    int Mnumber=0;
    
    while(FSKEY_ESC!=key)
    {
        FsPollDevice();
        key=FsInkey();
        glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
        
        if (key==FSKEY_M)
        {
            Mnumber++;
        }
        if (Mnumber%2==0)
        {
            DramMap();//Include check player's position(whether player can step on that part or not) and move
                      //the map.
            
            CheckPlayersState();
            
            player.DrawPlayerInMap();
            
            player.DrawMovingPlayerInCorner(player.PlayersState);
        }
        if (Mnumber%2==1)
        {
            ShowShrinkMap();
        }
		
		// check position
		int x=GetPlayersPositionX();
		int y=GetPlayersPositionY();
		//printf("x = %d,\t y = %d\n", x, y);

		srand((unsigned int)time(NULL) + rand());

		for (int i=0; i<5; i++)
		{
			int x_min = building[i].getX() - building[i].getW() ;
			int x_max = building[i].getX() + building[i].getW() ;
			int y_min = building[i].getY() - building[i].getH() ;
			int y_max = building[i].getY() + building[i].getH() ;
			if (x>x_min && x<x_max && y>y_min && y<y_max)
			{
				//char name[256];
				YsRawPngDecoder png4;
				int state0=0,state1=0,state2=0,state3=0,state4=0;

				FsPollDevice();
				
				int MouseEvent;

				int lb,mb,rb,mx,my;

				//building[i].getName(name);
				//printf("I am in %s!\n", name);
				switch (i)
				{
					case 0: // pool
                        if(YSOK==png4.Decode("ClickButton.png"))
                        {
                           png4.Flip();
                           int winWid,winHei;
                           FsGetWindowSize(winWid,winHei);
						   glRasterPos2d(400,300);
						   glDrawPixels(png4.wid,png4.hei,GL_RGBA,GL_UNSIGNED_BYTE,png4.rgba);
						   // changes by Chun Fan
						   //printf("%d  %d",png4.wid,png4.hei);					 
						}

						MouseEvent=FsGetMouseEvent(lb,mb,rb,mx,my);
						switch(MouseEvent)
						{
						case FSMOUSEEVENT_LBUTTONDOWN:
								if(mx>=400 && mx<=600 && my>=200 && my<=300)
								{
									state0=1;
								}
						}

						if(state0==1)
						{
							score.setResult(0, poolgame.rungame());
							// changes by Chun Fan
							//printf("Game 1: %d trials, %s\n", score.getCount(0), score.getResult(0)?"Passed":"Failed");
							FsClearEventQueue();
						}
						state0=0;
						//FsClearEventQueue();

						break;

					case 1: // CAD
						if(YSOK==png4.Decode("ClickButton.png"))
                        {
                           png4.Flip();
                           int winWid,winHei;
                           FsGetWindowSize(winWid,winHei);
						   glRasterPos2d(400,300);
						   glDrawPixels(png4.wid,png4.hei,GL_RGBA,GL_UNSIGNED_BYTE,png4.rgba);
						   // changes by Chun Fan
						   //printf("%d  %d",png4.wid,png4.hei);					 
						}

						MouseEvent=FsGetMouseEvent(lb,mb,rb,mx,my);
						switch(MouseEvent)
						{
						case FSMOUSEEVENT_LBUTTONDOWN:

								if(mx>=400 && mx<=600 && my>=200 && my<=300)
								{
									state1=1;
								}
						}

						if(state1==1)
						{
							
							score.setResult(1, cadclass.CADMain());
							// changes by Chun Fan
							//printf("Game 2: %d trials, %s\n", score.getCount(1), score.getResult(1)?"Passed":"Failed");
							FsClearEventQueue();
						}
						state1=0;		
						//FsClearEventQueue();

						break;

					case 2: // gear game
						if(YSOK==png4.Decode("ClickButton.png"))
                        {
                           png4.Flip();
                           int winWid,winHei;
                           FsGetWindowSize(winWid,winHei);
						   glRasterPos2d(400,300);
						   glDrawPixels(png4.wid,png4.hei,GL_RGBA,GL_UNSIGNED_BYTE,png4.rgba);
						   // changes by Chun Fan
						   //printf("%d  %d",png4.wid,png4.hei);					 
						}

						MouseEvent=FsGetMouseEvent(lb,mb,rb,mx,my);
						switch(MouseEvent)
						{
						case FSMOUSEEVENT_LBUTTONDOWN:
								if(mx>=400 && mx<=600 && my>=200 && my<=300)
								{
									state2=1;
								}
						}

						if(state2==1)
						{
						   score.setResult(2, geargame.run());
						   // changes by Chun Fan
						   //printf("Game 3: %d trials, %s\n", score.getCount(2), score.getResult(2)?"Passed":"Failed");
						   
							// changes by Chun Fan
						    glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
							FsClearEventQueue();
						}
						state2=0;
						//FsClearEventQueue();

						break;

					case 3:
						if( score.getGraduate())
						{
							if(YSOK==png4.Decode("ClickButton.png"))
							{
							   png4.Flip();
							   int winWid,winHei;
							   FsGetWindowSize(winWid,winHei);
							   glRasterPos2d(400,300);
							   glDrawPixels(png4.wid,png4.hei,GL_RGBA,GL_UNSIGNED_BYTE,png4.rgba);
							   // changes by Chun Fan
							   //printf("%d  %d",png4.wid,png4.hei);					 
							}

							MouseEvent=FsGetMouseEvent(lb,mb,rb,mx,my);
							switch(MouseEvent)
							{
							case FSMOUSEEVENT_LBUTTONDOWN:
									if(mx>=400 && mx<=600 && my>=200 && my<=300)
									{
										state3=1;
									}
							}
						}

						if(state3==1 )
						{
						   shuttle.action();

							glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);

							score.DrawScoreCard();

							FsSwapBuffers();
							
							FsPollDevice();
							int key1 = FsInkey();
							
							while(key1!=FSKEY_ENTER)
							{
								
								FsPollDevice();
								key1 = FsInkey();
								FsSleep(20);
							}
							
							glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);

							awardStage.SetDept("Mechanical Engineering");

							awardStage.DrawStage();
							awardStage.PrintCert();

							FsSwapBuffers();						
							
							FsPollDevice();
							key1 = FsInkey();
							
							while(key1!=FSKEY_ENTER)
							{
								FsPollDevice();
								key1 = FsInkey();
								
								FsSleep(20);
							}
							key=FSKEY_ESC;

						}
						state3=0;
				
						//if (checkscore()==1)		
						FsClearEventQueue();

						break;

					case 4: // stayawake
						if(YSOK==png4.Decode("ClickButton.png"))
                        {
                           png4.Flip();
                           int winWid,winHei;
                           FsGetWindowSize(winWid,winHei);
						   glRasterPos2d(400,300);
						   glDrawPixels(png4.wid,png4.hei,GL_RGBA,GL_UNSIGNED_BYTE,png4.rgba);
						   // changes by Chun Fan
						   //printf("%d  %d",png4.wid,png4.hei);					 
						}

						MouseEvent=FsGetMouseEvent(lb,mb,rb,mx,my);
						switch(MouseEvent)
						{
						case FSMOUSEEVENT_LBUTTONDOWN:
								if(mx>=400 && mx<=600 && my>=200 && my<=300)
								{
									state4=1;
								}
						}

						if(state4==1)
						{
						   stayawake.StartGame();
						   score.setResult(3, stayawake.GetScore());
						   // changes by Chun Fan
						   //printf("Game 4: %d trials, %s\n", score.getCount(3), score.getResult(3)?"Passed":"Failed");
							FsClearEventQueue();
						}
						state4=0;
						//FsClearEventQueue();

						break;
					
				}
			}
		}
		
        FsSwapBuffers();
        FsSleep(50);
    }
}