Creating short animations?

Im working on a 2d rpg game that follows the basic game loop idea below:

void gameLoop(){

while(player.alive()){

updateWorld()

paintWorld()

sleep(30);

}

}

So anyway, my question is this, what is the best way for implementing short animation. Basically when the player attacks another entity or viceversa, i want to display a attack animation such as an explosion, or a blood spray, on the opposing enemy.

The best i can come up with is using a counter like this..

/* Represents any character object in the game*/

class Character{

public void paint(graphic g){

if(hit && counter > 0){

g.draw(bloodGraphic);

counter--;

}

}

}

This seems like a crappy way of doing it. I don't really want the character classes to have to have to worry about how to paint the attack animations. Because there could be any number of different attack animations, all with different lengths. but im not quite sure how else to go about it. Any suggestions would be appreciated.

[1091 byte] By [mlopresa] at [2007-10-3 3:08:38]
# 1
Yeah, I'd start with the basics first. Make sure you understand the game loop better. I recommend this book: Practical Java Game ProgrammingHere's a link: http://www.charlesriver.com/Books/BookDetail.aspx?productID=81070
SoulTech2012a at 2007-7-14 20:59:09 > top of Java-index,Other Topics,Java Game Development...