Jump to content
  • Advertisement
Sign in to follow this  
lodoss118

whats the algorithm used to resize sprite depending on the screen size /resoultion?

This topic is 3993 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

I was wondering what type of forumlae is used to do this? as i want my sprites to increase in size if resolution gets bigger or maintain the ratio?

Share this post


Link to post
Share on other sites
Advertisement
width *= new_x_res / old_x_res;
height *= new_y_res / old_y_res;

Of course, you need to have some base resolution to go by. If your sprites aren't built specific to some resolution, or the game doesn't know what that resolution is, then it would be hard to determine the original size, much less the adjusted one.

Share this post


Link to post
Share on other sites
Make sure you use floats for your intermediate results, otherwise you'll get very strange results (assuming widht and height are ints):

width = (int)((float) width * (float)new_x_res / (float)old_x_res);
height = (int)((float) height * (float)new_y_res / (float)old_y_res);

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!