Spritesheet

Started by
2 comments, last by Dave Hunt 16 years, 6 months ago
Hello! Quick question; I have a spritesheet, all sprites are 16x16 and in multiple lines. I know the width and the height of the sheet. How would I do to get the coordinates of the n:th sprite?
Check out my devlog.
Advertisement
Assuming you number your sprites starting at zero being the upper-left:

int row = n / numSpritesPerRow;
int col = n % numSpritesPerRow;

int x = col * 16;
int y = row * 16;
Thank you!
Check out my devlog.
You're quite welcome.

This topic is closed to new replies.

Advertisement