void logotest(void)
{
    int h;
    void *scaled;
    /* Set logo palette. */
    setcustompalette();
    /* Create logo bitmap */
    logobitmap = alloca(LOGOWIDTH * LOGOHEIGHT);
    loadbitmap("linuxlogo.bmp", logobitmap);
    /* Allocate buffer for scaled bitmap. */
    scaled = alloca(WIDTH * HEIGHT);
    gl_clearscreen(0);
    /* Stretch vertically. */
    for (h = 0; h <= LOGOHEIGHT; h++) {
	gl_scalebox(LOGOWIDTH, LOGOHEIGHT, logobitmap,
		    LOGOWIDTH, h, scaled);
	gl_putbox(0, 0, LOGOWIDTH, h, scaled);
	if (VIRTUAL)
	    gl_copyscreen(physicalscreen);
    }
    gl_clearscreen(0);
    /* Scale to screen resolution. */
    gl_scalebox(LOGOWIDTH, LOGOHEIGHT, logobitmap, WIDTH, HEIGHT, scaled);
    gl_putbox(0, 0, WIDTH, HEIGHT, scaled);
    gl_copyscreen(physicalscreen);
}
void opening(XInfo &xinfo)
{
	char *filename[31];
	filename[0] = (char *)"bitmap/open/open0.xbm";
	filename[1] = (char *)"bitmap/open/open1.xbm";
	filename[2] = (char *)"bitmap/open/open2.xbm";
	filename[3] = (char *)"bitmap/open/open3.xbm";
	filename[4] = (char *)"bitmap/open/open4.xbm";
	filename[5] = (char *)"bitmap/open/open5.xbm";
	filename[6] = (char *)"bitmap/open/open6.xbm";
	filename[7] = (char *)"bitmap/open/open7.xbm";
	filename[8] = (char *)"bitmap/open/open8.xbm";
	filename[9] = (char *)"bitmap/open/open9.xbm";
	filename[10] = (char *)"bitmap/open/open10.xbm";
	filename[11] = (char *)"bitmap/open/open11.xbm";
	filename[12] = (char *)"bitmap/open/open12.xbm";
	filename[13] = (char *)"bitmap/open/open13.xbm";
	filename[14] = (char *)"bitmap/open/open14.xbm";
	filename[15] = (char *)"bitmap/open/open15.xbm";
	filename[16] = (char *)"bitmap/open/open16.xbm";
	filename[17] = (char *)"bitmap/open/open17.xbm";
	filename[18] = (char *)"bitmap/open/open18.xbm";
	filename[19] = (char *)"bitmap/open/open19.xbm";
	filename[20] = (char *)"bitmap/open/open20.xbm";
	filename[21] = (char *)"bitmap/open/open21.xbm";
	filename[22] = (char *)"bitmap/open/open22.xbm";
	filename[23] = (char *)"bitmap/open/open23.xbm";
	filename[24] = (char *)"bitmap/open/open24.xbm";
	filename[25] = (char *)"bitmap/open/open25.xbm";
	filename[26] = (char *)"bitmap/open/open26.xbm";
	filename[27] = (char *)"bitmap/open/open27.xbm";
	filename[28] = (char *)"bitmap/open/open28.xbm";
	filename[29] = (char *)"bitmap/open/open29.xbm";
	filename[30] = (char *)"bitmap/open/open30.xbm";
	filename[31] = (char *)"bitmap/open/open31.xbm";
	
	Pixmap opening[31];
	int FPS = 30;
	XEvent event;
	unsigned long lastRepaint = 0;
	int frame = 0;
	int start_huh = 0;
	int time = 60000000;
	XFillRectangle(xinfo.display, xinfo.window, xinfo.gc[0], 0, 0, 800, 600);
	
	while( start_huh == 0) {
		if (XPending(xinfo.display) > 0) {
			XNextEvent( xinfo.display, &event );
			switch( event.type ) {
				case KeyPress:
					handleKeyPress_skip(xinfo, event, start_huh);
					break;
				case ConfigureNotify:
					handleResize(xinfo, event);
					break;	
				
			}
		}
		
		// animation timing
		unsigned long end = now();
		if (frame == 31) 
		{
			//printf("set start to 1\n");
			start_huh = 1;
		}
		if (end - lastRepaint > time/FPS)
		{
			if (frame >= 16) 
				time = 90000000;
			//printf("frame is %d\n", frame);
			opening[frame] = loadbitmap(xinfo, filename[frame]);
			XCopyPlane(xinfo.display, opening[frame], xinfo.window, xinfo.gc[0],
                    0, 0, 800,600, (xinfo.current_w-800)/2, (xinfo.current_h-600)/2,1);
			
			std::string text1("PRESS 's' TO SKIP");
			XDrawImageString( xinfo.display, xinfo.window, xinfo.gc[1], (xinfo.current_w-800)/2+350, (xinfo.current_h-600)/2+550, text1.c_str(), text1.length()  );
			
			frame++;
			lastRepaint = now();
		}


		// give the system time to do other things
		if (XPending(xinfo.display) == 0) {
			usleep(time/FPS - (end - lastRepaint));
		}
	} //end while
}
void handleCrush(XInfo xinfo, Ship ship, int flag)
{
	int current_w;		// current size
	int current_h;
	
	Pixmap ship_crush[5];
	
	ship_crush[0] = loadbitmap(xinfo, (char *)"bitmap/crush/ship_crush1.xbm");

	ship_crush[1] = loadbitmap(xinfo, (char *)"bitmap/crush/ship_crush2.xbm");

    ship_crush[2] = loadbitmap(xinfo, (char *)"bitmap/crush/ship_crush3.xbm");

    ship_crush[3] = loadbitmap(xinfo, (char *)"bitmap/crush/ship_crush4.xbm");

    ship_crush[4] = loadbitmap(xinfo, (char *)"bitmap/crush/ship_crush5.xbm");

    ship_crush[5] = loadbitmap(xinfo, (char *)"bitmap/crush/ship_crush6.xbm");

	int i;
	int j;
	
	for (i = 0; i<=5; i++) {
		for (j = 0; j <10000; j ++)
		{
		XCopyPlane(xinfo.display, ship_crush[i], xinfo.window, xinfo.gc[0],
                    0, 0, 20, 20, ship.x, ship.y, 1);
		}
		//usleep(1000000);
	
	
	}
	

	std::string text("YOUR SHIP CRUSHED!!!");
	XDrawImageString( xinfo.display, xinfo.window, xinfo.gc[0],
                		xinfo.current_w/2 - 10, xinfo.current_h/2 - 10, text.c_str(), text.length()  );
/*    
    if (flag == 0) 
	    text=("You let the ship crush on the mountain, you failed to save the planet... you should feel the guilt now, and you should definitely try again and beat the game");
	else if (flag == 1) 
	    text=("It was such a tragic... you tried so hard and get so far... but the speed was too fast...");

 	XDrawImageString( xinfo.display, xinfo.window, xinfo.gc[0], xinfo.current_w/2 - 100, xinfo.current_h/2 + 20, text.c_str(), text.length()  );    
                	*/
    
    Pixmap end;
    
    if (flag == 0)
    {
    	Pixmap end = loadbitmap(xinfo, (char*) "bitmap/others/mountain.xbm");
			XCopyPlane(xinfo.display, end, xinfo.window, xinfo.gc[0],
                    0, 0, 800,600, (xinfo.current_w-800)/2, (xinfo.current_h-600)/2,1);
	}
	
	else if (flag == 1)
    {
    	Pixmap end = loadbitmap(xinfo, (char*) "bitmap/others/speed.xbm");
			XCopyPlane(xinfo.display, end, xinfo.window, xinfo.gc[0],
                    0, 0, 800,600, (xinfo.current_w-800)/2, (xinfo.current_h-600)/2,1);
	}
	
	text=("Press space to try again");
	XDrawImageString( xinfo.display, xinfo.window, xinfo.gc[1],
                		xinfo.current_w/2 - 65, xinfo.current_h/2 + 270, text.c_str(), text.length()  );
}
Exemple #4
0
int designerinit()
{
 int i,flag = 1,quit = 0,ctr=0;
 sel = 0;
 char ch;
 char help[][50] = {"                                       \0",//0
		    "Click On Buttons to activate event     \0",//1
		    "Select a desired lens                  \0",//2
		    "Enter X coord of optical centre of lens\0",//3
		    "Sorry!!!Enter X coord below 600        \0",//4
		    "Enter Radius of First Interface        \0",//5
		    "Enter Radius of Second Interface       \0",//6
		    "Sorry!!!Enter radius between 60 and 200\0",//7
		    "Enter Radius of curved Interface       \0",//8
		    "Enter Refractive Index of Lens         \0",//9
		    "Sorry!!!Enter RI from 0.5 to 2.0(exc.1)\0",//10
		    "New Lens Inserted                      \0",//11
		    "Sorry!!!Overflow of Lenses(Max : 6)    \0",//12
		    "Enter Lens Number to be Modified       \0",//13
		    "Enter Value(1 to \0"                      ,//14
		    "Sorry!!!Underflow of Lenses            \0",//15
		    "Lens Removed                           \0",//16
		    "Lens Modified                          \0",//17
		    "Sorry!!!Enter X coord above \0"           ,//18
		    "\0",//19
		    "\0",//20
		    "\0",//21
		   };
 loadbitmap(pic);
 lensfinit();
 setcolor(12);
 rectangle(10,10,getmaxx()-10,getmaxy()-10);
 rectangle(15,15,getmaxx()-15,getmaxy()-15);
 setfillstyle(SOLID_FILL,15);floodfill(12,12,12);
 setcolor(10);rectangle(50,55,200,175);rectangle(45,50,205,180);
 setfillstyle(SOLID_FILL,12);floodfill(47,57,10);
 setcolor(12);rectangle(30,220,230,320);
 setcolor(10);line(80,184,80,210);line(60,197,80,184);line(80,210,60,197);
 setfillstyle(SOLID_FILL,1);floodfill(75,197,10);
 line(170,184,170,210);line(190,197,170,184);line(170,210,190,197);floodfill(175,197,10);
 rectangle(95,186,155,212);floodfill(97,188,10);outtextxy(102,195,"SELECT");
 setcolor(11);outtextxy(235,37,"HELP:");
 gotoxy(36,3);cout<<"Click on buttons to activate event";
 outtextxy(233,52,"INPUT:");
 setcolor(12);line(287,65,600,65);
 settextstyle(DEFAULT_FONT,HORIZ_DIR,1);setcolor(11);
 outtextxy(30,37,"LENS:");
 window(80,26,425,440,1,"DONE",0);
 window(80,26,535,440,1,"QUIT",0);
 window(80,26,315,440,1,"BACK",0);
 setfillstyle(SOLID_FILL,1);settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
 rectangle(255,276,575,294);floodfill(257,278,10);outtextxy(375,282,"REMOVE LENS");
 rectangle(255,298,575,316);floodfill(257,300,10);outtextxy(375,303,"MODIFY LENS");
 erase(51,56,199,174);
 gotoxy(10,3);cout<<"                    ";
 gotoxy(10,3);puts(lens[ctr].name);
 drawlens(lens[ctr],1);
 MM.reset();directvideo = 0;MM.show();
 while(quit==0)
 {
  if(MM.leftPressed)
  {
   if((mousechk(60,184,80,210)==1)&&flag==1)
   {
    if(ctr==0)ctr = 5; else --ctr;
    erase(51,56,199,174);
    gotoxy(10,3);cout<<"                    ";
    gotoxy(10,3);puts(lens[ctr].name);
    gotoxy(36,3);puts(help[2]);
    drawlens(lens[ctr],1);
    delay(600);
   }
   if((mousechk(170,184,190,210)==1)&&flag==1)
   {
    if(ctr==5)ctr = 0; else ++ctr;
    erase(51,56,199,174);
    gotoxy(10,3);cout<<"                    ";
    gotoxy(10,3);puts(lens[ctr].name);
    gotoxy(36,3);puts(help[2]);
    drawlens(lens[ctr],1);
    delay(600);
   }
   if((mousechk(95,186,155,212)==1)&&flag==1)
   {
    gotoxy(10,3);cout<<"                    ";
    gotoxy(10,3);puts(lens[ctr].name);
    gotoxy(36,3);puts(help[2]);
    if(sel<6) {flag = 0;selectlens(lens[ctr],flag,help,sel,0);}
    else {gotoxy(36,3);puts(help[12]);}
    delay(600);
   }
   if((mousechk(255,298,575,316)==1)&&flag==1)
   {
    if(sel!=0)
    {
     gotoxy(10,3);cout<<"                    ";
     gotoxy(10,3);puts(lens[ctr].name);
     gotoxy(36,3);puts(help[13]);
     flag = 0;
     do
     {
      gotoxy(37,4);puts(help[0]);
      gotoxy(37,4);cin>>i;
      gotoxy(36,3);puts(help[0]);
      gotoxy(36,3);puts(help[14]);
      gotoxy(54,3);cout<<sel<<")";
     } while(!(i>=1&&i<=sel));
     gotoxy(36,3);puts(help[0]);
     selectlens(lensf[i-1],flag,help,sel,i);
    }
    else
    {
     gotoxy(36,3);puts(help[0]);
     gotoxy(36,3);puts(help[15]);
    }
     delay(600);
   }
   if((mousechk(255,270,575,288)==1)&&flag==1)
   {
    if(sel!=0)
    {
     gotoxy(36,3);puts(help[0]);
     gotoxy(36,3);puts(help[16]);
     for(i=0;i<sel;i++)
     {
      gotoxy(5,i+15);
      cout<<"                       ";
     }
     --sel;
     for(i = 0;i<sel;i++)
     {
      gotoxy(5,i+15);
      cout<<i+1<<" ";
      puts(lensf[i].name);
     }
    }
    else
    {
     gotoxy(36,3);puts(help[0]);
     gotoxy(36,3);puts(help[15]);
    }
    delay(600);
   }
   if((mousechk(495,427,575,453)==1)&&flag==1)
   {
    for(i=0;i<5;i++)
    {
     window(80,26,535,440,4,"QUIT",0);delay(50);
     window(80,26,535,440,14,"QUIT",0);delay(50);
    }
    delay(1000);
    quit = 1; return 6;
   }
   if((mousechk(275,427,355,453)==1)&&flag==1)
   {
    for(i = 0;i<5;i++)
    {
     window(80,26,315,440,4,"BACK",0);delay(50);
     window(80,26,315,440,14,"BACK",0);delay(50);
    }
    delay(1000);
    quit = 1; return 0;
   }
   if((mousechk(385,427,465,453)==1)&&flag==1)
   {
    for(i = 0;i<5;i++)
    {
     window(80,26,425,440,4,"DONE",0);delay(50);
     window(80,26,425,440,14,"DONE",0);delay(50);
    }
    delay(1000);
    quit = 1;return 7;
   }
  }
void handleWin(XInfo xinfo, Ship ship)
{

	Pixmap ship_land[16];
	
	ship_land[0] = loadbitmap(xinfo, (char *)"bitmap/landing/landing1.xbm");

	ship_land[1] = loadbitmap(xinfo, (char *)"bitmap/landing/landing2.xbm");

    ship_land[2] = loadbitmap(xinfo, (char *)"bitmap/landing/landing3.xbm");

    ship_land[3] = loadbitmap(xinfo, (char *)"bitmap/landing/landing4.xbm");

    ship_land[4] = loadbitmap(xinfo, (char *)"bitmap/landing/landing5.xbm");

    ship_land[5] = loadbitmap(xinfo, (char *)"bitmap/landing/landing6.xbm");
    
    ship_land[6] = loadbitmap(xinfo, (char *)"bitmap/landing/landing7.xbm");

	ship_land[7] = loadbitmap(xinfo, (char *)"bitmap/landing/landing8.xbm");

    ship_land[8] = loadbitmap(xinfo, (char *)"bitmap/landing/landing9.xbm");

    ship_land[9] = loadbitmap(xinfo, (char *)"bitmap/landing/landing10.xbm");

    ship_land[10] = loadbitmap(xinfo, (char *)"bitmap/landing/landing11.xbm");

    ship_land[11] = loadbitmap(xinfo, (char *)"bitmap/landing/landing12.xbm");
    
    ship_land[12] = loadbitmap(xinfo, (char *)"bitmap/landing/landing13.xbm");

	ship_land[13] = loadbitmap(xinfo, (char *)"bitmap/landing/landing14.xbm");

    ship_land[14] = loadbitmap(xinfo, (char *)"bitmap/landing/landing15.xbm");

    ship_land[15] = loadbitmap(xinfo, (char *)"bitmap/landing/landing16.xbm");


	int i;
	int j;
	
	for (i = 0; i<=15; i++) {
		for (j = 0; j <30000; j ++)
		{
		XCopyPlane(xinfo.display, ship_land[i], xinfo.window, xinfo.gc[0],
                    0, 0, 20, 20, ship.x, ship.y, 1);
		}
		//usleep(1000000);
	
	
	}
	
	Pixmap win[5];
	
	win[0] = loadbitmap(xinfo, (char *)"bitmap/win/win0.xbm");
	win[1] = loadbitmap(xinfo, (char *)"bitmap/win/win1.xbm");
	win[2] = loadbitmap(xinfo, (char *)"bitmap/win/win3.xbm");
	win[3] = loadbitmap(xinfo, (char *)"bitmap/win/win4.xbm");
	win[4] = loadbitmap(xinfo, (char *)"bitmap/win/win5.xbm");
	
	
	for (i = 0; i<=4; i++) {
		for (j = 0; j <1000; j ++)
		{
			if (i>=4){
				j += 500;
				}
								
		XCopyPlane(xinfo.display, win[i], xinfo.window, xinfo.gc[0],
                    0, 0, 800, 600, (xinfo.current_w-800)/2, (xinfo.current_h-600)/2, 1);
		}
		//usleep(1000000);
	
	
	}
	
	/*
	XFillRectangle(xinfo.display, xinfo.window, xinfo.gc[0], (xinfo.current_w-800)/2, (xinfo.current_h-600)/2, 800, 600);
				std::string text("YOU WIN!!!");
				XDrawImageString( xinfo.display, xinfo.window, xinfo.gc[1],
               			xinfo.current_w/2 - 10, xinfo.current_h/2 - 10, text.c_str(), text.length()  );
               			
               	text=("Press space to play again");
				XDrawImageString( xinfo.display, xinfo.window, xinfo.gc[1],
                		xinfo.current_w/2 - 45, xinfo.current_h/2 + 20, text.c_str(), text.length()  );*/

}