Archived

This topic is now archived and is closed to further replies.

Quino

Character animations?

Recommended Posts

Quino    122
Hello all, I have an alright skill with opengl, and would prefereably liek to know how to do this: How can i load multiple character animations from one picture? Like, with little fighter 2( www.lf2.com i do beleive), It gives you the pictures of the sprites. each picture has about 25 o so poses, and I was wondering, how do they load each pose and make animations out of it? I have a few ideas, but I cant quite code them, and also, i wouldnt mind if anyone out there could tell me how? I think it is just loading textures from different parts of the picture, but how would i load from a specific part of the picture?????? It would REALLY help with my hand drawn 2d rpg sidescroller (like legend of mana ) Whoever helps me, i could try to return a favour, cause this is VERY important to me and crucial to continue coding my game

Share this post


Link to post
Share on other sites
BGCJR    100
using tex coordinates to split an image into 'tiles'
then draw the quad with the correct texture coordinates for each animation frame.

That's a ummm simple way...

or use a program like PhotoShop and split the pic into smaller pics of each animation. then look each as 64x64 textures and simply bind the right texture for the next animation to draw.


Bobby

[edited by - BGCJR on August 4, 2003 12:31:05 AM]

Share this post


Link to post
Share on other sites
Krohm    5030
I vote for the first method (load up as a single texture and use texcoords to split frames). This is going to be faster than using multiple textures and does not look too difficult.

Share this post


Link to post
Share on other sites
Hawkeye3    122
Using one large file is faster, too. Because then you don''t have to re-bind the texture if you are going to draw the same sprite again, say for multiple monsters.

Share this post


Link to post
Share on other sites
Quino    122
Thanks guys! Could maybe i see some sample code for this though? i dont know how to split up the image to tiles, Im using vc++ with opengl, so, if you could, that would be awesome

Edit: erm... well, how could i move the picture around for the diff images of the monster chars, bushes etc. etc.?

[edited by - Quino on August 5, 2003 9:11:06 PM]

Share this post


Link to post
Share on other sites
BGCJR    100
some psuedo code:



glBindTexture(GL_TEXTURE_2D,tilepic);
glEnable(GL_TEXTURE_2D);
bool DrawFrame=true;
int frame = 0;

if (DrawFrame)
{
float row,col;
float adjust = 1/width_of_texture.
row = (int)(frame/10);
col = (int)(frame-(row*10));
row *= adjust;
col *= adjust;

glColor3f(1,1,1);
glBegin(GL_QUADS);
glTexCoord2f(col,row);
glVertex2f(position.x,position.y);
glTexCoord2f(col+texcoordwidth,row)
glVertex2f(position.x+tilewidth,position.y);
glTexCoord2f(col+texcoordwidth,row+texcoordheight);
glVertex2f(position.x+tilewidth,position.y+tileheight);
glTexCoord2f(col,row+texcoordheight);
glVertex2f(position.x,position.y+tileheight);
glEnd();
}




[edited by - BGCJR on August 5, 2003 9:50:43 PM]

Share this post


Link to post
Share on other sites