Slicing up a sprite in-game

S

StanCoda

Guest
Hello! I'm making a game in which the player slices rectangles by dashing over them in one quick motion. Right now they're blank rectangles, more complicated sprites will be added later. Here's a quick example of the player slicing through one horizontally:


(Player clicks to the right of the rectangle, dashing through it, cutting it, and sending the two halves spiraling away)

My current solution is replacing the rectangle object with two "half rectangles", but here's the problem:
It looks great when the player cuts it at a perfect horizontal angle, but what if they bisect it at a slight angle? Or only cut off a corner? My question is THIS:

Can I somehow slice up a sprite in-game? It would be impossible to create sprites for every possible angle and location of possible cuts. I want a system that makes it possible to have cuts like this:

Does anyone know of a way to slice up a sprite in-game? I appreciate your feedback!
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Jobo did an extension on the MarketPlace that does exactly that. Probably under 'Extensions'.
Umm... and that helps the user how??? I mean, you don't even link to the extension! Pffff... seriously though, it's great to mention extensions and stuff, but if the user wants help with something you should at least try to suggest a solution to the problem rather than just a generic "marketplace" answer... Maybe they actually want to learn something? Do it themselves? ;)

Now, to the problem... The way you'd probably want to do it would be to EITHER use textured primitives and simply calculate the parts that are being "cut" and create a primitive for each, or to draw the main shape to a surface and then use sprite_create_from surface to create the parts that are being cut off.
 
S

StanCoda

Guest
Thank you both, this is exactly the solution I was looking for!!
 
Top