Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (489)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (555)
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 1714 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 »

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.

Offline ra4king

JGO Kernel


Medals: 345
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:
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? Tongue

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

Senior Member


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 Member





« 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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (10 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (27 views)
2014-08-22 19:31:30

atombrot (40 views)
2014-08-19 09:29:53

Tekkerue (38 views)
2014-08-16 06:45:27

Tekkerue (34 views)
2014-08-16 06:22:17

Tekkerue (24 views)
2014-08-16 06:20:21

Tekkerue (34 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (47 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!