Shake effects; and zoom/pan

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
Gumaster
Regular
Posts: 93
Joined: Sun Sep 06, 2009 6:54 am
Contact:

Shake effects; and zoom/pan

#1 Post by Gumaster »

Just wondering about a few things regarding shake effects, both the one from the cookbook and the ones made using Move (like hpunch and vpunch)
-Is it possible to have a shake feature going on in the background, during other image transitions? Like, having a series of cgs transitioning in from the sides while shaking?
-How to make a shake effect that gradually increases/decreases in magnitude? I'm guessing it involves maths functions of some sort, but eh. I could try to replicate the effect using a bunch of seperate shake effects with different magnitudes, sort of like converting an analogue signal to digital, but...that's kinda clumsy and awkward.

Also, is it possible to zoom in on an image, then pan the camera in a direction, and zoom out again? Or something to that effect, other than making a bunch of seperate images like I'm doing now?

And as a random note, directing battle sequences+effects is HARD x_x

JinzouTamashii
Eileen-Class Veteran
Posts: 1686
Joined: Mon Sep 21, 2009 8:03 pm
Projects: E-mail me if you wanna rock the planet
Location: USA
Contact:

Re: Shake effects; and zoom/pan

#2 Post by JinzouTamashii »

Don't worry, we can get through it together. I didn't forget about you! I just got overwhelmed.
https://cherylitou.wordpress.com

Gumaster
Regular
Posts: 93
Joined: Sun Sep 06, 2009 6:54 am
Contact:

Re: Shake effects; and zoom/pan

#3 Post by Gumaster »

Gumaster wrote:Just wondering about a few things regarding shake effects, both the one from the cookbook and the ones made using Move (like hpunch and vpunch)
I think I have, but maybe I missed something?
I have a tendency to miss the incredibly obvious sometimes.

JinzouTamashii
Eileen-Class Veteran
Posts: 1686
Joined: Mon Sep 21, 2009 8:03 pm
Projects: E-mail me if you wanna rock the planet
Location: USA
Contact:

Re: Shake effects; and zoom/pan

#4 Post by JinzouTamashii »

If you don't mind me asking, what are you trying to accomplish?
Don't worry, we can get through it together. I didn't forget about you! I just got overwhelmed.
https://cherylitou.wordpress.com

Gumaster
Regular
Posts: 93
Joined: Sun Sep 06, 2009 6:54 am
Contact:

Re: Shake effects; and zoom/pan

#5 Post by Gumaster »

For battle effects, I want multiple, different CGs transitioning in quickly one after the other, and during all this the screen is shaking. At the moment all I can do is have a CG *appear* shaking, or have them transition in without shaking.
Also, I want a shake effect that 'dies down' gradually over a few seconds, rather than stopping abruptly. The closest I can get is using shake a bunch of times at a smaller magnitude
(example, Shake with a distance of 40, then Shake with a distance of 30, then Shake with a distance of 20, etc)

Also, say I have a regular 800x600 cg (assuming I run in a 800x600 window)
I want the cg to dissolve in at a zoomed in particular point (say, if the cg is one of a person, then the cg dissolves in already zoomed in on their feet, then pans up to their face, then zooms back out to the full cg)

Sorry, I'm bad at explaining things =\

Guest

Re: Shake effects; and zoom/pan

#6 Post by Guest »

That sounds a lot like this
http://www.youtube.com/watch?v=xWhrhed-aiY

Gumaster
Regular
Posts: 93
Joined: Sun Sep 06, 2009 6:54 am
Contact:

Re: Shake effects; and zoom/pan

#7 Post by Gumaster »

Yeah, it probably is, something similar anyway :P

Guest

Re: Shake effects; and zoom/pan

#8 Post by Guest »

Gumaster wrote:Yeah, it probably is, something similar anyway :P
Well I know if you use ATL and combine with effects you can match the blade swings, the problem is you can't and sound to it unless you break it up.

The zoom thing someone else'll have to tell you

Twilit
Regular
Posts: 53
Joined: Wed Aug 27, 2008 6:25 pm
Location: Around...
Contact:

Re: Shake effects; and zoom/pan

#9 Post by Twilit »

Alright,

If you want them transitioning quickly then you'll have to alter the transitions to be faster, I think that can be accomplished similar to the shake effect.....

