Sign in to follow this  
rootoutcast

SDL Animation when using large sprite sheets

Recommended Posts

rootoutcast    101
Hi everyone I am new to gamedev.net, I am working on a super mario style game. I have used sites such as lazyfoo.net and sdltutorials.com. to get information. The problem I am trying to solve is that I have a sprite image each frame for the sprite is 64x64 pixels the sheet is set up in 5 columns the rows are for each animation state such as standing, walking and jumping all have a different number of frames depending on what the animation is.

From Looking at lazyfoo's site his animation tutorial looks like you have to set the position of each frame individually. My image has 64 frames of animation. I am looking for another way of cliping the sprites.

Share this post


Link to post
Share on other sites
You could calculate the clip rects using math, and wrap it in a function.
[CODE]
rect.x = (column * SpriteWidth)
rect.y = (row * SpriteHeight);
rect.w = SpriteWidth;
rect.h = SpriteHeight;
[/CODE]

Several years ago, I created a single header file that wraps it all for you providing convenience functions.
[size=5][[url="http://www.gamedev.net/topic/533909-sdl_tileset/"]SDL_tileset[/url]][/size]

That thread's formatting has deteriorated with time, but the [url="http://www.mediafire.com/?mld1dkm2zrm"]download link[/url] still works. If you have any questions, just ask.

Share this post


Link to post
Share on other sites
eppo    4877
If you're on D3D10+ hardware, you might want to use texture arrays (as long as all sprites are the same size) as they prevent filtering artifacts between neighboring sprites.
Instead of cutting sprites out of a sheet in a shader you can do it at load-time. Edited by eppo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this