Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Clever animation design?  (Read 2773 times)
0 Members and 1 Guest are viewing this topic.
Offline Mads

JGO Ninja

Medals: 26
Projects: 3
Exp: 6 years

One for all!

« Posted 2011-07-16 19:13:55 »


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.

Offline ra4king

JGO Kernel

Medals: 508
Projects: 3
Exp: 5 years

I'm the King!

« Reply #1 - Posted 2011-07-16 19:52:06 »

Create a new animation?

Offline Mads

JGO Ninja

Medals: 26
Projects: 3
Exp: 6 years

One for all!

« Reply #2 - Posted 2011-07-16 20:08:53 »

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:
and so on. Each of these enums has an animation in the HashMap.

Your solution suggests that I do this:

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

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline zoto

Senior Devvie

Medals: 4

« Reply #3 - Posted 2011-07-16 20:22:11 »

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.
Offline Swattkidd7

Junior Devvie

Exp: 8 years

« Reply #4 - Posted 2011-07-17 00:11:28 »

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.
Pages: [1]
  ignore  |  Print  

DesertCoockie (20 views)
2018-05-13 18:23:11

nelsongames (68 views)
2018-04-24 18:15:36

nelsongames (65 views)
2018-04-24 18:14:32

ivj94 (748 views)
2018-03-24 14:47:39

ivj94 (79 views)
2018-03-24 14:46:31

ivj94 (595 views)
2018-03-24 14:43:53

Solater (95 views)
2018-03-17 05:04:08

nelsongames (168 views)
2018-03-05 17:56:34

Gornova (378 views)
2018-03-02 22:15:33

buddyBro (1038 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!