Code: Select all

$ wiperightfast = CropMove(0.25, "wiperight")
As for the zoom you'll need to find out where the x,y for the feet is but it'd probably go like this:

Code: Select all

scene Guy with flash
    with Pause (0.75)
    "Why was I even here?"
    play sound "Sound/Clash.wav"
    scene Guy at Zoom((800, 600), (225, 150, 400, 0))
    with Pause (0.75)
Using ATL you could set it to pan in parallel

Code: Select all

scene Guy at Pan ((400,0), (400,300), 5.0) 
    with Pause (0.75)
Someone who knows ATL better would be of more use.......

I'd actually like to know how it's done too....if we ever get it down it's going into a cook book!!

Hope this helps some~
A modern magic fantasy series: http://twilitdreams.wordpress.com/

number473
Regular
Posts: 195
Joined: Tue Dec 15, 2009 4:20 am
Projects: The Duke's Daughter
Location: Cape Town
Contact:

Re: Shake effects; and zoom/pan

#10 Post by number473 »

This is a possibility for the shake effect. Put the following in a separate .rpy file:

Code: Select all

python early hide:
    @renpy.atl_warper
    def varyShake(t):
        import math
        n = 100
        f = (math.sin(math.pi*t)*math.sin(math.pi*t))*math.sin(n*math.pi*t)
        return f
        
    @renpy.atl_warper
    def dwindleShake(t):
        import math
        n = 100
        f = (math.cos(math.pi*t)/2+0.5)*math.sin(100*math.pi*t)
        return f
Those define ATL warpers, both are oscilations (back and forth motions). It seems that Ren'Py is much more lenient with them than I though, they can go as negative as you like and you still get a result that would be expected. It can't go over 1 though, it seems. Alright, so the first one there speeds up, then slows down. The second one starts at max and then slows down to a stop. you can change n to change the number of vibrations.

Code: Select all

    show man x:
        center
        varyShake 5 xpos 0.45
You need to set the initial position otherwise it does something weird (resets the position, not sure why). You can mix up xpos, xalign, xanchor to get the size oscilation you want. You can use y instead of x if you want up/down motion. Use parallel if you want motion in both directions.
Mental weather report: Cloudy with a possibility of brain storms.

Gumaster
Regular
Posts: 93
Joined: Sun Sep 06, 2009 6:54 am
Contact:

Re: Shake effects; and zoom/pan

#11 Post by Gumaster »

Alright, I'm stumped =\ Again.

Code: Select all

   scene phone
   show sprite:
        center
        varyShake 5 xpos 0.45
   "Teeeeeeeeeeeeeext"
gives an error when trying to launch the game.
On line 110 of C:\renpy-6.10.1\GreatestMysteryEver/game/script.rpy: ATL statement contains two expressions in a row; is one of them a misspelled property? If not, separate them with pass.
varyShake 5 xpos 0.45
Adding a pass doesnt do anything either, same error.

Code: Select all

    scene phone
    show sprite:
        center
        varyShake(5) xpos 0.45
    "So ur with ur{w=2} honey and yur making out {nw}"
that instead gives an error when it comes to that part in the script (so at least i can launch the game) and gives this instead.
Exception: Could not evaluate expression u'varyShake(5) ' when compiling ATL.
I don't know much (read: anything) about ATL, so I literally have no idea what to do with this.
It's probably also why I'm screwing up the zoom/pan.
It zooms fine, but then it shows another copy of the image and pans that, instead of the image that's already zoomed. The result is an image in the background, screen's zoomed in, and a panning shot of a copy of that image, some of which hidden offscreen since the screen is still zoomed in. I'll take this chance to look silly and ask: is there any particular code I need to make it "run in parallel" as you say, or is it a lost case anyway?

number473
Regular
Posts: 195
Joined: Tue Dec 15, 2009 4:20 am
Projects: The Duke's Daughter
Location: Cape Town
Contact:

Re: Shake effects; and zoom/pan

#12 Post by number473 »

I firstly want to check that you put the piece of code that starts with "python early hide" in a separate .rpy file. The reference says it has to be parsed (read by the program that takes the text file and makes it ready to be used by the game) before the file that uses it, and since I have no idea what order Ren'Py does that in (anyone know?) I assumed it was alphabetical so I named the file "a.rpy" and it worked fine.

