Make the screen have a constant sway/floating movement?

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.
Post Reply
Message
Author
User avatar
Rainvillain
Regular
Posts: 76
Joined: Thu Mar 05, 2015 11:27 am
Contact:

Make the screen have a constant sway/floating movement?

#1 Post by Rainvillain »

Hello!

Working on a game that takes place aboard a ship and I was wondering if there was a way of having a subtle little swaying to the camera up and down to give the impression of being on water.

I know how to do basic stuff like panning the screen to the left/right/up/down but it's always been one-off things, that happen inbetween dialogue and not concurrently (or looping).
Not sure how to have a loopable "transform" animation that runs on the screen and characters in the background while the scene unfolds.
Any advice?

User avatar
Alera
Miko-Class Veteran
Posts: 651
Joined: Sun Mar 21, 2010 3:20 am
Completed: Tortichki // Zayay // Hero's Spirit
Deviantart: psyalera
itch: psyalera
Location: UK
Contact:

Re: Make the screen have a constant sway/floating movement?

#2 Post by Alera »

Hello!

I'm not sure how to apply it to the whole screen per se but you could easily apply such effect to individual elements (or all of them if you wish) using ATL

So it would be something like this:

Code: Select all

init-2:
    transform ship_sway:
        ypos -10 #You'll have to play around with these values and see what works for the images you've got and the effect you want.
        linear 0.5 ypos -15
        linear 0.5 ypos -10
        repeat #This is what makes it loop
                        
label start:
    show ship_bg at ship_sway
I hope this helps?
Image
Games:
❤️ Zayay [Otome?][BxPlayer][NaNo 2013]
❤️ Tortichki [Drag&Drop mini game]

Other games I've worked on:
My Heart's Flame Emissary of Starlight Freedom From Silence Sickness
And many more unannounced/secret projects. (. .)

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Make the screen have a constant sway/floating movement?

#3 Post by PyTom »

You can apply it to the entire master layer with:

Code: Select all

show layer master at ship_sway
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom


User avatar
Rainvillain
Regular
Posts: 76
Joined: Thu Mar 05, 2015 11:27 am
Contact:

Re: Make the screen have a constant sway/floating movement?

#5 Post by Rainvillain »

Follow up question: the "show layer master at ship_sway" works perfectly, but what if I wanted just one layer that didn't sway?
In my case, I want the ship (and characters) in the foreground to sway but not the sky and clouds, which are on their own layer behind everything else. Is there a way to basically apply sway to everything except for one layer?

Kinsman
Regular
Posts: 130
Joined: Sun Jul 26, 2009 7:07 pm
Location: Fredericton, NB, Canada
Contact:

Re: Make the screen have a constant sway/floating movement?

#6 Post by Kinsman »

You can add extra layers to your Ren'Py game by changing what's in config.layers.

Code: Select all

# Add a "backdrop" layer behind the master layer
init python:
    config.layers = [ 'backdrop', 'master', 'transient', 'screens', 'overlay' ]

# Later in your script..
show layer master at ship_sway

show cloudy_sky onlayer backdrop
Flash To Ren'Py Exporter
See the Cookbook thread


User avatar
Letitia_L
Regular
Posts: 84
Joined: Wed Apr 20, 2016 4:33 am
Projects: Up until the end
IRC Nick: Letitia
Tumblr: letigame
Deviantart: LetitiaLambrechts
itch: https://letigame.itc
Contact:

Re: Make the screen have a constant sway/floating movement?

#8 Post by Letitia_L »

I know this tread is a little old, but I wanted to thank Alera for her answer!

Code: Select all

init-2:
    transform ship_sway:
        ypos -10 #You'll have to play around with these values and see what works for the images you've got and the effect you want.
        linear 0.5 ypos -15
        linear 0.5 ypos -10
        repeat #This is what makes it loop
                        
label start:
    show ship_bg at ship_sway
I used this to make a running effect :)
WIP project
Image
Completed project
Image

Post Reply

Who is online

Users browsing this forum: No registered users