1

I am attempting to make a 2D game in Pygame. Later I will convert it to kivy to deploy to mobile devices. I have searched many tutorials to get started, and I understand the basics of sprites/physics. However, I cannot find a tutorial that tells me HOW to find the location of a sprite from a sprite sheet. For example, a tutorial mentioned that I could use a drawing program to find the location of a sprite, but it didn't go into detail as to HOW you would find the location of a sprite on a large sheet of sprites.

Basically I have to find the x, y location of a sprite on a .png or .jpg spritesheet file.

For example, if I want to get the location of sonic running from a spritesheet in order to use that image my code would look like this:

       sonic_running = (589, 500, 80, 80)

The first two numbers in the tuple would be the x and y location of sonic in the spritesheet, and the last two numbers in the tuple would be the height and width of that sprite. But I have no idea how to find the x and y position of the sprite in the spritesheet, or the height and width of the sprite. If anyone has worked with pygame, or game creation i'd really appreciate the help. I hope that the question was detailed enough because I am still just starting out.

Simeon Ikudabo
  • 2,152
  • 1
  • 10
  • 27

1 Answers1

2

PyGame doesn't have any sprite sheet auto-detection functionality. I think the tutorial you were reading simply meant you'd have to find it by hand. For example, in MSPaint on Windows, the coordinates of the cursor are in the status bar at the bottom of the window. There isn't really any more magic than that.

If you're using sprites from an existing sheet you found, this may be tedious. If you're creating sprite sheets, I would imagine there are probably some tools to do this that export both an image and a text file with metadata. However I have not used these personally.

Blake O'Hare
  • 1,863
  • 12
  • 16
  • Thank you. This was helpful. It prompted me to find an online dimension finder, so I am able to load a .png spritesheet from my downloads, and then I’m able to select an image from the sheet and it tells me the coordinates of that image, and also the height and width of it. I was confused, but your response prompted me to use MSPaint at first and then find a program to make it a little bit easier. Thanks for the help! – Simeon Ikudabo Jan 19 '18 at 20:16