Welcome Guest ( Log In | Register )

HOME FORUMS DISCORD GAMES RPG MAKER SEARCH




Post new topic Reply to topic  [ 13 posts ] 
    e
  Tue Oct 28, 2008 1:05 am
shittybutt
User avatar



Location: Berlin
Here's a little something I've been working on for the past day and a half, after finally understanding most of the math involved behind the easing equations.

This is a little animation toolkit; very basic for now, in the sense that it requires intermediate scripting skills, but I plan on offering easy to use interface and facades, which should allow anyone with basic RGSS knowledge and a little guidance to use this correctly to build beautiful cut scenes.

So, what exactly does this do? Precisely, it takes an object's numerical property's starting value and a user given end value to generate a function of time, which is called on every frame update. Easy, right? Except it uses Robert Penner's excellent (as in, free) easing equations to smooth out the animation process.

Less precisely, it allows one to manipulate graphics (in most cases, but any object can be supplied, since I follow duck typing) and easily animate their coordinates, opacity, color, tone, etc., allowing someone to do fade in/out, slide in/out, zoom in/out, etc., effects very easily.

I've made a short demo which shows some of the capabilities of the script.

Once again, this is right now most likely geared towards fellow scripters who want to add animations to their scripts.

HOW IT WORKS:
The script itself is based on Ruby's mix-in capabilities; by including the module Effects::Animated into a given class, you now have access to a bunch of processing methods. The only other necessary modification is made in the update method, or whatever method is called on every frame.

Expand to see the code.


Just adding this tiny snippet would make the Sprite class animate-able.

Effects are processed as a job queue; in other words, you create new Effects::Effect objects which are pushed at the end of queue and processed sequentially. I'm afraid I don't quite know how to do simultaneous effects (without threads) short of cooperative multi-threading; simply performing all effects in the queue all at once would probably cause lag if the number of effects is very large.

You have a few methods to control the processing of the effects queue:
Expand to see the code.


Please note that when pausing/resuming an effect, if you modify the properties which are modified in the effect, but through an external manner, you will get strange behaviors. I'm still unsure as to what stand to take on this matter.

To add an effect to the job queue of an object, you simply push (it is an Array, except handled in a queue-like fashion) a new Effects::Effect object, such as:
Expand to see the code.


Where @s is a Sprite object.

The transition parameter is supposed to be a Method object; more specifically, a method from one of the Effects::Trans sub-modules.
The duration is the number of frames the effect should take to complete. A few aliases have been made for durations : Effects::Effect::SHORT (15 frames), Effects::Effect::NORMAL (30 frames), Effects::Effect::LONG (60 frames).

The properties parameter is an hash of the properties of the object which should be modified over time. The keys are the properties, the values the end values of each property (i.e.: the X coord goes from 0 to 300 under 80 frames in our example).

Sub-properties are supported, that is to say, properties of properties; for example, you want to change the tone property of a Sprite. You'd do :
Expand to see the code.


The beforeUpdate param is a callback, or more specifically a Method or Proc object, which is called on every frame on every property before said property is updated.
The afterUpdate param is a callback which is called on every frame on every property after said property has been updated.
The onStart param is a callback which is called when a new effect becomes the current job being processed. In other words, at the beginning of the Effect, but before any update.
The onFinish param is a callback which is called when an effect is finished, before the queue is shifted and a new effect takes its place.

The object param is the object which should be updated. It is a required parameter.

Anyway, here's the script itself:
Expand to see the code.


And here's a link to the RMXP demo: http://rgss.etheon.net/Animator.zip
And the RMVX demo: http://rgss.etheon.net/VXnimator.zip

The demo code is in the Scene_Map script. It's neatly identified, so no one should have any trouble with it.

I'll be posting a couple of Effects templates, such as fade in/out, slide in/out, grow/shrink, projectile curves, etc.

You can view a demo of some of the different easings available on Robert Penner's site: http://www.robertpenner.com/easing/easing_demo.html


Last edited by Anonymous on Wed Oct 29, 2008 1:24 am, edited 1 time in total.

Top Top
Profile      
 

    action
  Tue Oct 28, 2008 1:32 am
User avatar
Member


Location: Woodbury, MN
Stauf wrote:
So, what exactly does this do? Precisely, it takes an object's numerical property's starting value and a user given end value to generate a function of time, which is called on every frame update. Easy, right? Except it uses Robert Penner's excellent (as in, free) easing equations to smooth out the animation process.


No more easy to me than a Doctor degree Algebra 2 Mathe test.
What did I just say?
[not flaming] :P
Anyways, what I think this is is a script that allows you to change the X, Y, Z, and opacity of the animations.

Am I right?

