Sunday, October 30, 2022
HomeGame Developmentalgorithm - Numbering sprites in a sprite sheet left-to-right, top-to-bottom

algorithm – Numbering sprites in a sprite sheet left-to-right, top-to-bottom


I am utilizing this program referred to as Quadtastic which is a sprite sheet administration software that allows you to outline quads on a sprite sheet, title them, and so forth, and export to metadata with these names (+ place, measurement, and so forth). It has a function that mechanically numbers chosen quads from high left to high proper by sorting first by y axis after which by x.

Ideally I need my sprites numbered on this order:

Sprites connected by arrows running rightward along each row, then diagonally down to the leftmost sprite in the next row

Nevertheless, as a result of arbitrary measurement of the sprites in my sprite sheet, the sprite recognized as the highest left wasn’t the precise high left sprite. One other sprite on the identical row had a bigger bounding field than it and thus had a decrease y place which prompted it to get sorted earlier than the precise high left one (which was sorted as fifth)

I attempted to switch the supply code to strive a special algorithm the place I sorted by the gap of every quad’s high left nook to the highest left nook of the minimal bounding field of all the chosen quads (a rectangle that encompasses all of them). This considerably labored and was in a position to accurately type the highest left sprite as the primary however a bunch of others have been incorrect.

So, the place can I’m going from right here? I can not actually consider some other algorithms for sorting. If anybody has any concepts for different algorithms I might strive, that’d be nice!

And, if anybody is questioning, the code for the sorting might be discovered right here.

If you wish to run and take a look at algorithms your self you want the 32 bit model of Love 10.1. If you happen to get errors about an lfs.dll, take it from the shared folder within the repo and put it within the base listing of 32-bit Love 10.1, the place love.exe, is and you need to have the ability to run it.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments