Lemma Soft Forums

Supporting creators of visual novels and story-based games since 2003.


Visit our new games list, blog aggregator, IRC, and wiki.
Activation problem? Email [email protected]
It is currently Fri May 24, 2013 4:08 am

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sun Aug 12, 2012 9:33 am 
Veteran
User avatar

Joined: Sun Feb 12, 2012 9:17 am
Posts: 331
Location: USA
Completed: Locked-In, Young Earth Road Trip, The Cards Never Lie
Projects: The Censor
ATL is very intuitive and can add great polish to your game, but it can seem a little intimidating if you've never used it before. Hopefully people will find these examples useful. The wiki has a great section on Animation and Transformation Language.

Opacity
Custom fades are your friend--you can make a game look much more polished by adding custom fades to sprites instead of having them pop up and vanish. Here's a simple fade effect that occurs during one second. Alpha 0.0 is invisible and alpha 1.0 is opaque. "Linear" means seconds. We add "on show" and "on hide" to have effects for both.
Code:
    transform basicfade:
        on show:
            alpha 0.0
            linear 1.0 alpha 1.0
        on hide:
            linear 1.0 alpha 0.0        


Code:
    show eileen at basicfade, center
    e "Here I am!"
    e "Buh-bye now!"
    hide elieen


Basic Animations
Realistic Rain
Search for rain animation tutorials to find an easy way to make images. I used this tutorial for Gimp. I got a nice result using three frames. Define your image by indicating the images and the amount of time between each:
Code:
    image rain:
        "rain.png"
        0.1
        "rain2.png"
        0.1
        "rain3.png"
        0.1
        repeat


If you want rain during an exterior, layer your images with rain at the end. (Images are layered on top of each other, so the first image shown will be at the "back" of the screen.)
Code:
    scene darksky
    show house
    show rain


If you want rain on outside of an interior scene, you would layer the rain before the interior image (which needs to have transparent windows or some other way to see the rain on the other side, of course).
Code:
    scene darksky
    show rain
    show bedroom


You can also build a layered image using LiveComposite (it ain't just for sprites).

Code:
    image bedroom:
        LiveComposite((800,600), (0,0), "darksky", (0,0), "rain", (0,0), "bedroom.png")

Code:
    scene bedroom


Flicker
You can take advantage of the Null command in animation loop to make an image flicker. It can create a neat effect on terminal-like objects and screens.

Code:
    image monitor:       
        "scanlines.png"
        1.4
        Null ()
        0.05
        "scanlines.png"
        4.0
        Null ()
        0.05     
        repeat


Basic Horizontal and Vertical Movement
This makes a little airplane go from the left to the right side of the screen over 45 seconds. Since I only used this effect once I included the position commands in the image definition, so you just type
Code:
show airplane
to get the effect.
Code:
    image airplane:
        "airplane.png"
        xalign -0.1 yalign 0.15
        linear 45.0 xalign 1.1    


You could drop a ball from the top of the screen to the bottom by adjusting the y-position instead.
Code:
    transform falling:
        yalign 0.0 xalign 0.5
        linear 1.0 yalign 1.0


Code:
show ball at falling


Choice and Parallel - Adding Simultaneous and Random Elements

Randomized Lightning
This takes advantage of the choice command to use random images at random positions. Make three (or however many) lightning images, and define the image to show a random lighting picture using choice:
Code:
    image lightning:
        choice:
            "lightning.png"
        choice:
            "lightning2.png"
        choice:
            "lightning3.png"


You can weight the likelihood of choices by adding an integer (the default is 1.0):
Code:
    choice 3.0:
        "lightning.png"


Now we will create a transform that causes the lightning to 1) appear at random places at the top of the screen and 2) flash. To do this we will use parallel statements, which allow us to executes multiple ATL blocks at the same time. The first parallel block sets the image position at one of three x-positions at the top of the screen. The second parallel block causes the image to appear and disappear within 0.5 seconds, simulating a flash.
Code:
    transform flash:
        parallel:
            yalign 0.0
            choice:
                xalign 0.9
            choice:
                xalign 0.5
            choice:
                xalign 0.1
        parallel:   
            alpha 0.0
            linear 0.25 alpha 1.0
            linear 0.25 alpha 0.0


Code:
show lightning at flash


Combine Horizontal and Vertical Motion
In Locked-In there is a scene where a waiter walks by a with a dinner tray. I made the tray move from right to left, AND slightly up and down to simulate walking, by splitting the y movement and the x movement into two parallel blocks.
Code:
    transform tray:
        parallel:
            xalign 2.5
            linear 4.0 xalign -2.0
        parallel:
            yalign 1.5
            block:               
                linear 1.0 yalign 1.0
                linear 1.0 yalign 1.5
                repeat   


