/* * * (c) 2019 Sollia 3 */ PROGRAM texturemaps; global rgb; struct quad[2] x,y,s; struct point[3]; x,y; handle; end end quads = 1; struct texture[2] x,y, s, map, w,h; struct coord[3] x,y; end end // VORTIGANO ********************************* list_id_handles[3]; // END *************************************** w,h; tx[3]; ty[3]; tl[3]; qx[3]; qy[3]; ql[3]; vmx; vmy; oldmx; oldmy; local i,j; pressing; // VORTIGANO ********************************* // REPLACES PRIVATE HANDLE "GOT" got_enable; // END *************************************** private texture_id[2]; begin set_mode(m1024x768); set_fps(60,0); // VORTIGANO ******************************************************************************************* x_mouse(); // END **** ******************************************************************************************* write_int(0,10,700,0,&fps); rgb = load_fpg("rgb.fpg"); mouse.graph = 4; mouse.x = 700; define_region(1,0,0,512,512); draw(3,114,15,1,0,0,512,512); draw(5,1,15,1,255-52,255-52,255+52,255+52); for(i = 255; i>24; i-=22) draw(4,1,15,1,255-i,255-i,255+i,255+i); end draw(5,114,15,1,255-11,255-11,255+11,255+11); draw(4,114,15,1,255-33,255-33,255+33,255+33); frame; texture.map = new_map(512,512,0,0,114); screen_copy(1,0,texture.map,0,0,512,512); delete_draw(all_drawing); put(rgb,texture.map,0,0); w = graphic_info(rgb,texture.map,g_wide); h = graphic_info(rgb,texture.map,g_height); for(i = 0; iw-32) texture.x = 32; end texture.y+=4*(key(_down)-key(_up)); if(texture.y<32) texture.y = h-32; end if(texture.y>h-32) texture.y = 32; end //end pressing = key(_right) or key(_left) or key(_up) or key(_down); texture.coord[0].x = texture.x-texture.w/2; texture.coord[0].y = texture.y-texture.h/2; texture.coord[1].x = texture.x+texture.w/2; texture.coord[1].y = texture.y-texture.h/2; texture.coord[2].x = texture.x+texture.w/2; texture.coord[2].y = texture.y+texture.h/2; texture.coord[3].x = texture.x-texture.w/2; texture.coord[3].y = texture.y+texture.h/2; texture_id[0] = paintTexture(0); // texture_id[1] = paintTexture(1); // texture_id[2] = paintTexture(2); tex(0,texture_id); // tex(1,texture_id[1]); // tex(2,texture_id[2]); drawTextureArea(0); frame; unload_map(texture_id); unload_map(texture_id[1]); unload_map(texture_id[2]); delete_draw(all_drawing); vmx = mouse.x-oldmx; vmy = mouse.y-oldmy; oldmx = mouse.x; oldmy = mouse.y; end exit(0,0); end process tex(q,graph) begin x =quad[q].x; y =quad[q].y; xput(rgb,graph,quad[q].x,quad[q].y+200,0,200,0,0); frame; end // VORTIGANO ******************************************************************************************* process x_mouse() private id_buffer; id_list[3]; // 3 is the number of circles. n_colisiones; var_x; salir_repeat; proteccion_de_interacciones; id_cache; id_index; catched; n_elementos=3; // 3 is the number of circles begin graph = new_map(1,1,0,0,1); flags =4; loop x = mouse.x; y = mouse.y; id_buffer =0; n_colisiones =0; salir_repeat =0; repeat (id_buffer=collision(type handle)); if (id_buffer!=0) id_list[n_colisiones] = id_buffer; n_colisiones++; end for(var_x=0; var_x0 && proteccion_de_interacciones==0) for(var_x=0, id_cache = id_list[var_x]; var_xquad[idq].s) quad[idq].point[idp].x = quad[idq].s; end quad[idq].point[idp].y+=vmy; if(quad[idq].point[idp].y<-quad[idq].s) quad[idq].point[idp].y = -quad[idq].s; end if(quad[idq].point[idp].y>quad[idq].s) quad[idq].point[idp].y = quad[idq].s; end if (not mouse.left) got_enable =0; end end frame; end end function paintTexture(t) private pix; px,py; rpx[2]; rpy[2]; image; begin image =new_map(64,64,31,31,10); for(i = 0; i<4; i+=1) tx[i] =texture[t].coord[i].x; ty[i] =texture[t].coord[i].y; qx[i] =quad[t].point[i].x; qy[i] =quad[t].point[i].y; end for(i = 0; i<4; i+=1) tl[i] = fget_dist(tx[i],ty[i],tx[(i+1)%4],ty[(i+1)%4]); ql[i] = fget_dist(qx[i],qy[i],qx[(i+1)%4],qy[(i+1)%4]); end for(i = 0; i