Exemplo n.º 1
0
/* Draw the pawn */
void draw_pawn(int coord_x, int coord_y, int color)
{
	if(color == 0)
	{
		GrSetGCForeground(tuxchess_gc,WHITE);
		GrFillEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4);
		GrSetGCForeground(tuxchess_gc,BLACK);
		GrEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4);
		GrSetGCForeground(tuxchess_gc,WHITE);
		GrFillRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3);
		GrSetGCForeground(tuxchess_gc,BLACK);
		GrRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3);
	}
	else 
	{
		GrSetGCForeground(tuxchess_gc,BLACK);
		GrFillEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4);
		GrSetGCForeground(tuxchess_gc,LTGRAY);
		GrEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4);
		GrSetGCForeground(tuxchess_gc,BLACK);
		GrFillRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3);
		GrSetGCForeground(tuxchess_gc,LTGRAY);
		GrRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3);
	}
}
Exemplo n.º 2
0
/* Draw the pawn */
void draw_pawn(int coord_x, int coord_y, char color)
{
	if(color == 'w')
	{
		GrSetGCForeground(tuxchess_gc,GR_RGB(255,255,255));
		GrFillEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4);
		GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0));
		GrEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4);
		GrSetGCForeground(tuxchess_gc,GR_RGB(255,255,255));
		GrFillRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3);
		GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0));
		GrRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3);
	}
	else 
	{
		GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0));
		GrFillEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4);
		GrSetGCForeground(tuxchess_gc,GR_RGB(160,160,160));
		GrEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4);
		GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0));
		GrFillRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3);
		GrSetGCForeground(tuxchess_gc,GR_RGB(160,160,160));
		GrRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3);
	}
}
Exemplo n.º 3
0
static void
GrEllipseWrapper(void *r)
{
	nxEllipseReq *req = r;

	GrEllipse(req->drawid, req->gcid, req->x, req->y, req->rx, req->ry);
}
Exemplo n.º 4
0
static void
draw_screen(void)
{
	GR_POINT tri[4] = { {5, 115}, {105, 115}, {55, 200}, {5, 115} };
	GR_WINDOW_INFO winfo;
	GR_GC_ID gc;
	char dash1[2] = { 10, 5 };
	char dash2[4] = { 5, 2, 1, 2 };
	char dash3[4] = { 5, 2, 5, 5 };
	char dash4[2] = { 2, 2 };

	GrGetWindowInfo(g_main, &winfo);

	/* Draw several lines and a few boxes */
	gc = GrNewGC();
	GrSetGCLineAttributes(gc, GR_LINE_ONOFF_DASH);

	/* Draw a dashed box */

	GrSetGCDash(gc, dash1, 2);
	GrRect(g_main, gc, 5, 5, 100, 100);

	GrSetGCDash(gc, dash2, 4);
	GrLine(g_main, gc, 10, 10, 95, 95);

	GrSetGCDash(gc, dash3, 4);
	GrEllipse(g_main, gc, 160, 55, 50, 50);

	GrSetGCDash(gc, dash4, 2);
	GrPoly(g_main, gc, 4, tri);

	GrDestroyGC(gc);
}
Exemplo n.º 5
0
/* Draw the king */
void draw_king(int coord_x, int coord_y, char color)
{
	GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0));
	GrLine(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+1,coord_x+6,coord_y+4);
	GrLine(tuxchess_wid,tuxchess_gc,coord_x+4,coord_y+2,coord_x+8,coord_y+2);
	if(color == 'w')
		GrSetGCForeground(tuxchess_gc,GR_RGB(255,255,255));

	GrFillEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+8,4,4);
	GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0));
	GrEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+8,4,4);
}
Exemplo n.º 6
0
/* Draw the king */
void draw_king(int coord_x, int coord_y, int color)
{
 	GrSetGCForeground(tuxchess_gc,BLACK);
	GrLine(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+1,coord_x+6,coord_y+4);
	GrLine(tuxchess_wid,tuxchess_gc,coord_x+4,coord_y+2,coord_x+8,coord_y+2);
	if(color == 0)
		GrSetGCForeground(tuxchess_gc,WHITE);

	GrFillEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+8,4,4);
	GrSetGCForeground(tuxchess_gc,BLACK);
	GrEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+8,4,4);
}
Exemplo n.º 7
0
/* draw a button to the screen at x,y using info from id */
void lights_draw_button( int x, int y, int id )
{
	int ls2 = lights_size/2;

	/* change color based on if it's lit or not */
	if( lights_states[id] ) {
		if( lights_screen_info.bpp == 16 )
		    GrSetGCForeground( lights_gc, GR_RGB( 255, 100, 50 ));
		else 
		    GrSetGCForeground( lights_gc, GR_RGB(255,255,255) );
	} else {
		GrSetGCForeground( lights_gc, GR_RGB(0,0,0) );
	}
	GrFillEllipse( lights_bufwid, lights_gc, 
		ls2+x, ls2+y, ls2-2, ls2-2 );

	/* draw the container */
	if( lights_screen_info.bpp == 16 )
	    GrSetGCForeground( lights_gc, GR_RGB( 102, 0, 0 ));
	else 
	    GrSetGCForeground( lights_gc, GR_RGB(80,80,80) );
	GrEllipse( lights_bufwid, lights_gc, 
		    ls2+x, ls2+y, ls2-1, ls2-1 );

	/* draw the cursor if applicable */
	if( id == lights_curr  &&  !lights_hold_engaged )
	{
		if( lights_cursblink ) {
		    if( lights_screen_info.bpp == 16 )
			GrSetGCForeground( lights_gc, GR_RGB( 0, 255, 0 ));
		    else
			GrSetGCForeground( lights_gc, GR_RGB(255,255,255) );
		} else {
		    GrSetGCForeground( lights_gc, GR_RGB(0,0,0) );
		}
		GrEllipse( lights_bufwid, lights_gc, 
			ls2+x, ls2+y, ls2, ls2 );
		GrEllipse( lights_bufwid, lights_gc, 
			ls2+x, ls2+y, ls2-1, ls2-1 );
		GrEllipse( lights_bufwid, lights_gc, 
			ls2+x, ls2+y, ls2-1, ls2 );
		GrEllipse( lights_bufwid, lights_gc, 
			ls2+x, ls2+y, ls2, ls2-1 );

		if( lights_cursblink ) {
			GrSetGCForeground( lights_gc, GR_RGB(0,0,0) );
		} else {
		    if( lights_screen_info.bpp == 16 )
			GrSetGCForeground( lights_gc, GR_RGB( 0, 255, 255 ));
		    else
			GrSetGCForeground( lights_gc, GR_RGB(255,255,255) );
		}
		GrEllipse( lights_bufwid, lights_gc, 
			ls2+x, ls2+y, ls2-2, ls2-2 );
	}
}
Exemplo n.º 8
0
static void me_draw(int angle)
{
	int vx,vy;
	angle += 180;
	GrEllipse(ipobble_wid, ipobble_gc, me_posx, me_posy,
			ME_RADIUS, ME_RADIUS);
	/* draw arrow... for now just a line... */
	
	vx = (int)((float)(2.5 * ME_RADIUS) * (float)sin((float)angle /
				180 * 3.1415));
	vy = (int)((float)(2.5 * ME_RADIUS) * (float)cos((float)angle /
				180 * 3.1415));
	GrLine(ipobble_wid, ipobble_gc, me_posx, me_posy, me_posx + vx,
			me_posy + vy);
	
}
Exemplo n.º 9
0
void drawXO(int pos, int shade, char theChar)
{	
	int xPos, yPos, i;
	GrSetGCUseBackground(tictactoe_gc, GR_TRUE);
    GrSetGCBackground(tictactoe_gc, WHITE);
    GrSetGCForeground(tictactoe_gc, shade);
	
	xPos = wi.width * .25 * (pos % 3 + 1);
	yPos = wi.height * .25 * (pos / 3 + 1);
	
	if (theChar == 'o') {
		for ( i = 0; i < 4; i++)
			GrEllipse(tictactoe_wid, tictactoe_gc, xPos, yPos, wi.width * .03 + i, wi.height * .03 + i);
	} else if (theChar == 'x') {
		for ( i = 0; i < 4; i++) {
			GrLine(tictactoe_wid, tictactoe_gc, xPos - wi.width * .03 + i, yPos - wi.height * .03, 
				   xPos + wi.width * .03 + i, yPos + wi.height * .03);
			GrLine(tictactoe_wid, tictactoe_gc, xPos - wi.width * .03 + i, yPos+ wi.height * .03, 
				   xPos + wi.width * .03 + i, yPos - wi.height * .03);
		}
	}
}
Exemplo n.º 10
0
static int keyman_handle_event(GR_EVENT * event)
{
	int ret = 0;
    switch( event->type )
    {
    case( GR_EVENT_TYPE_TIMER ):
	
	switch(GAMEN){
		
		
		case MENU:
			makemenu();
			
			MINIPHOTO(0,0,160,128);
			wlastkey.AR=0;wlastkey.AL=0;wlastkey.AU=0;wlastkey.AD=0;wlastkey.REE=0;wlastkey.PAU=0;
			break;
		case INGAME:
			
		
		
		
			if (wlastkey.AL==1){wnow.LR=-1;wnow.MUKI=-1;}
			else if(wlastkey.AR==1){wnow.LR=1;wnow.MUKI=1;}
			else {wnow.LR=0;}
			
			
			if(wlastkey.REE==1){
					if(wnow.JIMEN==ZIM){
					wnow.YKANSEI=-9;
					wnow.JIMEN=SORA;
					}
					else if (wnow.HASIGO==1){
					wnow.YKANSEI=-9;
					wnow.JIMEN=SORA;
					wnow.HASIGO=0;
					
					}
			}
			
			if (INIT(wnow.XLOC+8,wnow.YLOC+8,'G')==FALSE){wnow.HASIGO=0;}
			
			
			
			if (INIT(wnow.XLOC+8,wnow.YLOC+8,'G')== TRUE && wlastkey.AU !=0){
				wnow.HASIGO=1;
				wnow.shupict=2;
				//GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,32,112,0);
				wnow.XKANSEI=0;
				//wnow.YLOC=wnow.YLOC-3;
				}
			else if (INIT(wnow.XLOC+8,wnow.YLOC+8,'G')== TRUE && wlastkey.AD !=0){
				wnow.HASIGO=0;
				//GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,32,112,0);
				wnow.XKANSEI=0;
				//wnow.YLOC=wnow.YLOC+3;	
				}
				
			
			if (wnow.JIMEN==ZIM){wnow.XKANSEI=(0.9*wnow.XKANSEI)+(1*wnow.LR);}
			else {
				if (wnow.LR != 0){
				wnow.XKANSEI=(0.99*wnow.XKANSEI)+(0.3*wnow.LR);
				}
			}
			if (wnow.HASIGO==0 ){
				if (wnow.YKANSEI <= 6){
					wnow.YKANSEI++;
				}
			}
			else {wnow.YKANSEI=0;}
			
			
			

			
			wnow.XLOC=wnow.XLOC+wnow.XKANSEI;
			wnow.YLOC=wnow.YLOC+wnow.YKANSEI;
			
			
			if (wnow.NUPDW==-1 && ((wnow.MAPSCROLL) % 16)==0){wnow.YLOC=wnow.YLOC+16;}
			else if (wnow.NUPDW==1 && (wnow.MAPSCROLL % 16)==15){wnow.YLOC=wnow.YLOC-16;}
			
			
			
			if (wnow.MAPSCROLL>0 && wnow.MAPSCROLL<TATEHABA*16){
				wnow.MAPSCROLL=wnow.MAPSCROLL+wnow.NUPDW;
			}
			scr= (wnow.MAPSCROLL/16);
			ATARI2();
						
			
			if (wlastkey.AU != 1 && wlastkey.AD != 1){
			 if (wnow.MUKI==1){
			 wnow.shupict=0;
			 //GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,0,112,0);
			 }
			 else {
			 wnow.shupict=1;
			 //GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,16,112,0);
			 }
			}			
			
						
			if (wnow.NUPDW==-1 && wnow.YLOC>136){
				wdeady.sp=-20;
				wdeady.g=1.6;
				wdeady.nowt=128;
				GAMEN=END;
				wdeady.kaiten=0;
				ketumatu=0;
				wdeady.deadcount=1;}
				
			else if(wnow.NUPDW==1 && wnow.YLOC<0){
				wdeady.sp=12;
				wdeady.g=0;
				wdeady.nowt=-16;
				GAMEN=END;
				wdeady.kaiten=0;
				ketumatu=0;
				wdeady.deadcount=1;}
			else if (wnow.NUPDW==0 && (wnow.YLOC>136)) {
			
				wdeady.sp=-10;
				wdeady.g=1.6;
				wdeady.nowt=128;
				GAMEN=END;
				wdeady.kaiten=0;
				ketumatu=0;
				wdeady.deadcount=1;}
					
				
			
			GrCopyArea(mainmenu_pixmap,keyman_gc,0,0,160,128,allmap_pixmap,0,wnow.MAPSCROLL,0);
			kmbitmap();
			//GrCopyArea(mainmenu_pixmap,keyman_gc,wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)),160,128,shu_pixmap,0,0,0);
			hensu();		
			
			MINIPHOTO(0,0,160,128);
			if (wlastkey.PAU==1){GAMEN=PAUSE;}
			
			wlastkey.AR=0;wlastkey.AL=0;wlastkey.AU=0;wlastkey.AD=0;wlastkey.REE=0;wlastkey.PAU=0;
			break;
		case PAUSE:
			GrCopyArea(dialogall_pixmap,keyman_gc,0,0,96,80,dialog_pixmap,0,0,0);
			GrCopyArea(dialogall_pixmap,keyman_gc,3,24+(dialogkey*24),13,16,yomipict_pixmap,115,48,0);
			GrCopyArea(keyman_wid,keyman_gc,32+((screen_info.cols-160)/2),24+((screen_info.rows-128)/2),96,80,dialogall_pixmap,0,0,0);
			
			break;
		case END:
				if (ketumatu==0){
					wdeady.sp=wdeady.sp+wdeady.g;
					wdeady.nowt=wdeady.nowt+wdeady.sp;
					//sprintf(hensuu,"%d",wnow.MAPSCROLL+(wdeady.deadcount*wnow.NUPDW));
					
					if (wnow.MAPSCROLL+(wdeady.deadcount*wnow.NUPDW)>0 && wnow.MAPSCROLL+(wdeady.deadcount*wnow.NUPDW)<TATEHABA*16){
						GrCopyArea(mainmenu_pixmap,keyman_gc,0,0,160,128,allmap_pixmap,0,wnow.MAPSCROLL+(wdeady.deadcount*wnow.NUPDW),0);
					}
					
					GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,wdeady.kaiten*16,16,0);
					GrCopyArea(mainmenu_pixmap,keyman_gc,wnow.XLOC,wdeady.nowt,160,128,shu_pixmap,0,0,0);
					hensu();
					
					MINIPHOTO(0,0,160,128);
					if (wdeady.kaiten<7){wdeady.kaiten++;}else{wdeady.kaiten=0;}
					if (training==0){
						if (wdeady.deadcount>31){GAMEN=MENU;
					
						}   
					}
					else if (training==1){
						if (wdeady.deadcount>15){opencard();GAMEN=INGAME;
						}
						
					}
					wdeady.deadcount++;
				}
				else if (ketumatu==1){
					if (training==0){
					GAMEN=MENU;
					}
					if (training==1){
						if (tranum>=MAXTRA){
							GAMEN=MENU;
						}
						else{
							startgame();
							GAMEN=INGAME;
						}
					
					}
				}
			break;
		case NODATA:
			GrSetGCForeground(keyman_gc, WHITE);
			GrFillRect(keyman_wid,keyman_gc,0,0,160,128);
			
			GrSetGCForeground(keyman_gc, GRAY);
			GrLine(keyman_wid,keyman_gc,80,20,34,100);
			GrLine(keyman_wid,keyman_gc,80,20,126,100);
			GrLine(keyman_wid,keyman_gc,34,100,126,100);
			GrEllipse(keyman_wid,keyman_gc,80,55,5,20);
			GrEllipse(keyman_wid,keyman_gc,80,85,5,5);
			
			GrSetGCForeground(keyman_gc, BLACK);
			GrText(keyman_wid,keyman_gc,50,48,"Please Copy",-1,GR_TFASCII|GR_TFTOP);
			GrText(keyman_wid,keyman_gc,30,68,"KMData folder to /etc",-1,GR_TFASCII|GR_TFTOP);
			GrText(keyman_wid,keyman_gc,50,100,"Click to Quit",-1,GR_TFASCII|GR_TFTOP);
			break;
		}
		
			
	break;
	

    case( GR_EVENT_TYPE_KEY_DOWN ):
	
	switch(GAMEN){
		case INGAME:
			if (event->keystroke.ch==wsetkey.KLEFT){wlastkey.AL=1;}else{wlastkey.AL=0;}
			if (event->keystroke.ch==wsetkey.KRIGHT){wlastkey.AR=1;}else{wlastkey.AR=0;}
			if (event->keystroke.ch==wsetkey.KUP){wlastkey.AU=1;}else{wlastkey.AU=0;}
			if (event->keystroke.ch==wsetkey.KDOWN){wlastkey.AD=1;}else{wlastkey.AD=0;}
			if (event->keystroke.ch==wsetkey.KJUMP){wlastkey.REE=1;}else{wlastkey.REE=0;}
			if (event->keystroke.ch==wsetkey.KPAUSE){wlastkey.PAU=1;}else{wlastkey.PAU=0;}
			break;
		case MENU:
			switch( event->keystroke.ch )
			{
	    
			case '\r': /* action */
				switch (wmenukey.BA){
				case 0:if (wmenukey.KEY<2){wmenukey.KEY++;}else{wmenukey.KEY=1;}break;	
				case 1:if (wmenukey.STAGE<MAXSTAGE){wmenukey.STAGE++;}
						else {wmenukey.STAGE=1;}
						break;
				
				case 2: GAMEN=INGAME; 
					training=0;
					startgame();
					break;
				case 3:GAMEN=INGAME;
					tranum=0;
					training=1;
					startgame();
					break;
				case 4: pz_close_window(keyman_wid);
					GrDestroyTimer(keyman_timer);
					GrUnmapWindow(keyman_wid);
					GrDestroyWindow(keyman_wid);
					GrFreeImage(kmimage_id);
					GrDestroyGC(keyman_gc);
					ret = 1;
					break;
				}
			break;
			case 'r': /* CCW spin */
			if (wmenukey.BA<4){ipod_beep();wmenukey.BA++;}		
			break;

			case 'l': /* CW spin */
			if (wmenukey.BA>0){ipod_beep();wmenukey.BA--;}
			break;
			
			case 'm': /* menu */
					pz_close_window(keyman_wid);
					GrDestroyTimer(keyman_timer);
					GrUnmapWindow(keyman_wid);
					GrDestroyWindow(keyman_wid);
					GrFreeImage(kmimage_id);
					GrDestroyGC(keyman_gc);
					ret = 1;		
			break;
			}
			break;
			
					
		case PAUSE:
			if (event->keystroke.ch==wsetkey.KLEFT && dialogkey == 1){ipod_beep();dialogkey=0;}
			if (event->keystroke.ch==wsetkey.KRIGHT && dialogkey == 0){ipod_beep();dialogkey=1;}
			if (event->keystroke.ch==wsetkey.KJUMP && dialogkey == 0){GAMEN=INGAME;}
			else if (event->keystroke.ch==wsetkey.KJUMP && dialogkey == 1){GAMEN=MENU;}
			
			break;
		case END:break;
		case NODATA:
			if (event->keystroke.ch=='\r'){
			GrDestroyTimer(keyman_timer);
			GrUnmapWindow(keyman_wid);
			GrDestroyWindow(keyman_wid);
			GrFreeImage(kmimage_id);
			GrDestroyGC(keyman_gc);
			ret = 1;
			}
			break;
		}
	
	
	
	break;
    }

    return ret;
}