Jump to content
• Advertisement

# Allegro and sprite sheets

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

##### Share on other sites
Advertisement
Thanks anyway. I figured this out.

#### Share this post

##### Share on other sites
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

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5
• Advertisement

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013294
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!