Jump to content
  • Advertisement
Sign in to follow this  
VersionEleven

SDL Won't Show The Whole Image During Animation

This topic is 4417 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 have been looking for an API/Engine that best suited my venture into 2D game programming. The SDL API proved most useful to me along the lines of it's ease of use, and capabilities. And everything went smoothly until I began to animate the sprites. Using the source code from this tutorial, though altering it to handle my image's size, and location. It compiled fine, and seemed to work fine until I triggered a movement. Then, instead of showing the whole sprite in the location of the image I specified, it only showed half of it, and half of the sprite that was behind it. It moved across the screen, so the only problem seems to be that it doesn't display it properly. If anyone would have an idea what the problem is, and could inform me how to fix it then I would greatly appreciate it. Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Double check the offsets of the clip rectangle you set when you handle key events.

I don't really like that guy's method though. Here's mine. Instead of using one clip rect and moving it around I just make a bunch of them and clip the sprite sheet once.

Share this post


Link to post
Share on other sites
Yours was easier to understand, and I was able to use it. Thanks. Though, I encountered another problem. I tried to make "a" trigger a punch animation. I used the same code as the left-right animations. Except I didn't use velocity as the integer, so that it didn't slide across the screen. It wouldn't display it when I pressed "a". Though when I changed: apply_surface( offSet, SCREEN_HEIGHT - FOO_HEIGHT, foo, screen, &clipsPunch[ frame ] ); to: apply_surface( offSet, SCREEN_HEIGHT - FOO_HEIGHT, foo, screen, &clipsPunch[ 1 ] ); it did. Only problem was that it didn't loop. How would I do this the way the left-right animations worked? Your help would again be appreciated.

Share this post


Link to post
Share on other sites
Quote:
Original post by VersionEleven
Yours was easier to understand, and I was able to use it. Thanks. Though, I encountered another problem. I tried to make "a" trigger a punch animation. I used the same code as the left-right animations. Except I didn't use velocity as the integer, so that it didn't slide across the screen. It wouldn't display it when I pressed "a". Though when I changed: apply_surface( offSet, SCREEN_HEIGHT - FOO_HEIGHT, foo, screen, &clipsPunch[ frame ] ); to: apply_surface( offSet, SCREEN_HEIGHT - FOO_HEIGHT, foo, screen, &clipsPunch[ 1 ] ); it did. Only problem was that it didn't loop. How would I do this the way the left-right animations worked? Your help would again be appreciated.


After you're finished with punch animation you have set the animation to the first frame of the walking animation.

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!