_________________
https://soundcloud.com/realnomenclatures/slacker


Top Top
Profile      
 

    e
  Tue Oct 28, 2008 2:00 am
shittybutt
User avatar



Location: Berlin
Opacity, X, Y, Z, whatever you want, as long as its a numerical property, something that can be coerced into a function over time. That includes Colors, Font sizes, Tones, Hues, etc.


Top Top
Profile      
 

    trebor777
  Tue Oct 28, 2008 2:57 am
Member

:p now all we need is a curve editor lol !! with bezier curves and control points!

Good work!
Really cool to smooth animated stuff ( instead of having a constant speed of motion ) !


Top Top
Profile      
 

    Link in Pink
  Tue Oct 28, 2008 3:03 am
It rhymes.
User avatar
Member


Location: Confirmed. Sending Supplies.
So can you only use it on the first map? Or can it be called in a script from an event?

_________________
http://i288.photobucket.com/albums/ll19 ... ature2.png[/img]


Top Top
Profile      
 

    Zeriab
  Tue Oct 28, 2008 9:58 am
Hugging Lion
User avatar
Sponsor

I love you etheon <3

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 

    e
  Tue Oct 28, 2008 3:55 pm
shittybutt
User avatar



Location: Berlin
As I've said, this is mostly for scripters to integrate within their scripts to animate objects.

I will be releasing an Effects pack which will contain pre-made effects for Sprites and Windows that you can use from Events.


Top Top
Profile      
 

    Me(tm)
  Tue Oct 28, 2008 6:12 pm
User avatar
Member


Location: Delft, The Netherlands
Hey Stauf,

Love this Module! You did way more then stuff I used to have in my projects (I only used easein (so in the beginning slow) and easesin-easeout (so slow - quick - slow)). But this is very cool. To have objects be uopdated sync, just keep using the @normal var, but in this way:

Expand to see the code.


That should work ;)

_________________
Image


Top Top
Profile      
 

    e
  Tue Oct 28, 2008 11:55 pm
shittybutt
User avatar



Location: Berlin
Wouldn't that cause some lag if there were too many effects going on at the same time?

Though that's a reasonable risk; it'd be the scripter's fault :p


Top Top
Profile      
 

    Me(tm)
  Wed Oct 29, 2008 11:23 pm
User avatar
Member


Location: Delft, The Netherlands
Stauf wrote:
Wouldn't that cause some lag if there were too many effects going on at the same time?

Though that's a reasonable risk; it'd be the scripter's fault :p


MAXUPDATING
^
Restricts the number of sequential updates at the same time.

_________________
Image


Top Top
Profile      
 

    e
  Wed Oct 29, 2008 11:42 pm
shittybutt
User avatar



Location: Berlin
I fixed it in another way; using the callbacks provided, onStart and onFinish, you can easily launch multiple effects on multiple objects, and keep them tightly controlled.

I'm updating it to add a delay function (i.e.: wait X FPS before launching the next effect) and some syntactic sugar, such:

Expand to see the code.


Mostly for game designers and whatnot.

Also, for some reason, the easing equations (other than Linear) utterly fail when morphing (scaling) an object. They're fine when it comes to moving things around, but scaling things just goes awry, for some reason...which is no big deal, I guess.


Top Top
Profile      
 

    Me(tm)
  Thu Oct 30, 2008 6:18 pm
User avatar
Member


Location: Delft, The Netherlands
.then(arguments) would simply call onFinish: Prog fx.do(arguments) right?

Your fixing way is better either way - but I hope it works the way you coded it (if you want a simultaneous effect I would call it with onStart: right? But what if Sprite A and Sprite B have a method with a effect, how would one call the other and still be sync?

_________________
Image


Top Top
Profile      
 

    e
  Thu Oct 30, 2008 11:37 pm
shittybutt
User avatar



Location: Berlin
In theory, on each frame, the effects update the specified properties. If their properties' growth rate are the same, they should grow similarly. There might be a one frame delay if Sprite B's update method was called prior to Sprite A launching Sprite B's effect queue, but that could be fixed, if known beforehand, by lowering Sprite B's effect duration by 1 frame. Of course, if you don't know that it will be called, I guess I could add some way to skip to the next frame right away (i.e.: SpriteB.fx.next_frame() would update the animation without waiting for the game engine to do another loop).


Top Top
Profile      
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 


Who is online

Users browsing this forum: No users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

We are an independent, not-for-profit game making community.
Homepage
Board Index
About Us
Downloadable Games
Free Browser Games
Games in Development
RPG Maker Support
Game Maker Support
Construct 2 Support
HBGames the eZine
Advanced RPG Maker
Site Announcements
Powered by phpBB © phpBB Group