Make a rect based on image

spikes
In the image the spikes are on different parts of the 16x16 image to fit on a wall properly. But I don’t understand how I would make a hitbox in the correct position without a lot of unclean code of me manually moving and changing size for every single type of spike. Any way to make a rect using pixels that aren’t transparent on the image or something?

Your question is not that clear to me, so I may be misunderstanding, but assuming you’re wanting a method to create rects representing “regions of non-transparent pixels” or some such; you could loop through each pixel in the texture (texture.GetData), test its transparency, and either create or modify (if it is touching an existing one) a rect in a list. Ending up with a list of rects that represents all continuous regions of a texture that have non-transparent pixels (in at least one spot in each row/column of the given rects).