Rotate
Analog Clock
For this you will need a separate clock face, minute hand, and hour hand. The hour hand rotates in 60 seconds and the minute hand rotates in 5 seconds. If you get a bad jitter effect on slow rotations you can add subpixel True to smooth things out.
Code:
   
    transform hoursforward: 
        subpixel True
        rotate 0
        linear 60.0 rotate 360
        repeat


Code:
    transform minutesforward:
        subpixel True
        rotate 0
        linear 5.0 rotate 360
        repeat


If you want the hands to rotate counter-clockwise, you can do it by giving a negative rotation:
Code:
    transform hoursbackward:   
        subpixel True
        rotate 0
        linear 60.0 rotate -360
        repeat


Swinging Back and Forth
This is how I made the padlock on the Locked-In logo swing back and forth before coming to a standstill. I use a block statement to separate the latter part of the transform.
Code:
   
    transform lock:
        rotate 0
        linear 0.0 rotate 30
        block:
            linear 0.75 rotate -30
            linear 0.65 rotate 25
            linear 0.60 rotate -25
            linear 0.55 rotate 20
            linear 0.50 rotate -20
            linear 0.45 rotate 15
            linear 0.35 rotate -15
            linear 0.30 rotate 10
            linear 0.25 rotate -10
            linear 0.20 rotate 5
            linear 0.15 rotate -5
            linear 0.1 rotate 0


If you wanted it to swing back and forth indefinitely, you could do it using a repeating block:
Code:
    transform lock:
        rotate 0
        linear 0.0 rotate 30
        block:
            linear 0.75 rotate -30
            linear 0.75 rotate 30
            repeat


As you can see, zoom is conspicuously absent. If anyone wants to add their own examples/improvements, please do.

_________________
Lucky Special Games - Locked-In - Young Earth Road Trip - The Censor (Nano 2013) WIP


Last edited by saguaro on Thu Aug 23, 2012 9:01 pm, edited 1 time in total.

Top
 Profile Send private message  
 
PostPosted: Sun Aug 12, 2012 12:08 pm 
Regular
User avatar

Joined: Mon Jan 30, 2012 7:50 am
Posts: 93
Location: Europe
Projects: The Romance of Miss Boop (Complete) viewtopic.php?f=11&t=17090
This is a really good post to put all the codes together as one. The rain code never worked for me, so i ended up trying a difference method. I just replaced the Cherry Blossom png with one of the rain's image files.

_________________
http://berry-melon.deviantart.com/


Top
 Profile Send private message  
 
PostPosted: Sun Aug 12, 2012 3:43 pm 
Miko-Class Veteran
User avatar

Joined: Sun Mar 25, 2012 7:54 pm
Posts: 559
Projects: Club Shuffle
Rad, thanks for all of the contextual examples. Those always help me with my coding. :D

_________________
Image
Developer Blog for Club Shuffle - Follow and Share?
-Also! You can call me Crystal if you want.-


Top
 Profile Send private message  
 
PostPosted: Tue Aug 14, 2012 5:40 pm 
Ren'Py Creator
User avatar

Joined: Mon Feb 02, 2004 10:58 am
Posts: 10778
Location: Kings Park, NY
Completed: Moonlight Walks
Projects: Ren'Py
These examples are great. Thanks for posting them.

_________________
Another Old-Fashioned Bishoujo Gamer
Supporting creators since 2004; Code > Drama
(When was the last time you backed up your game?)
"It is not the critic who counts; not the man who points out how the strong man stumbles, or where the doer of deeds could have done them better. The credit belongs to the man who is actually in the arena, whose face in marred by dust and sweat and blood; who strives valiantly; who errs, who comes short again and again, because there is no effort without error and shortcoming" - Theodore Roosevelt


Top
 Profile Send private message  
 
PostPosted: Mon Aug 20, 2012 1:40 pm 
Miko-Class Veteran
User avatar

Joined: Mon Dec 13, 2010 9:30 am
Posts: 842
Location: New Brunswick, Canada
Projects: Camp Renard
Would you be ok with me putting these together into a sampler game?

Susan

_________________
In order to understand recursion, one must first understand recursion. (Anonymous)


Top
 Profile Send private message  
 
PostPosted: Mon Aug 20, 2012 7:42 pm 
Veteran
User avatar

Joined: Sun Feb 12, 2012 9:17 am
Posts: 331
Location: USA
Completed: Locked-In, Young Earth Road Trip, The Cards Never Lie
Projects: The Censor
Go for it, that's a great idea.

