Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Smooth Natural Animation, One Approach

Author
Message
Dejunai
19
Years of Service
User Offline
Joined: 19th Jul 2005
Location: Mentally: Manhattan; Physically: LA -doh
Posted: 3rd Aug 2005 06:29 Edited at: 4th Aug 2005 05:37
If I were the confident sort of NoOb,
I'd post this in CODE SNIPPETS, but I ain't.

So since I am a NoOb, and not so confident...
I thought I'd present my solution to a specific
problem I encountered. It may be VERY specific to only me,
and therefore useless to others.

My situation is that I have numerous animated sprites on
screen at the same time. "Play Sprite" has proven unhelpful
for my specific tasks.

The sprites I wish to animate all have different frame counts.
But I require them to all be in sync. ( yes, reworking them to
all have the same frame count would help, but that's not the
point of my post )

I'd also prefer that my animations not appear to be loops.
For my specific purposes I am creating an animated shore line.
The tide washes in, and then back out... And shouldn't appear to
a constant loop.

As such I have written the following code,
which seems to work, and of course could be improved upon.



The above snippet of course is just that "a snippet"
it doesn't "DO" much of anything... What it does do
is set the global variable MOMENT.

Which in my case is then applied ( as a percentage multiplier )
to the maxNumberOfFrames for each sprite. All are then in sync
to the "MOMENT"...

I am not sure how to demo the code effectively, but here goes...



The above code REALLY does nothing, it can't even be executed.
But hopefully you understand how it works...
It is using the variable MOMENT to decide which frame to use.
All sprites no matter how many frames long, execute in order
and ~should~ appear smooth, despite sync/frame rate. They also
~should not~ appear to be in a perfect loop, because of the
random increment of the moment.

Adjustments to the SMOOTH variable will make changes to
the animation. The lower the SMOOTH variable, the more
variation ( random ) to the loop. The higher the SMOOTH
variable the smoother the animation ( but less random the
loop ).

SMOOTH set to "0" ( zero ), is of course useless.
SMOOTH set to one is the most random least smooth version
of the animations.
SMOOTH set to the maxNumberOfFramesOfTheLongestAnimation
should make the sprite with the max number of frames seem
very natural, all other sprites should vary based on the
above description. They would appear more 'loopish'
depending on how few frames are available.

Playing with the variable SMOOTH, should allow you to
find a happy medium.

I cannot tell you how happy I am with the implementation,
but at the same time, I am certain my explaination is far
from perfect. So questions are welcome.

If there any veterans that can share a better way to do it...
Well, any and all input is more than welcome.

============ : Windows 200 SP4+, 3.2GHz Hyperthreaded
-Dejunai ............: 2GB RAM, nVidia 6600 256MB AGP 8x
============ : AC'97 basic A-Bit Motherboard Audio ( drivers always Maintained )
master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 3rd Aug 2005 06:37
Kinda understand. You should post the game as a .zip so we can have the media to execute and see what you're talking about.

--------------------------------------
Vote for Excelsis on the Puzzle Game Compo

__________________________________________
<<<<<Check out my sites>>>>>
www.rhettgames.tk | www.slayerbattletanks.tk
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 7th Aug 2005 21:16
Hi,

Out of interest, have you looked at the sin/cos, and curvevalue commands? That's certianly how I'd do a tide (its movement, 2d, anyway). The sine wave shape for example to me represents something similar to the layering of a sprite tide. Just a thought, hope it helps

Cheers.

Login to post a reply

Server time is: 2024-09-24 01:26:47
Your offset time is: 2024-09-24 01:26:47