• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [Solved] Tiling an image inside a sprite shape...

Roastedzerg

Member
Hey guys, im trying to create a corpse pile in my game that i can stretch to any size, then use the objects draw function to fill the shape with a background image (or sprite) in a tile method, staying inside the shape.
How would one go about doing this? Is it a simple function i can punch into the draw event of said object?

More details:
The shape:


The Texture (which i will obviously need to still make tileable):


The desired result (and able to do this with a corspe pile larger than the given texture through tiling):
or


Hope this helps
 
Last edited:
W

whale_cancer

Guest
Is it a simple function i can punch into the draw event of said object?
No.
How would one go about doing this?
You can either add tiles dynamically to an area or draw sprites using an object. The sprite method is more costly in terms of performance.
background image (or sprite) in a tile method
I am not 100% sure what you mean by in a 'tile method'; do you mean tiling as in the appearance changes depending on adjacent instances, tiles, or what not?
staying inside the shape
Simply set a min and max y and x value depending on where you want the bodies to go; alternatively, you could use something like a grid to denote legal positions for the bodies to be placed.

TBH, though, I am not 100% on what you want your end goal to look like.
 

Mike

nobody important
GMC Elder
Look into destination alpha. Create a surface of the size of your sprite, clear it with 0 alpha (switching off blending and alpha test to do so), draw the sprite, then use "bm_dest_alpha" or "bm_inv_dest_alpha" to use the surface alpha and clip to your sprite shape.
 

Roastedzerg

Member
Thanks for the replies, Im doing some research now based off what you've given me.

But i think there might still be some confusion, so allow me to throw up some examples of what im wanting to do

The shape:


The Texture (which i will obviously need to still make tileable):


The desired result (and able to do this with a corspe pile larger than the given texture through tiling):
or


Hope this helps
 
Last edited:

Roastedzerg

Member
Hey thanks for the help guys, after some research i was able to find a solution using the following code-

Code:
///Placed in draw event
if(!surface_exists(surf)){surf=surface_create(sprite_width,sprite_height);}
surface_set_target(surf);
draw_clear_alpha(c_black,0);
draw_sprite_ext(sprite_index,image_index,sprite_xoffset,sprite_yoffset,image_xscale,image_yscale,image_angle,image_blend,image_alpha);
draw_set_colour_write_enable(1,1,1,0);
draw_sprite_tiled(spr_corpse_pile_texture,0,0,0);
draw_set_colour_write_enable(1,1,1,1);
surface_reset_target();
draw_surface(surf,x-sprite_xoffset,y-sprite_yoffset);
However, i also found i would be better off simply creating multiple sizes of corpse piles then layering them to give the illusion of one big mound of bodies. But theres the working code for anyone who might find it useful. (Dont forget to put surface_free(surf) in the destroy and room end event)

Thanks again GMC :)

(Also, how do i set this post as the answer post like i could in the legacy forums?)
 
Top