How do you make the scene shake? (2025)

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

  • Print view

11 posts• Page 1 of 1

Message

Author

emocookie41
Regular
Posts: 55
Joined: Thu Aug 29, 2013 4:44 pm
Projects: Island Story
Contact:

Contact emocookie41

Send private message

How do you make the scene shake?

  • Quote

#1Postby emocookie41 »

I've noticed in a few VNs that you can make the scenes shake, like when something dramatic happens. What piece of coding does that? I unfortunately only need it for like 2 parts of my game that I am making... Also how do you make it flash? Like a white light?

Top

Googaboga
Eileen-Class Veteran
Posts: 1395
Joined: Wed Dec 12, 2012 1:37 pm
Completed: https://gbpatch.itch.io/
Projects: Floret Bond, XOXO Blood Droplets, Our Life
Organization: GB Patch Games
Tumblr: gb-patch
itch: gbpatch
Contact:

Contact Googaboga

Send private messageTwitter

Re: How do you make the scene shake?

  • Quote

#2Postby Googaboga »

I know how to make it shake off the top of my head. It's right in the Cookbook. But I'll have to look go back and look up how to do a flash before I can explain it to you. Or maybe someone else can give you the answer sooner. Anyways here is how you make is shake:

Code: Select all

init: python: import math class Shaker(object): anchors = { 'top' : 0.0, 'center' : 0.5, 'bottom' : 1.0, 'left' : 0.0, 'right' : 1.0, } def __init__(self, start, child, dist): if start is None: start = child.get_placement() # self.start = [ self.anchors.get(i, i) for i in start ] # central position self.dist = dist # maximum distance, in pixels, from the starting point self.child = child def __call__(self, t, sizes): # Float to integer... turns floating point numbers to # integers. def fti(x, r): if x is None: x = 0 if isinstance(x, float): return int(x * r) else: return x xpos, ypos, xanchor, yanchor = [ fti(a, b) for a, b in zip(self.start, sizes) ] xpos = xpos - xanchor ypos = ypos - yanchor nx = xpos + (1.0-t) * self.dist * (renpy.random.random()*2-1) ny = ypos + (1.0-t) * self.dist * (renpy.random.random()*2-1) return (int(nx), int(ny), 0, 0) def _Shake(start, time, child=None, dist=100.0, **properties): move = Shaker(start, child, dist=dist) return renpy.display.layout.Motion(move, time, child, add_sizes=True, **properties) Shake = renpy.curry(_Shake) ##init: $ sshake = Shake((0, 0, 0, 0), 1.0, dist=15)# The game starts here.label start: scene bg whatev "Huh?! What happened?" with sshake return

Be sure to put the big init code before the start label and then use the command sshake after the start label when you want it to shake.

In-Progress:
Floret Bond, XOXO Blood Droplets, Our Life
Released:
A Foretold Affair, My Magical Divorce Bureau, XOXO Droplets, Lake of Voices

Top

emocookie41
Regular
Posts: 55
Joined: Thu Aug 29, 2013 4:44 pm
Projects: Island Story
Contact:

Contact emocookie41

Send private message

Re: How do you make the scene shake?

  • Quote

#3Postby emocookie41 »

Goodness you know that off the top of your head?! Well thank you! I feel better knowing that I can at least have the screen shake XD I'm still learning.

Top

Googaboga
Eileen-Class Veteran
Posts: 1395
Joined: Wed Dec 12, 2012 1:37 pm
Completed: https://gbpatch.itch.io/
Projects: Floret Bond, XOXO Blood Droplets, Our Life
Organization: GB Patch Games
Tumblr: gb-patch
itch: gbpatch
Contact:

Contact Googaboga

Send private messageTwitter

Re: How do you make the scene shake?

  • Quote

#4Postby Googaboga »

I wish XD. But really I just know where to find the code immediately and how to get it to work without refreshing my memory. So it only takes a few moments to put together an example. I still have to copy/paste it though How do you make the scene shake? (3). That's not the case with a flash where I have to reread stuff and test things to make sure I'm doing it right.

Anyways for a simple flash this should work:

Code: Select all

init: $ flash = Fade(.25, 0, .75, color="#fff") image bg whatev = "BG.png"# The game starts here.label start: "........................." "What is happening?" with flash#Or you could do this scene bg whatev with flash#You can use the flash to go to a new background or if you want it to be the same background just make sure the scene line lists the same background you were using in the last scene return

In-Progress:
Floret Bond, XOXO Blood Droplets, Our Life
Released:
A Foretold Affair, My Magical Divorce Bureau, XOXO Droplets, Lake of Voices

Top

