X $0t.c@\BTX ( @ (//(  0/80@0?/8 0( ?G@POWOXOP?H0@/7@O_``h_hPX 0(P_oppxow_g@O/8'' 7p`o?G/7 0??H/8`/o?GOX@H0?/pOW?H/8 7OP?G/7( P0@PX@O0@ 0O @H/@' 00@@P0?'_OP@H( 7/7' ^^^^^^^^^^^^^^^^^^^^^^^^^^TeeBBBBeTT^^^^^^^eBDJ33333JJDBeZ^^^^TD33==#####==3JDBT^^^^eJ=###=3DeZ^^TB3# #=3JBZ^^T3#  #=JBT^^J# Sll #=JBZ^T# %,68??86,/@A*< ##45('.6787-9%:;*<=#$+&,--.,/01)2 3 $%&&'%($!)* ##  !"#     ??d+r@sprite0  >xscb3 b^(fds@Q@:bMpÊVE'qkZ surface_floodfill_direct //surface_floodfill_direct(id,x,y) by Jonathan "SINAZ" Straw // //fills an area of color in the surface with the current //draw color. This script reads and writes directly to //the surface making it very slow. // //returns: // -1 := origin pixel already draw color // 1 := success! var q,xx,yy,ns,ws,es,ex,wx,fch,bch,oc,sh,sw; //explanation of variables: //q := node queue //xx := x value of seeker node //yy := y value of seeker node //ns := north/south bias of node //ws := west safe zone marker (x coordinate) //es := east safe zone marker (x coordinate) //wx := west seeker //ex := east seeker //fch := forward child boolean //bch := backward child boolean //sh := surface height //sw := surface width //oc := old color oc = surface_getpixel(argument0,argument1,argument2); if(oc == draw_get_color()) { return -1; } q = ds_queue_create(); ds_queue_enqueue(q,argument1); ds_queue_enqueue(q,argument2); ds_queue_enqueue(q,1); ds_queue_enqueue(q,argument1+1); ds_queue_enqueue(q,argument1-1); surface_set_target(argument0); sw = surface_get_width(argument0); sh = surface_get_height(argument0); while(ds_queue_size(q) != 0) { wx = ds_queue_dequeue(q); yy = ds_queue_dequeue(q); ns = ds_queue_dequeue(q); ws = ds_queue_dequeue(q); es = ds_queue_dequeue(q); fch = false; bch = false; ex = wx; while(surface_getpixel(argument0,wx - 1,yy) == oc && wx != 1)wx -= 1; while(surface_getpixel(argument0,ex + 1,yy) == oc && ex != sw - 1)ex += 1; //surface_set_target(argument0); draw_line(wx,yy,ex+1,yy); //surface_reset_target(); //screen_redraw(); xx = wx; while(xx <= ex) { if(yy - ns >= 0 && yy - ns < sh) { if(surface_getpixel(argument0,xx,yy - ns) == oc && fch = false) { fch = true; ds_queue_enqueue(q,xx); ds_queue_enqueue(q,yy - ns); ds_queue_enqueue(q,ns); ds_queue_enqueue(q,wx); ds_queue_enqueue(q,ex); } if(surface_getpixel(argument0,xx,yy - ns) != oc) { fch = false; } } if((xx < ws || xx > es) && (yy + ns >= 0 && yy + ns < sh)) { if(surface_getpixel(argument0,xx,yy + ns) == oc && bch = false) { bch = true; ds_queue_enqueue(q,xx); ds_queue_enqueue(q,yy + ns); ds_queue_enqueue(q,ns * -1); ds_queue_enqueue(q,wx); ds_queue_enqueue(q,ex); } if(surface_getpixel(argument0,xx,yy + ns) != oc) { bch = false; } } else { if(bch == true)bch = false; } xx += 1; } } surface_reset_target(); ds_queue_destroy(q); return 1;ds_grid_floodfill //ds_grid_floodfill(id,x,y,value) by Jonathan "SINAZ" Straw // //fills an area of the grid from origin //point x,y with value. // //returns: // -1 := origin cell already value // 1 := success! var q,xx,yy,ns,ws,es,ex,wx,fch,bch,ov,sh,sw; //explanation of variables: //q := node queue //xx := x value of seeker node //yy := y value of seeker node //ns := north/south bias of node //ws := west safe zone marker (x coordinate) //es := east safe zone marker (x coordinate) //wx := west seeker //ex := east seeker //fch := forward child boolean //bch := backward child boolean //sh := surface height //sw := surface width //ov := old value ov = ds_grid_get(argument0,argument1,argument2); if(ov == argument3) { return -1; } q = ds_queue_create(); ds_queue_enqueue(q,argument1); ds_queue_enqueue(q,argument2); ds_queue_enqueue(q,1); ds_queue_enqueue(q,argument1+1); ds_queue_enqueue(q,argument1-1); surface_set_target(argument0); sw = ds_grid_width(argument0); sh = ds_grid_height(argument0); while(ds_queue_size(q) != 0) { wx = ds_queue_dequeue(q); yy = ds_queue_dequeue(q); ns = ds_queue_dequeue(q); ws = ds_queue_dequeue(q); es = ds_queue_dequeue(q); fch = false; bch = false; ex = wx; while(ds_grid_get(argument0,wx - 1,yy) == ov && wx != 0)wx -= 1; while(ds_grid_get(argument0,ex + 1,yy) == ov && ex != sw - 1)ex += 1; ds_grid_set_region(argument0,wx,yy,ex,yy,argument3); xx = wx; while(xx <= ex) { if(yy - ns >= 0 && yy - ns < sh) { if(ds_grid_get(argument0,xx,yy - ns) == ov && fch = false) { fch = true; ds_queue_enqueue(q,xx); ds_queue_enqueue(q,yy - ns); ds_queue_enqueue(q,ns); ds_queue_enqueue(q,wx); ds_queue_enqueue(q,ex); } if(ds_grid_get(argument0,xx,yy - ns) != ov) { fch = false; } } if((xx < ws || xx > es) && (yy + ns >= 0 && yy + ns < sh)) { if(ds_grid_get(argument0,xx,yy + ns) == ov && bch = false) { bch = true; ds_queue_enqueue(q,xx); ds_queue_enqueue(q,yy + ns); ds_queue_enqueue(q,ns * -1); ds_queue_enqueue(q,wx); ds_queue_enqueue(q,ex); } if(ds_grid_get(argument0,xx,yy + ns) != ov) { bch = false; } } else { if(bch == true)bch = false; } xx += 1; } } ds_queue_destroy(q); return 1;surface_create_floodmask///surface_create_floodmask(id) by Jonathan "SINAZ" Straw // //creates a ds_grid to store and manage //a color mask of the surface // //returns: // grid id if(!surface_exists(argument0)) { show_error("surface_create_floodmask(): Surface with given ID does not exist!",1); } var g,w,h,i1,i2; w = surface_get_width(argument0); h = surface_get_height(argument0) g = ds_grid_create(w,h); for(i1 = 0; i1 < w; i1 += 1) { for(i2 = 0; i2 < h; i2 += 1) { ds_grid_set(g,i1,i2,surface_getpixel(argument0,i1,i2)); } } return g;surface_floodfill_mask //surface_floodfill_mask(id,x,y,grid) by Jonathan "SINAZ" Straw // //fills an area of color in the surface with the current //draw color. This script reads from a mask provided //by a ds_grid (grid) created using surface_create_floodmask //and writes the result directly to the surface. // //this is the most optimized way of drawing a visual //flood fill. // //returns: // -1 := origin pixel already draw color // 1 := success! var q,xx,yy,ns,ws,es,ex,wx,fch,bch,oc,sh,sw,g; //explanation of variables: //q := node queue //xx := x value of seeker node //yy := y value of seeker node //ns := north/south bias of node //ws := west safe zone marker (x coordinate) //es := east safe zone marker (x coordinate) //wx := west seeker //ex := east seeker //fch := forward child boolean //bch := backward child boolean //sh := surface height //sw := surface width //oc := old color //nc := new color //g := floodmask ds_grid oc = ds_grid_get(argument3,argument1,argument2); nc = draw_get_color() if(oc == nc) { return -1; } q = ds_queue_create(); ds_queue_enqueue(q,argument1); ds_queue_enqueue(q,argument2); ds_queue_enqueue(q,1); ds_queue_enqueue(q,argument1+1); ds_queue_enqueue(q,argument1-1); surface_set_target(argument0); sw = ds_grid_width(argument3); sh = ds_grid_height(argument3); while(ds_queue_size(q) != 0) { wx = ds_queue_dequeue(q); yy = ds_queue_dequeue(q); ns = ds_queue_dequeue(q); ws = ds_queue_dequeue(q); es = ds_queue_dequeue(q); fch = false; bch = false; ex = wx; while(ds_grid_get(argument3,wx - 1,yy) == oc && wx != 0)wx -= 1; while(ds_grid_get(argument3,ex + 1,yy) == oc && ex != sw - 1)ex += 1; //surface_set_target(argument0); draw_line(wx,yy,ex + 1,yy); ds_grid_set_region(argument3,wx,yy,ex,yy,nc); //surface_reset_target(); //screen_redraw(); xx = wx; while(xx <= ex) { if(yy - ns >= 0 && yy - ns < sh) { if(ds_grid_get(argument3,xx,yy - ns) == oc && fch = false) { fch = true; ds_queue_enqueue(q,xx); ds_queue_enqueue(q,yy - ns); ds_queue_enqueue(q,ns); ds_queue_enqueue(q,wx); ds_queue_enqueue(q,ex); } if(ds_grid_get(argument3,xx,yy - ns) != oc) { fch = false; } } if((xx < ws || xx > es) && (yy + ns >= 0 && yy + ns < sh)) { if(ds_grid_get(argument3,xx,yy + ns) == oc && bch = false) { bch = true; ds_queue_enqueue(q,xx); ds_queue_enqueue(q,yy + ns); ds_queue_enqueue(q,ns * -1); ds_queue_enqueue(q,wx); ds_queue_enqueue(q,ex); } if(ds_grid_get(argument3,xx,yy + ns) != oc) { bch = false; } } else { if(bch == true)bch = false; } xx += 1; } } surface_reset_target(); ds_queue_destroy(q); return 1;font0Arial object0 [6surf = surface_create(256,256) surface_set_target(surf); draw_clear(c_black); for(i1 = 0; i1 < 256; i1 += 1) { for(i2 = 0; i2 < 256; i2 += 1) { draw_point_color(i1,i2,choose(c_black,c_white)); } } surface_reset_target(); grid = ds_grid_create(1,1); mode = 1; modetext = "direct"; 00000006[Gshow_message("Select a fill method. #Current method is "+modetext+"#Click OK to continue to menu.") mode = show_menu("flood mask|direct",1); if(mode = 0) { modetext = "flood mask"; ds_grid_destroy(grid); show_message("Flood mask will take a few moments to generate. Click OK and be patient."); grid = surface_create_floodmask(surf); show_message("DONE! #With a flood mask generated, the fills occur much faster!"); } else { modetext = "direct"; show_message("Directly flood filling a surface is slow due to the nature of reading colors from a surface.") }00000005[if(draw_get_color() = c_black) { draw_set_color(c_white); } else { draw_set_color(c_black); } if(mode = 0) { surface_floodfill_mask(surf,mouse_x,mouse_y,grid); } else { surface_floodfill_direct(surf,mouse_x,mouse_y); }0000000[Ddraw_surface(surf,0,0); draw_sprite(sprite0,0,mouse_x,mouse_y); 0000000room0 show_info();        XGame InformationX'{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}{\f1\fnil Arial;}} {\colortbl ;\red0\green0\blue0;} \viewkind4\uc1\pard\cf1\fs24 Left click = Flood fill (the fill color toggles, so if no visible effect occurs, click again to try the toggled color.) \par \par Right click = Change fill mode. \par \par Credits go to Jonathan "JD" Straw aka SINAZ \par \par Use freely, credit appropriately. For questions and comments, PM me at the Game Maker forums. \par \par (close the info window to begin!)\f1 \par } Spritessprite0Sounds BackgroundsPathsScriptsds_grid_floodfillsurface_floodfill_directsurface_create_floodmask surface_floodfill_mask Fonts font0 Time LinesObjectsobject0Roomsroom0 Game Information Global Game Settings