Clever animation design?

Hello!

A week has passed, a new problem ahead!

Heh, what I want to do is to have more animations looking exactly like eachother, but animationoff-sync. This is normally not a hard thing to do, but let me explain the state of my code.

I handle animations and pictures in what I think is a clever way. I have a resource manager that in a HashMap binds together Animations, and enums representing the animations.
So when I need an animation I can just refer to the enum, and get the animation from there when I need to actually draw it. This way I don’t have a lot of animations floating around on all kinds of objects, but just the enum references. I do the same for still images, where it’s obviously not a problem.
Because there is only 1 of each different animation (the one in the hashmap), it will be drawn on all entities that uses that animation. However, what do I do when I need two of the same animations side-by-side but they need to go at different pulses?

My scenario is this: The player walks in a huge field of high grass, and when he enters a new tile the grass on the tile is shaken because of the player walking in it. However, all of the grass uses the same images, and same animation so when one of the tiles are animated all of them are. That is unfortunate.

What do I do with my solution when I want these non-syncronized animations? I certainly do not want to force the animations directly on to the tiles.

Create a new animation?

Normally, this would be the way to go. Unfortunately, I may have a 30x30 grass-field.
Creating that much animations by hand is a little too much. It’s a little hacky.
You see, i store animations like this

HashMap<ANIMATION, Animation> animations;
Where the first one is an enum, and the second one is the actual Animation class.

EDIT: The enum looks like this:
HIGH_GRASS
FENCE
DOOR
and so on. Each of these enums has an animation in the HashMap.

Your solution suggests that I do this:
HIGH_GRASS1
HIGH_GRASS2
HIGH_GRASS4

and so on, up to 400 and assign them accordingly. You see how hacky that is? :stuck_out_tongue:

Keep the static data how you have it and separate out the dynamic data into another class that points to the static data.

So the frames that represent that animation would still be handled the same as it currently is but the things that point to it would keep track of stuff like current frame and the animation timers.

Yea I agree with zoto, I am not sure if I am saying this correctly but you want to only load the images once like you are and just reference the images, but have multiple instances of Animations which use the static images with variables that display them at whatever time intervals, etc;

That way you can have maybe a “run” animation made from a “walk” animation at a faster speed.