_________________
Lucky Special Games - Locked-In - Young Earth Road Trip - The Censor (Nano 2013) WIP


Top
 Profile Send private message  
 
PostPosted: Thu Aug 23, 2012 9:03 pm 
Veteran
User avatar

Joined: Sun Feb 12, 2012 9:17 am
Posts: 331
Location: USA
Completed: Locked-In, Young Earth Road Trip, The Cards Never Lie
Projects: The Censor
Added a bit about using LiveComposite to layer bg images (thaaaank you apricotorange). I also added a flicker animation, which was inspired by some code foo PyTom posted in the questions forum a while back.

_________________
Lucky Special Games - Locked-In - Young Earth Road Trip - The Censor (Nano 2013) WIP


Top
 Profile Send private message  
 
PostPosted: Sat Sep 01, 2012 8:26 pm 
Miko-Class Veteran
User avatar

Joined: Fri Mar 16, 2012 11:38 am
Posts: 936
Location: Tokyo, Japan
Projects: Untitled Japanese study game
Organization: Pure Anarchy
Thanks a lot for posting these. I'm sure these will come in very handy .

_________________
Working on a VN to teach lower-conversational Japanese, and a guide to living in Japan.
It's a very long dev process.

You could help me with my game A LOT by filling out this anonymous 10 question survey: http://www.surveymonkey.com/s/6GR57YB
Massive thanks to everyone who has already filled it out!
You can see a Q&A about the survey here: http://tinyurl.com/SurveyQandA


Top
 Profile Send private message  
 
PostPosted: Sun Jan 13, 2013 11:06 am 
Veteran
User avatar

Joined: Fri Aug 17, 2012 8:33 am
Posts: 268
Completed: The Halberd and the Tiger
Projects: Jacob's Island
Lovely codes!
When I figured out how to implement them, they were exactly what I was looking for, thanks!

Just in case there are other people out there who missed the easy part.

example:
Code:
   
    show lamp at lock
    transform lock:
        rotate 0
        linear 0.0 rotate 30
        block:
            linear 0.75 rotate -30
            linear 0.65 rotate 25
            linear 0.60 rotate -25
            linear 0.55 rotate 20
            linear 0.50 rotate -20
            linear 0.45 rotate 15
            linear 0.35 rotate -15
            linear 0.30 rotate 10
            linear 0.25 rotate -10
            linear 0.20 rotate 5
            linear 0.15 rotate -5
            linear 0.1 rotate 0
   

"lamp" is the image which I defined earlier, and "lock" is the name of the transform. Activate it with "at".
"show lamp at lock"

_________________
My Dev.art - My VN WiP Blog --- The Halberd and the Tiger VN


Top
 Profile Send private message  
 
PostPosted: Sat Jan 26, 2013 10:41 pm 
Miko-Class Veteran
User avatar

Joined: Sun Jan 01, 2012 4:09 am
Posts: 786
Completed: MBAI, ICMB! Band Crash!, LoSE, LoC, NatH, etc.
Projects: TWCC, Dream's Dénouement, Heartful Memory, Witch Apprentice, etc.
Organization: TTG, Team ANARKY
I thought I'd be smart enough to figure this out on my own but lol no. Instead of going insane by myself, it'd be a lot faster and less painful to ask the ATL master directly.

Right now I know how to use ATL to make all my sprites appear on the screen simultaneously. I even figured out how to use ATL at custom positions:
Code:
    transform moreright_dissolve:
        on show:
            yalign 0.5 xalign 0.2 alpha 0.0
            linear 2.0 alpha 1.0
        on hide:
            linear 2.0 alpha 0.0
label start:
    show girl at moreright_dissolve
    girl "No lag, no waiting! I love it!"

It looks nice and it's not hard to code after you define your ATL blocks once. However, these ATL transitions only work when you want to show the sprite initially. If I try to do something like this:
Code:
show girl happy at basicfade, right
girl "Man this is nice."
show girl angry at basicfade
girl "Hey wait, why wasn't there a transition?!"
hide girl angry at basicfade
girl "L-A-M-E."
The sprite has no smooth transitions and the new expression is just plastered onto the spot/disappears suddenly. I can use dissolve if I want, but that will make the textbox disappear momentarily, which is okay when it's every so often but we all know that expressions change constantly throughout the script.

In other words, what I am doing wrong here?

_________________
ImageImageImage


Visit the OELVN wiki at the top of the forum! We have free assets, programs, tutorials, tips and more over there. I'm the administrator, PM me if you want to help organize the place. I could use a hand.


Top
 Profile Send private message  
 
PostPosted: Sun Jan 27, 2013 1:54 am 
Veteran
User avatar