As far as ATL in general, the tutorial is very informative. Run it from the launcher and then pick the corresponding chapter. Once you have those basics it's straightforward. There is a command called parallel which lets you do more than one thing at the same time. Something like

Code: Select all

show sprite:
    parallel:
        # zoom goes here
    parallel:
        # pan goes here
Mental weather report: Cloudy with a possibility of brain storms.

number473
Regular
Posts: 195
Joined: Tue Dec 15, 2009 4:20 am
Projects: The Duke's Daughter
Location: Cape Town
Contact:

Re: Shake effects; and zoom/pan

#13 Post by number473 »

Okay, I think I got something that works, let me know if it's just what you were looking for.
Firstly, the problem with the copy panning: it seems to cause trouble if you don't declare the position of the sprite explicitly to begin with, it seems to be the same reason the center statement was needed in the shake. So show the sprite (or whatever you're gonna zoom) using:

Code: Select all

show sprite:
    align(0,0, 0.0)  #same as xalign 0.0 yalign 0.0
Or you can use 0.5 if you want to work relative to the center of the screen rather than the top left corner. You can then leave pos alone and change anchor to set the place on your sprite you want. probably want to use a fraction to show this because I'm not sure how it handles the number of pixels when you zoom.
It turns out that parallel wasn't necessary, you can just write it in one line, like so (this one zooms in and then pans, then zooms back out):

Code: Select all

show sprite:
    linear 5 anchor(x1, y1) zoom 4
    linear anchor(x2, y2)
    linear anchor(0.0, 0.0) zoom 1
(x1, y1) and (x2, y2) are of course the coordinates of the points you want to pan between. But I think you wanted it to dissolve and then pan, so this inelegant piece of code works (if anyone knows how to get the dissolve out of the with statement and into the main atl part then please let me know)(the numbers are to get the timing right, dissolve takes 0.5s, but you can customize with Dissolve()):

Code: Select all

    show sprite with dissolve:
        anchor(x1, y1) zoom 4
        0.5
        linear 5 anchor(x2, y2)
    pause 5
    show sprite with dissolve:
        anchor(0.0, 0.0) zoom 1
btw, the tutorial teaches atl quickly, and it's easy so it helps me to procrastinate from leaning any pythonesque style code for a while longer ^^
Mental weather report: Cloudy with a possibility of brain storms.

Gumaster
Regular
Posts: 93
Joined: Sun Sep 06, 2009 6:54 am
Contact:

Re: Shake effects; and zoom/pan

#14 Post by Gumaster »

Perfect, that was utterly perfect.
It was a naming thing afterall for the shake effect, "shake.rpy" didn't work since it was alphabetically after "script.rpy", changing it to "ashake.rpy" makes it work.
Few questions just to tidy it up, though.
The shake effect continues until it finishes or until its hidden. Is there an easy way to make it so that clicking stops the shaking, or should I just "reshow" it normally after each shake? like, putting a "show sprite at center" or whatever after the effect? If I add a sfx to this, is it possible to make the sfx cut off as well? (perhaps using stop sound in a similar way?)
Also, the zoom/pan works BRILLIANTLY. Right now though, it dissolves in zoomed and begins to pan immediately. Is there a way to make it dissolve in zoomed, PAUSE for a bit, THEN pan?
Other than that though, seriously, that's some great stuff.

number473
Regular
Posts: 195
Joined: Tue Dec 15, 2009 4:20 am
Projects: The Duke's Daughter
Location: Cape Town
Contact:

Re: Shake effects; and zoom/pan

#15 Post by number473 »

Glad to be of assistance ^_^
I don't know about the clicking (it doesn't skip the animation when you click automatically?) but another show statement might work (can't test it right now). Experiments are your friend ^^
To make it pause you just need to change the numbers. The following will have it pause for 0.2s before and after panning.

Code: Select all

show sprite with dissolve:
    anchor(x1, y1) zoom 4
    0.7 # this controls pause length
    linear 5 anchor(x2, y2)
pause 5.2 # this also controls pause length
show sprite with dissolve:
    anchor(0.0, 0.0) zoom 1
Someone else will have to help with the sound though. I haven't had a look at how that works yet.
Mental weather report: Cloudy with a possibility of brain storms.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]