Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've been working on an item system for a post-apocalyptic RPG, with diablo as inspiration, and it would be awesome if I could visually represent an item that can be equipped on the player sprite. I was thinking you could have a player sprite with certain animations, then the equipped item would be drawn as if it was on the player with the same animations, so it syncs with the player animations but that couldn't work very smoothly, I imagine there's a better system.

How can you graphically represent an item worn on the player, which moves like he does, and looks as if he's wearing it? I'm not asking you how to do it in framework X or platform X (altho if you REALLY need it, I'm using Allegro 5 with codeblocks on win XP) but instead I'm asking you how to generally program such an idea.

share|improve this question
    
Are your character models 3D or pre-rendered 2D sprites? –  Krom Stern Sep 11 '12 at 8:37
    
They're sprites drawn by hand. –  Bugster Sep 11 '12 at 11:24
add comment

1 Answer

up vote 3 down vote accepted

(I assume you're talking 2D here since you talk about sprites)

One solution would be to use 2D skeletal animations. You define animations not by successive frames in a sprite but by chopping up the character in bones and then you express how each bone should move in a certain animation. Each bone has it's own sprite that moves with the bone (note that you can still animate these sprites).

Wearable items could be implemented as a new sprite for one or several bones. Or you could attach multiple sprites to a bone. For example you have a thigh bone and a sprite for the thigh. You now want to add a holster. Create a new holster sprite and attach it somewhere at the the thigh bone. In the game you first draw the thigh-sprite based on the position of the thigh-bone and then you draw the holster, also transformed with respect to the thigh-bone over the thigh-sprite. You now have a layering/attachment system that should be easy to work with. Note that when you change your animations all you have to do is change the movements of the bones, all sprites will just stick on and work like before. This makes changing animations easy. Don't go for a solution where changing an animation would cause you to have to update dozens of sprites.

I also did some googling to see if there are some useful references out there. It seems some people have made a few skeletal animation samples for Allegro here and there even seems to be a very nice editor for skeletal animations in allegro.

share|improve this answer
    
That's fantastic, thanks. –  Bugster Sep 11 '12 at 11:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.