Joined: Sun Feb 12, 2012 9:17 am
Posts: 331
Location: USA
Completed: Locked-In, Young Earth Road Trip, The Cards Never Lie
Projects: The Censor
Try adding:

Code:
        on replace:
            linear 2.0 alpha 1.0
        on replaced:
            linear 2.0 alpha 0.0


I just learned about that recently myself.

_________________
Lucky Special Games - Locked-In - Young Earth Road Trip - The Censor (Nano 2013) WIP


Top
 Profile Send private message  
 
PostPosted: Sun Jan 27, 2013 2:26 am 
Miko-Class Veteran
User avatar

Joined: Sun Jan 01, 2012 4:09 am
Posts: 786
Completed: MBAI, ICMB! Band Crash!, LoSE, LoC, NatH, etc.
Projects: TWCC, Dream's Dénouement, Heartful Memory, Witch Apprentice, etc.
Organization: TTG, Team ANARKY
It has the odd habit of working 50% of the time :C It works only with certain sprites/expressions, which doesn't make much sense because they should all basically be the same. I've deleted my persistent data just in case but that doesn't change anything either.

I'm not sure if this means anything, but replace and replaced aren't highlighted in brown in Editra. The script doesn't really mean anything either.
Code:
init:
    transform basicfade:
        on show:
            linear 1.0 alpha 1.0
        on hide:
            linear 1.0 alpha 0.0
        on replace:
            linear 1.0 alpha 1.0
        on replaced:
            linear 1.0 alpha 0.0
label start:
    show guy normal at center with dissolve
    guy "Line 1."
    show guy sad at basicfade
    guy "This probably doesn't work."

*sighs and collapses at desk*

_________________
ImageImageImage


Visit the OELVN wiki at the top of the forum! We have free assets, programs, tutorials, tips and more over there. I'm the administrator, PM me if you want to help organize the place. I could use a hand.


Top
 Profile Send private message  
 
PostPosted: Sun Jan 27, 2013 2:48 am 
Crawling Chaos
User avatar

Joined: Mon Feb 13, 2012 5:37 am
Posts: 1115
Location: Kimashi Tower, Japan
Completed: SMAR,AAA
Projects: DMC
Transform is performed with other processes. So when images are loading/caching, it causes delay and blank. You can overlap the time of face changes to hide this blank, but its difficult to do on pose changes.

_________________


Top
 Profile Send private message  
 
PostPosted: Wed Jan 30, 2013 1:41 am 
Veteran
User avatar

Joined: Fri Jun 22, 2012 7:23 pm
Posts: 211
Location: Yogyakarta, Indonesia
Completed: Pharmacy Quiz, Physical Pharmacy, Tour de Pharmacy
Projects: The Devil, ERASER
Organization: NSAID
Great tutorial ! I've tried some and it's successful~ Big thanks ! :mrgreen:
Just wondering because I'm a Renpy noob, can you combine the rain animation and lightning effect at the same time ? What code should I write ? (i don't think parallel statement can be used for animation...)
Thanks again~

Starshine wrote:
The rain code never worked for me, so i ended up trying a difference method. I just replaced the Cherry Blossom png with one of the rain's image files.

Just use GIMP or Photosop to make rain effect, vary the noise effect from 50-55% with uniform distribution, then Filter-Motion Blur should do the trick. Just animated it, and voila~

_________________
Completed project :
[Campus Life][Education]Tour de Pharmacy
[Trivia/Quiz][Education]Pharmacy Quiz 1.0
[Trivia/Quiz][Education]Physical Pharmacy

ATL can do many things !
ERASER [Slice of Life][Sci-fi] : My Next Project Visual Novel

DOODLE COMPILATION

"All things are poison, and nothing is without poison; only the dose permits something not to be poisonous" (Paracelsus, The Father of Toxicology)
So Visual Novel overdose = POISON XD

"Let us learn to DREAM, then we may perhaps find the truth" (August Kekule, the benzene structure inventor)
so let me sleep at least 8 hours per day !


Top
 Profile Send private message  
 
PostPosted: Wed Jan 30, 2013 8:14 am 
Veteran
User avatar

Joined: Sun Feb 12, 2012 9:17 am
Posts: 331
Location: USA
Completed: Locked-In, Young Earth Road Trip, The Cards Never Lie
Projects: The Censor
Yes, you would just show them both.

Code:
label test:
    show rain   
    show lightning
    etc.

_________________
Lucky Special Games - Locked-In - Young Earth Road Trip - The Censor (Nano 2013) WIP


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users


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
You cannot post attachments in this forum

Search for:
Protected by Anti-Spam ACP
Powered by phpBB® Forum Software © phpBB Group