Jump to content
  • Advertisement
Sign in to follow this  
subflood

more than one sprite in single file

This topic is 4846 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What is the point of having more than one sprite in a single file? For example, right now I'm looking at the graphics a simple breakout game has (open source) and I open up a ball.png and see it has 6 different color balls. What is the point of doing this and if you can how could you use this is the game. The source code is pretty hard for me to read as I'm still a newbie to game programming so, I can't just figure this out from the code.

Share this post


Link to post
Share on other sites
Advertisement
The use is so you won't have 10000 files for the sprites.
It's also faster to load a file and take the sprites from it, rather than open 10000 different files.

Share this post


Link to post
Share on other sites
Ok, I understand that but how can you take one individual sprite from multiple ones that are in a single file? By the way I use OpenGL if it makes a difference if I'm using one API or another.

Share this post


Link to post
Share on other sites
You just load the file in the memory, and the determine the x and y in the texture depending on how the sprites are organized and such.
You can empirically determine the x and y of each sprite using Photoshop or something (the grid option can be useful).

Share this post


Link to post
Share on other sites
Thanks!

One more question, if you need to have a background in your game such as breakout would it be more efficient to load an 800 x 600 picture to memory or use a smaller version of the picture but draw it to the screen multiple times but in different places, kinda like tiles.

Share this post


Link to post
Share on other sites
In OpenGL it's always better to render one texture rather than 10 textures.
But anyway, take care, openGL, by default, doesn't like textures with sizes that are not powers of 2.

Share this post


Link to post
Share on other sites
Drawing a bunch of the same (smaller) size tile is more efficient because you're using less memory, but the drawbacks are that it doesn't look as good (usually) and can be slower depending on your implementation.

When you have a lot of sprites in one file the load time for your game can improve dramatically. I had a LOT of sprites and combining them probably made my game load 350% faster.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!