//----------- Begin of function TerrainRes::init --------// //! void TerrainRes::init() { if ( init_flag ) return; //----- read info from TERRAIN.DBF ------// load_info(); //---- open bitmap resource of different resolutions ----// load_res( ZOOM_SMALL , "TERRA", "S" ); load_res( ZOOM_MEDIUM, "TERRA", "M" ); load_res( ZOOM_LARGE , "TERRA", "L" ); //----------------------------------------// init_flag=1; }
//----------- Begin of function PlantRes::init --------// //! void PlantRes::init() { if ( init_flag ) return; //----- read info from PLANT.DBF ------// load_info(); //---- open bitmap resource of different resolutions ----// load_res( ZOOM_SMALL , "PLANT", "S" ); load_res( ZOOM_MEDIUM, "PLANT", "M" ); load_res( ZOOM_LARGE , "PLANT", "L" ); //----------------------------------------// init_flag=1; }
int main(){ init(); load_res(); SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); SDL_RenderClear(renderer); render_sprite(sprite_sheet, 0, 0, &sprite_sections[0]); render_sprite(sprite_sheet, WIDTH - 100, 0, &sprite_sections[1]); render_sprite(sprite_sheet, 0, HEIGHT - 100, &sprite_sections[2]); render_sprite(sprite_sheet, WIDTH - 100, HEIGHT - 100, &sprite_sections[3]); SDL_RenderPresent(renderer); SDL_Delay(3000); quit(); return 0; }
//--------------------------------------------------------------------------- bool hxc_scrollbar::create(Display*d,Window daddy,int x,int y, int w,int h,LPHXC_SCROLLBARNOTIFYPROC pass_notifyproc){ if (XD!=NULL) destroy(this); XD=d; parent=daddy; notifyproc=pass_notifyproc; load_res(XD); XSetWindowAttributes swa; swa.backing_store=NotUseful; swa.background_pixel=col_border_light; handle=XCreateWindow(XD,parent,x,y,w,h,0, CopyFromParent,InputOutput,CopyFromParent, CWBackingStore|CWBackPixel,&swa); hxc::x=x;hxc::y=y;hxc::w=w;hxc::h=h; SetProp(XD,handle,cWinProc,(DWORD)WinProc); SetProp(XD,handle,cWinThis,(DWORD)this); XSelectInput(XD,handle,KeyPressMask|KeyReleaseMask| ButtonPressMask|ButtonReleaseMask| Button1MotionMask|Button2MotionMask| ExposureMask|StructureNotifyMask); if(horizontal){ UpBut.create(XD,handle,0,0,arrowheight,h,button_notify_proc,this,BT_ICON | BT_HOLDREPEAT,"",-1,col_grey); DownBut.create(XD,handle,w-arrowheight,0,arrowheight,h,button_notify_proc,this,BT_ICON | BT_HOLDREPEAT,"",1,col_grey); UpBut.set_icon(NULL,2); DownBut.set_icon(NULL,3); }else{ UpBut.create(XD,handle,0,0,w,arrowheight,button_notify_proc,this,BT_ICON | BT_HOLDREPEAT,"",-1,col_grey); DownBut.create(XD,handle,0,h-arrowheight,w,arrowheight,button_notify_proc,this,BT_ICON | BT_HOLDREPEAT,"",1,col_grey); UpBut.set_icon(NULL,0); DownBut.set_icon(NULL,1); } XSetForeground(XD,gc,col_black); XMapWindow(XD,handle); return false; }
//--------------------------------------------------------------- bool hxc_buttonpicker::create(Display *d,Window daddy,int x,int y,int w,int h, LPHXC_BUTTONPICKERNOTIFYPROC pass_notifyproc,void *o,int pass_ID) { if (XD) destroy(this); XD=d; parent=daddy; notifyproc=pass_notifyproc; id=pass_ID; owner=o; load_res(XD); XSetWindowAttributes swa; swa.backing_store=NotUseful; swa.background_pixel=col_bk; handle=XCreateWindow(XD,parent,x,y,w,h,0, CopyFromParent,InputOutput,CopyFromParent, CWBackingStore | CWBackPixel,&swa); hxc::x=x;hxc::y=y;hxc::w=w;hxc::h=h; if (handle==0){ XD=NULL; return 0; } SetProp(XD,handle,cWinProc,DWORD(WinProc)); SetProp(XD,handle,cWinThis,DWORD(this)); XSelectInput(XD,handle,ButtonPressMask | ButtonReleaseMask | ExposureMask | StructureNotifyMask | FocusChangeMask | EnterWindowMask | LeaveWindowMask | KeyPressMask | KeyReleaseMask); XMapWindow(XD,handle); return true; }
int main(){ init(); load_res(); SDL_Event event; Uint8 red = 255, green = 255, blue = 255; bool color_on = true; SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF); SDL_RenderClear(renderer); SDL_RenderCopy(renderer, color_wheel, NULL, NULL); SDL_RenderPresent(renderer); bool loop = true; while(loop) { while(SDL_PollEvent(&event) != 0) { if(event.type == SDL_QUIT) { loop = false; } if(event.type == SDL_KEYDOWN) { switch(event.key.keysym.sym) { case SDLK_SPACE: color_on = !color_on; break; case SDLK_q: red += 32; break; case SDLK_a: red -= 32; break; case SDLK_w: green += 32; break; case SDLK_s: green -= 32; break; case SDLK_e: blue += 32; break; case SDLK_d: blue -= 32; break; case SDLK_r: red = 255; green = 255; blue = 255; break; case SDLK_ESCAPE: loop = false; default: break; } red = clamp(red); green = clamp(green); blue = clamp(blue); if(color_on) { SDL_SetTextureColorMod(color_wheel, red, green, blue); printf("< R%03d G%03d B%03d >\n", red, green, blue); } else { SDL_SetTextureColorMod(color_wheel, 255, 255, 255); printf("< R255 G255 B255 >\n"); } } } SDL_RenderClear(renderer); SDL_RenderCopy(renderer, color_wheel, NULL, NULL); SDL_RenderPresent(renderer); } quit(); return 0; }