emocookie41
Regular
Posts: 55
Joined: Thu Aug 29, 2013 4:44 pm
Projects: Island Story
Contact:

Contact emocookie41

Send private message

Re: How do you make the scene shake?

  • Quote

#5Postby emocookie41 »

I seem to be having trouble with the shake code...
How do you make the scene shake? (4)
How do you make the scene shake? (5)

I am not sure what is going on. I tried indenting it where the arrow is at and it did nothing to change it XD Any ideas?

Top

emocookie41
Regular
Posts: 55
Joined: Thu Aug 29, 2013 4:44 pm
Projects: Island Story
Contact:

Contact emocookie41

Send private message

Re: How do you make the scene shake?

  • Quote

#6Postby emocookie41 »

Fixed it... I had typed the code by hand since I didn't realize I could copy and paste XD I copy and pasted it and now it works fine lol

Top

Googaboga
Eileen-Class Veteran
Posts: 1395
Joined: Wed Dec 12, 2012 1:37 pm
Completed: https://gbpatch.itch.io/
Projects: Floret Bond, XOXO Blood Droplets, Our Life
Organization: GB Patch Games
Tumblr: gb-patch
itch: gbpatch
Contact:

Contact Googaboga

Send private messageTwitter

Re: How do you make the scene shake?

  • Quote

#7Postby Googaboga »

Cool :>. Does the flash work?

In-Progress:
Floret Bond, XOXO Blood Droplets, Our Life
Released:
A Foretold Affair, My Magical Divorce Bureau, XOXO Droplets, Lake of Voices

Top

trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Contact trooper6

Send private messageTwitter

Re: How do you make the scene shake?

  • Quote

#8Postby trooper6 »

Isn't there a much easier way to do the shake and flash? Isn't a quick vertical and horizontal shake and a flash defined already in renpy? I'm pretty sure I remember seeing it in the tutorial.

Edit: Aha! I found it! This page talks about both the predefined hpunch and vpunch, which do a quick shake, but also gives and example of a camera flash under the Fade transition:

http://www.renpy.org/doc/html/transitions.html

I also thing for a longer more continuous shaking, there would probably be an easier way to do it through ATL code or screen language, right?

A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)

Check out My Clock Cookbook Recipe:

Top

emocookie41
Regular
Posts: 55
Joined: Thu Aug 29, 2013 4:44 pm
Projects: Island Story
Contact:

Contact emocookie41

Send private message

Re: How do you make the scene shake?

  • Quote

#9Postby emocookie41 »

Just finished putting the flash in. It works perfectly! Thank you! And I will also take a look at the easy tutorial as well. This should work for this current project though ^^

Top

Googaboga
Eileen-Class Veteran
Posts: 1395
Joined: Wed Dec 12, 2012 1:37 pm
Completed: https://gbpatch.itch.io/
Projects: Floret Bond, XOXO Blood Droplets, Our Life
Organization: GB Patch Games
Tumblr: gb-patch
itch: gbpatch
Contact:

Contact Googaboga

Send private messageTwitter

Re: How do you make the scene shake?

  • Quote

#10Postby Googaboga »

I'm glad that worked out for you :]. As for the predefined commands they will work just fine however using them won't save you that much trouble in the future. The only added complexity of using these is you have to copy/paste the init code. After you do that they work the same way as the predefined commands. So using them won't make it much more difficult since copy/paste isn't hard to do. You will make your script a little shorter though if you use the predefined actions C:.

In-Progress:
Floret Bond, XOXO Blood Droplets, Our Life
Released:
A Foretold Affair, My Magical Divorce Bureau, XOXO Droplets, Lake of Voices

Top

Donmai
Eileen-Class Veteran
Posts: 1965
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Contact Donmai

Send private message

Re: How do you make the scene shake?

  • Quote

#11Postby Donmai »

trooper is right. Here is the discussion about the ATL shaking effect:
http://lemmasoft.renai.us/forums/viewto ... 20#p284320

No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

Top

Post Reply

  • Print view

11 posts• Page 1 of 1

Return to “Ren'Py Questions and Announcements”

Who is online

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

How do you make the scene shake? (2025)

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Rob Wisoky

Last Updated:

Views: 6477

Rating: 4.8 / 5 (48 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Rob Wisoky

Birthday: 1994-09-30

Address: 5789 Michel Vista, West Domenic, OR 80464-9452

Phone: +97313824072371

Job: Education Orchestrator

Hobby: Lockpicking, Crocheting, Baton twirling, Video gaming, Jogging, Whittling, Model building

Introduction: My name is Rob Wisoky, I am a smiling, helpful, encouraging, zealous, energetic, faithful, fantastic person who loves writing and wants to share my knowledge and understanding with you.