Jump to content
  • Advertisement
Sign in to follow this  
shanelaffond13

Allegro and sprite sheets

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

Hi. My name is Shane and I am using Allegro to load a sprite sheet of 288 X 608. I am having trouble looping through the loading process. Here is my code: for( n = 0; n < 172; n++ ) { if( n == 9 || n == 18 || n == 27 || n == 36 || n == 45 || n == 54 || n == 63 || n == 72 || n == 81 || n == 90 || n == 99 || n == 108 || n == 117 || n == 126 || n == 135 || n == 144 || n == 153 || n == 162 || n == 171) y += 32; while(n < 172) { ground[n] = create_sub_bitmap( grnd, x, y, 32,32 ); } } Please help me. I don't know how to loop through this.

Share this post


Link to post
Share on other sites
Advertisement
That's some nasty brute force code. I'd do it more like this:


for( int n = 0; n < 172; n++ )
ground[n] = create_sub_bitmap(grnd, (n % 9) * 32, (n / 9) * 32, 32, 32);


Also, when you solve your own problem it would be good if you explained your solution. Someone else might be having a similar problem or might just be curious to see your solution.

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!