int SureExit(){ outtextxy(320,100,"Play Again?"); outtextxy(240,300,"Yes"); outtextxy(400,300,"No and Quit"); do{ if(leftPress() != 1){ getMousePosition(&mx,&my); if(mousex != mx||mousey != my){ putimage(mousex,mousey,imagep,XOR_PUT); mousex = mx; mousey = my; putimage(mousex,mousey,imagep,XOR_PUT); } }else if(mouseLeftFlag == 1){ mouseLeftFlag = 0; getMousePosition(&mx,&my); if(mx < 280 && mx > 200 && my < 320 && my > 280){ cleardevice(); return 1; } else if(mx < 440 && mx > 360 && my < 320 && my > 280){ cleardevice(); return 0; } } }while(1); }
/*------------------------------------------------------------------- * PrintGreekChar 10.17.90 MM * * Print the given betaletter at X,Y. *------------------------------------------------------------------- */ int PrintGreekChar( int cpX, int cpY, BETALETTER bchar) { int i; if(bchar.dc_num != LCHAR ) { putimage( cpX, cpY, (void far *)&Greek[bchar.charcode][0], bchar.attrib ); for(i=0;i<bchar.dc_num;i++) { if( bchar.dc_codes[i] == IOTASUBCODE ) { putimage( cpX, cpY+1, (void far *) &Greek[bchar.dc_codes[i]][0], XOR_PUT ); } else { putimage( cpX, cpY-3, (void far *) &Greek[bchar.dc_codes[i]][0], XOR_PUT ); } } } else outtextxy(cpX,cpY,bchar.dc_codes); return( CHARWIDTH ); }/*
int main() { int i,gd=DETECT,gm,size; void *buf; initgraph(&gd,&gm,""); setbkcolor(BLUE); cleardevice(); setcolor(LIGHTRED); setlinestyle(0,0,1); setfillstyle(1,10); circle(100,200,30); floodfill(100,200,12); size=imagesize(69,169,131,231); buf=malloc(size); getimage(69,169,131,231,buf); putimage(500,269,buf,COPY_PUT); for(i=0;i<185;i++) { putimage(70+i,170,buf,COPY_PUT); putimage(500-i,170,buf,COPY_PUT); } for(i=0;i<185;i++) { putimage(255-i,170,buf,COPY_PUT); putimage(315+i,170,buf,COPY_PUT); } getch(); closegraph(); }
void MCScreenDC::create_stipple() { graystipple = XCreatePixmap(dpy, getroot(), 32, 32, 1); gc1 = XCreateGC(dpy, graystipple, 0, NULL); XSetGraphicsExposures(dpy, gc1, False); XSetForeground(dpy, gc1, 1); XSetBackground(dpy, gc1, 0); Boolean oldshm = MCshm; MCBitmap *im = createimage(1, 64, 64, False, 0x0, True, False); int2 i; uint4 *dptr = (uint4 *)im->data; for (i = 0 ; i < 16 ; i++) { *dptr++ = 0xAAAAAAAA; *dptr++ = 0xAAAAAAAA; *dptr++ = 0x55555555; *dptr++ = 0x55555555; } putimage(graystipple, im, 0, 0, 0, 0, 32, 32); XSync(dpy, False); if (oldshm != MCshm) putimage(graystipple, im, 0, 0, 0, 0, 32, 32); destroyimage(im); }
food() { row=col=0; setfillstyle(1,15); if(xc!=0 && yc!=0) putimage(xc,yc,f1,XOR_PUT); ram: col=random(1001); while(col>=40) { row=row+1; col-=40; } xc=(col*15)+25; yc=(row*15)+20; for(v=0;v<=i;v++) { if((x[v]==xc)&&(y[v]==yc)) goto ram; } for(v=0;v<=j;v++) { if((x2[v]==xc)&&(y2[v]==yc)) goto ram; } setfillstyle(1,15); if((xc<=610)&&(xc>=25)&&(yc<=380)&&(yc>=20)) { putimage(xc,yc,f1,XOR_PUT); set=1; } else goto ram; return 0; }
void background(void *img1, void *img2, int h, int scroll_speed){ static int y1 = 0, y2 = 0; static int flag = 1; static clock_t cur = clock(); const clock_t delay = 15; if(flag){ y2 = -h; flag = 0; } if(y2 < 0){ putimage(0,y2,img2,0); putimage(0,y1,img1,0); }else{ putimage(0,y1,img1,0); putimage(0,y2,img2,0); } if(clock() - cur > delay){ if(y1 >= getmaxy()) y1 = -h; else y1 += scroll_speed; if(y2 >= getmaxy()) y2 = -h; else y2 += scroll_speed; cur = clock(); } }
void updateexplosion(void){ explosion *ptr = exhead, *dexplosion; int w,h; const clock_t delay = 40; while(ptr != NULL){ if(clock() - ptr -> time < delay && ptr -> frame < ptr -> tframe){ w = ptr -> w; h = ptr -> h; putimage(ptr -> x - w/2, ptr -> y - h/2, ptr -> img[2*(ptr -> frame) + 1], 3); putimage(ptr -> x - w/2, ptr -> y - h/2, ptr -> img[2*(ptr -> frame)], 2); ptr -> frame += 1; ptr -> time = clock(); ptr = ptr -> next; }else if(ptr -> frame >= ptr -> tframe){ dexplosion = ptr; ptr = ptr -> next; deleteexplosion(dexplosion); }else{ w = ptr -> w; h = ptr -> h; putimage(ptr -> x - w/2, ptr -> y - h/2, ptr -> img[2*(ptr -> frame) + 1], 3); putimage(ptr -> x - w/2, ptr -> y - h/2, ptr -> img[2*(ptr -> frame)], 2); ptr = ptr -> next; } } }
int main(void) { clrscr(); /* request autodetection */ int gdriver = DETECT, gmode, errorcode; void *arrow; int x, y, maxx; unsigned int size; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, "d:\\tc\\bgi"); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ } maxx = getmaxx(); x = 0; y = getmaxy() / 2; /* draw the image to be grabbed */ draw_arrow(x, y); /* calculate the size of the image */ size = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE); /* allocate memory to hold the image */ arrow = malloc(size); /* grab the image */ getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow); /* repeat until a key is pressed */ while (!kbhit()) { /* erase old image */ putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); x += ARROW_SIZE; if (x >= maxx) x = 0; /* plot new image */ putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); } /* clean up */ free(arrow); closegraph(); return 0; }
void belowcloud(cloud *cl, int len){ int i; for(i = 0;i < len;i++){ if((!cl[i].alt) && cl[i].active){ putimage(cl[i].x - cl[i].w/2,cl[i].y-cl[i].h/2,cl[i].img[1],3); putimage(cl[i].x - cl[i].w/2,cl[i].y-cl[i].h/2,cl[i].img[0],2); } } }
void printImg(imagem_type *imagem){ int mode = COPY_PUT; if(imagem->mask){ putimage(imagem->pos.x, imagem->pos.y, imagem->mask, AND_PUT); mode = OR_PUT; } putimage(imagem->pos.x, imagem->pos.y, imagem->img, mode); }
void restore(int x1,int y1) { putimage(x1,y1,p1,OR_PUT); putimage(midx+1,y1,p2,OR_PUT); putimage(x1,midy+1,p3,OR_PUT); putimage(midx+1,midy+1,p4,OR_PUT); farfree(p1); farfree(p2); farfree(p3); farfree(p4); }
void NetPlayerInfoView::show() { if (buffer_img_.img) { putimage(buffer_img_.x, buffer_img_.y, buffer_img_.img); delimage(buffer_img_.img); buffer_img_.img = NULL; } calc_view_width_height(); buffer_img_.x = pos_x_; buffer_img_.y = pos_y_; int temp_viewport_left, temp_viewport_right, temp_viewport_top, temp_viewport_bottom; getviewport(&temp_viewport_left, &temp_viewport_top, &temp_viewport_right, &temp_viewport_bottom); setviewport(pos_x_, pos_y_, pos_x_ + view_width_, pos_y_ + view_height_); buffer_img_.img = newimage(view_width_, view_height_); putimage(buffer_img_.img, 0, 0, NULL); setviewport(temp_viewport_left, temp_viewport_top, temp_viewport_right, temp_viewport_bottom); int target_top = pos_y_; if (player_pic_) { player_pic_->show_image_with_alpha(pos_x_ + view_width_ / 2 - player_pic_->get_width() / 2, target_top, 1.0); target_top += player_pic_->get_width() + margin_; } setcolor(WHITE); if (player_name_.length() > 0) { Gobang::set_font(Gobang::font_default, name_font_size_, true); xyprintf(pos_x_ + view_width_ / 2 - textwidth(player_name_.c_str()) / 2, target_top, player_name_.c_str()); target_top += textheight(player_name_.c_str()) + margin_; } if (is_ready_) { Gobang::set_font(Gobang::font_default, ready_font_size_); xyprintf(pos_x_ + view_width_ / 2 - textwidth("Ready!") / 2, target_top, "Ready!"); target_top += textheight("Ready!") + margin_; if (is_playing_) { playing_indicator_->show_image_with_alpha(pos_x_ + view_width_ / 2 - playing_indicator_->get_width() / 2, target_top, 1.0); target_top += playing_indicator_->get_height() + margin_; } } else if (!is_opposite_) { button_ready_->set_position(pos_x_ + view_width_ / 2 - button_ready_->get_width() / 2, target_top); button_ready_->show(); target_top += button_ready_->get_height() + margin_; } }
int updatespbp(spbulletplus **first,spbulletplus **tail,plane *myplane) { spbulletplus *ptr = *first, *dhp; int w,h; int maxx,maxy; double dir; maxx = getmaxx(); maxy = getmaxy(); while(ptr != NULL){ ptr -> x += (int) ((ptr -> speed)*cos(ptr -> angle)); //update position ptr -> y += (int) ((ptr -> speed)*sin(ptr -> angle)); if(sq(ptr->x - myplane->x)+sq(ptr->y - myplane->y) < sq(ptr->r)) { deletespbp(ptr,first,tail); return 1; } else if(ptr -> y + ptr->r > getmaxy()){ ptr -> y = getmaxy() - ptr->r; dir = 2.0 * PI - ptr -> angle; changespbp(ptr, 3, dir); }else if(ptr -> y - ptr->r < 0){ ptr -> y = ptr->r; dir = 2.0 * PI - ptr -> angle; changespbp(ptr, 3, dir); }else if(ptr -> x + ptr->r > getmaxx()){ ptr -> x = getmaxx() - ptr->r; if(ptr -> angle > PI) dir = 3.0*PI - ptr -> angle; else dir = PI - ptr -> angle; changespbp(ptr, 3, dir); }else if(ptr -> x - ptr->r < 0){ ptr -> x = ptr->r; if(ptr -> angle > PI) dir = 3.0*PI - ptr -> angle; else dir = PI - ptr -> angle; changespbp(ptr, 3, dir); } if(ptr!=NULL){ w = ptr -> w; h = ptr -> h; putimage(ptr -> x - w/2, ptr -> y - h/2, ptr -> img[1], 3); putimage(ptr -> x - w/2, ptr -> y - h/2, ptr -> img[0], 2); ptr = ptr -> next; } } return 0; }
main() { int gd = DETECT, gm, area, temp1, temp2, left = 25, top = 75; void *p; initgraph(&gd,&gm,"C:\\TC\\BGI"); setcolor(YELLOW); circle(50,100,25); setfillstyle(SOLID_FILL,YELLOW); floodfill(50,100,YELLOW); setcolor(BLACK); setfillstyle(SOLID_FILL,BLACK); fillellipse(44,85,2,6); fillellipse(56,85,2,6); ellipse(50,100,205,335,20,9); ellipse(50,100,205,335,20,10); ellipse(50,100,205,335,20,11); area = imagesize(left, top, left + 50, top + 50); p = malloc(area); setcolor(WHITE); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2); outtextxy(155,451,"Smiling Face Animation"); setcolor(BLUE); rectangle(0,0,639,449); while(!kbhit()) { temp1 = 1 + random ( 588 ); temp2 = 1 + random ( 380 ); getimage(left, top, left + 50, top + 50, p); putimage(left, top, p, XOR_PUT); putimage(temp1 , temp2, p, XOR_PUT); delay(100); left = temp1; top = temp2; } getch(); closegraph(); return 0; }
static int tmap_tiff( /* tone map SGILOG TIFF */ char *fname, TIFF *tp ) { float xres, yres; uint16 orient, resunit, phot; int xsiz, ysiz; uby8 *pix; /* check to make sure it's SGILOG */ TIFFGetFieldDefaulted(tp, TIFFTAG_PHOTOMETRIC, &phot); if ((phot == PHOTOMETRIC_LOGL) | (phot == PHOTOMETRIC_MINISBLACK)) flags |= TM_F_BW; /* read and tone map TIFF */ if (tmMapTIFF(&pix, &xsiz, &ysiz, flags, rgbp, gamv, lddyn, ldmax, fname, tp) != TM_E_OK) return(-1); /* get relevant tags */ TIFFGetFieldDefaulted(tp, TIFFTAG_RESOLUTIONUNIT, &resunit); TIFFGetFieldDefaulted(tp, TIFFTAG_XRESOLUTION, &xres); TIFFGetFieldDefaulted(tp, TIFFTAG_YRESOLUTION, &yres); TIFFGetFieldDefaulted(tp, TIFFTAG_ORIENTATION, &orient); /* put out our image */ if (putimage(orient, (uint32)xsiz, (uint32)ysiz, xres, yres, resunit, pix) != 0) return(-1); /* free data and we're done */ free((void *)pix); return(0); }
void draw_char( void ) { static int first = 1; int i, j; if ( load_first ) { first = 1; load_first = 0; } if ( !first ) { putimage( 0 + align, 0, matrix_image, COPY_PUT ); } else { draw_grid( X, Y ); matrix_image = ( char * ) realloc( matrix_image, imagesize( 0 + align, 0, ( WIDTH_X + 2 )*X + align, ( WIDTH_Y + 2 )*Y ) ); getimage( 0 + align, 0, ( WIDTH_X + 2 )*X + align, ( WIDTH_Y + 2 )*Y, matrix_image ); } for ( j = 0; j < Y; j++ ) { for ( i = 0; i < X; i++ ) { if ( edit_font[i][j] ) { put_dot( i, j ); } else if ( first ) { square( i, j ); } } } first = 0; }
int main() { PIMAGE img; initgraph(640, 480); //先随便画一些东西 setcolor(EGERGB(0xFF, 0xFF, 0x0)); setfillcolor(EGERGB(0xFF, 0x0, 0x80)); fillellipse(50, 50, 50, 50); img = newimage(); getimage(img, 0, 0, 160, 120); //先画一个非黑色背景,以便于比较 setbkcolor(EGERGB(0x80, 0x80, 0x80)); cleardevice(); //四种贴图比较 putimage(0, 0, img); putimage_alphablend(NULL, img, 160, 0, 0x80); //半透明度为0x80 putimage_transparent(NULL, img, 0, 80, BLACK); //透明贴图,关键色为BLACK,源图为这个颜色的地方会被忽略 putimage_alphatransparent(NULL, img, 160, 80, BLACK, 0xA0); //同时使用透明和半透明 getch(); delimage(img); closegraph(); return 0; }
void bulletattack( int bullet[][2], int randx[][2], const bool decidex, IMAGE img ) { if( decidex == true ) { for( int x=0;x<20;x++ ) { if( bullet[x][1]<=384 && bullet[x][1]>=-36 ) { bullet[x][1]-=3; putimage( bullet[x][0], bullet[x][1], &img ); } } for( int x=0;x<100;x++ ) { for( int i=0;i<20;i++ ) { if( randx[x][1]>=0 && randx[x][1]<=480 && randx[x][0]<bullet[i][0]+5 && randx[x][0]>bullet[i][0]-40 && bullet[i][1]<randx[x][1]+40 ) { randx[x][1]=481; bullet[i][1]=600; } } } } }
void loadcar( int x ) { IMAGE img; loadimage( &img, _T("res/car.jpg")); putimage( x, 420, &img ); }
void prevent( int randx[][2], IMAGE img, const bool decidex, Player player, int counter, int subx, int x ) { int cnt=0; if( decidex == true && player.getspeed() != 0 ) { if( subx == x ) { for( ;cnt<100;cnt++ ) { if( randx[cnt][1]<=0 || randx[cnt][1]>480 ) break; } if( x>( ( x/320+1 )*320-40 ) ) { for( ;x>( ( x/320+1 )*320-40 ); ) x--; } if( x/320 == 0 ) randx[cnt][0]=x; else randx[cnt][0]=x+1; randx[cnt][1]=0; putimage( randx[cnt][0], randx[cnt][1], &img ); } } }
/* IF USER JUST RUNS THE PROGRAM, WAIT UNTIL 'ENTER' IS PRESSED TO FIND THE STARTING TIME */ void user_response(int x1,int y1,int col1,int col2) { void* ext; unsigned int size; int line, choice; size = imagesize(x1,y1,x1+110,y1+50); // calculate the size of the bar ext = malloc(size); // allocate memory to hold the current image to use later getimage(x1,y1,x1+110,y1+50,ext); // grab the image // WAIT FOR USER RESPONSE for(line=0;;line++) { draw_3dbox(x1,y1,x1+110,y1+50,col1); settextstyle(2,0,5); color_text(260,135,"Press ENTER",col2); color_text(275,155,"to START",col2); delay(500); putimage(x1,y1,ext,COPY_PUT); // blink delay(300); fflush(stdin); flushall(); if(kbhit()) choice=getch(); if(choice==13) //when Enter is pressed,lesson starts break; } free(ext); }
bonous() { ro=co=0; setfillstyle(1,4); ram1: co=random(1001); while(co>=40) { ro=ro+1; co-=40; } xc1=(co*15)+25; yc1=(ro*15)+20; for(v=0;v<=i;v++) { if((x[v]==xc1)&&(y[v]==yc1)) goto ram1; } if((xc==xc1)&&(yc==yc1)) goto ram1; for(v=0;v<=j;v++) { if((x2[v]==xc1)&&(y2[v]==yc1)) goto ram1; } setfillstyle(1,4); if((xc1<=610)&&(xc1>=25)&&(yc1<=380)&&(yc1>=20)) { putimage(xc1,yc1,f2,XOR_PUT); bon=1; } else goto ram1; return 0; }
int info_scene() { cleardevice(); setcolor(0xFFFFFF); Mira mira(640, 300); auto p_imagetext(newimage(440, 130)); char infostr[] = "欢迎使用Easy Graphics Enginge (EGE) V0.3.8 ,本库是一个面向新手,或者面向快速图形程序开发的图形库,使用方便快捷,容易上手,特别适合于新手学习图形程序设计。本程序为安装程序,如果你要继续安装,请按'y'键继续"; setcolor(0xFFFF, p_imagetext); setfont(18, 0, "宋体", p_imagetext); setbkmode(TRANSPARENT, p_imagetext); for(int i = 0; i < 8; ++i) { outtextrect(5, 5, 440, 280, infostr, p_imagetext); imagefilter_blurring(p_imagetext, 0xF0, 0x100); } setcolor(0xFF, p_imagetext); outtextrect(5, 5, 440, 280, infostr, p_imagetext); for(; kbhit() == 0; delay_fps(60)) { mira.update(); mira.render(0, 480 - 300); putimage(100, 50, p_imagetext); } delimage(p_imagetext); return getch(); }
void begin() { IMAGE img; initgraph(700,630); setbkcolor(GREEN); cleardevice(); loadimage(&img,"E:\\5.jpg"); putimage(0,0,&img); setcolor(RED); setfont(100,0,"华文行楷"); outtextxy(110,10,"聪明的小蛇"); setcolor(WHITE); setfont(70,0,"楷体"); outtextxy(10,130,"开始游戏"); setcolor(BROWN); setfont(70,0,"楷体"); outtextxy(10,230,"游戏规则"); setcolor(YELLOW); setfont(70,0,"楷体"); outtextxy(10,330,"关卡选择"); setcolor(BLUE); setfont(70,0,"楷体"); outtextxy(10,430,"得分排名"); setcolor(WHITE); setfont(70,0,"楷体"); outtextxy(10,530,"退出游戏"); }
int main() { int unidad = 0,modo,n; void *getmemoria(int),*p; initgraph (&unidad,&modo,"c:\\bc\\bgi"); if (graphresult() != 0) { cout << "Error al tratar de pasar al modo grafico\n"; getch(); return 1; } n = imagesize (0,0,8,8); if (n == 0) { outtextxy (0,10,"n es cero"); return 1; } if (graphresult() == -11) { outtextxy (0,20,"Error en imagesize() "); return 2; } outtextxy(0,0,"C"); p = getmemoria (n); getimage (0,0,8,8,p); getch(); setpalette (3,RED); setcolor (3); outtextxy(10,10,"C"); getch(); putimage (0,250,p,COPY_PUT); getch(); closegraph(); return 0; }
static int tmap_picture( /* tone map Radiance picture */ char *fname, register PICTURE *pp ) { uint16 orient; double paspect = (pp->rs.rt & YMAJOR) ? pp->pa : 1./pp->pa; int xsiz, ysiz; uby8 *pix; /* read and tone map picture */ if (tmMapPicture(&pix, &xsiz, &ysiz, flags, rgbp, gamv, lddyn, ldmax, fname, pp->fp) != TM_E_OK) return(-1); /* figure out TIFF orientation */ for (orient = 8; --orient; ) if (ortab[orient] == pp->rs.rt) break; orient++; /* put out our image */ if (putimage(orient, (uint32)xsiz, (uint32)ysiz, 72., 72./paspect, 2, pix) != 0) return(-1); /* free data and we're done */ free((void *)pix); return(0); }
void bird(int a, int b) { if(z==0) { int lwing[]={40,20,60,20,20,60,40,20}; int rwing[]={100,20,120,20,140,60,100,20}; int face[]={60,20,60,10,70,15,90,15,100,10,100,20,80,40,60,20}; setfillstyle(1,BLUE); fillpoly(4,lwing); fillpoly(4,rwing); fillpoly(8,face); unsigned int area=imagesize(20,1,140,60); buf= malloc(area); getimage(20,1,140,60,buf); delay(3000); z++; } if(kbhit()) { ch=getch(); delay(100); switch(ch) { case 'a': if(x==60) ; else x-=160; break; case 'd': if(x==540) ; else x+=160; break; } } putimage(a,b,buf,XOR_PUT); }
void restore_screen(FILE *fptr, unsigned size) { /* this function will display actual logo and then restore screen */ int ystart=19,yend,yincr,x; void far *ptr[3]; yincr=(465+1)/3; yend=yincr+ystart; for(x=0;x<=2;x++) { if((ptr[x] = farmalloc(size)) == NULL) { closegraph(); printf("Error: not enough heap size in restore_screen().\n"); exit(1); } fread(ptr[x],size,1,fptr); putimage(105,ystart,ptr[x],COPY_PUT); ystart=yend+1; yend+=yincr+1; farfree(ptr[x]); } }
Ventana::~Ventana() { if (Copia != NULL) { mouse.Esconder(); putimage (X,Y,Copia,COPY_PUT); delete Copia; mouse.Mostrar(); } }
void make_char_block_image( void ) { setcolor( 1 ); moveto( 4 + align, 30 ); lineto( X + 3 + align, 30 ); lineto( X + 3 + align, Y + 29 ); lineto( 4 + align, Y + 29 ); lineto( 4 + align, 30 ); char_block_image = ( char* ) realloc( char_block_image, imagesize( 4 + align, 30, X + 3 + align, Y + 29 ) ); getimage( 4 + align, 30, X + 3 + align, Y + 29, char_block_image ); putimage( 4 + align, 30, char_block_image, XOR_PUT ); }