Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

The wonderful headaches of precision sprite animation

Sign in to follow this  


Well, I was hoping to have already been working on the demo for the comic book convention by this point for Barricade, but time flows a lot faster then I would like in a day, or at least it'd be nice to

A. Have enough wealth so I wouldn't have to work to earn a pay check for the rest of my life, I could dedicate my time to that which I wanted(I'm working towards this one.)

B.Had more hours in a day.

C. Could manipulate time with my mind so that I could get more accomplished.(I'm working on this one also)

So, I'm not really that far behind schedule all things considered. Only a couple of weeks of what I was shooting for to get done in the month of march, but now I'm running into some other issues, that I recently had to solve, and are in the process of now being resolved.

The main issue, had to do with animations for my sprite class. I have no idea how other people handle this in their code. I haven't bothered to ask or do research, but the way I've been handling it is simply loading a sprite sheet into memory as one texture and then mapping the sections with the individual frames to be shown at the appropriate time.

Some pseudo code might look like

Call to Animate Looks like

advance function hit count
get active frame

if enough hits have taken place advance the active frame number

for frame one show these texture coordinates

for frame two show these coordinates


My actual codes a lot better structured and is organized object orientedly and works great. The problem is that when I go to manually map my textures in my current editor
(I'm concurrently building a new editor as these issues and the demo are being built)
I have to go in and manually manipulate the textures for the frames to show up correctly on the quads. This is where I'm sure it isn't the best approach, but I don't really know another one, (Aside from having the graphics artist create the sprite sheets very precisely, which seems to be as much trouble as I'm having on my end anyways.)There are slight shifts in the textures do to slight shifts in the textures when I'm going in to map them, and while the anomalies are small and would even possibly be unnoticeable to someone playing the game, they are pretty damn obvious to me.

The solution I've come up with thus far is to increase the precision of movement for mapping the textures and also come up with a more precise grid for aligning the texture on the quad. I'll be trying this out in the next couple of days when I have a little bit of time this weekend.

If anyone out there can make some suggestions or offer any similar experiences up, I would be thankful, although I'm not sure if anyone ever reads this anyways, but if you do thanks in advance for the comments.
Sign in to follow this  


Recommended Comments

Hey Decipher,

I feel your pain about handling sprite management issues. I doubt I can offer much advice that would be useful, but I'll explain how I do it.

Typically, every entity has a resource object (sprite) type. The sprite is a combination of graphical and textual information. Multiple entities can use the same sprite, so sprites are always loaded as needed by a level as a singleton.

What a sprite consists of, is a data file and then multiple sprite sheets. For my game, sprites can be rendered in 8 directions in up to 12 animations with a max of 12 frames per animation. Typically I give each animation its own sprite sheet, which contains the frames for all 8 directions (like impwalk.png, impidle.png, etc.)

The data file details what animations this particular sprite can do. So some entities can do all 12 animations, whereas some only have one or two. The data file also contains the number of frames per animation, and the texture coordinates per animation type. This is somewhat restrictive requiring a general frame size for every frame in a given animation (but flexible in that different animations have different frame sizes). This file also contains the timestep for each frame of the animations. With the most complex characters, this text file becomes quite lengthy (but easy to alter).

When the time comes to render the sprite, the entity passes in its current direction and current frame number and state(frames are incremented according to the timesteps and clamped by the frame definitions -- all scripted).

I do all the scripting of these files by hand according to info my artist gives me, who sets up the actual sprite sheets with Lightwave (perhaps he wrote a script for this, I'll ask him).

That probably does you no good, sorry. But perhaps there is one tiny sliver of helpful information.

Another note: I really want to write a tool similar to yours, which automates the script creation process. Time will tell.

Good luck, and for reference, the sprites for Fireheart are currently spread out over 37 sprite sheets for the first five characters =)

Share this comment

Link to comment
Mas Informacion:

Turns out David uses image magick to align the sprites on a single texture. A link he provided:

He also mentioned using the 'montage' feature, and I have a copy of the .bat file he uses, which you have if you want. You would just have to alter the geometry.

Perhaps that is more useful =)

Share this comment

Link to comment

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
  • 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!