Lightning with Sound

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
PixelVirus89
Newbie
Posts: 3
Joined: Mon Aug 27, 2018 9:09 pm
Contact:

Lightning with Sound

#1 Post by PixelVirus89 »

Hi there!

I'm having a bit of a hard time trying to get this working so I thought I'd ask around for some ideas!

I'm trying to make a lighting effect that has sound. I thought it would be easy, but alas I can not figure it out! Here is the code I'm working with:

Code: Select all

image storm:
    "Backgrounds/whiteBG.jpg"
    renpy.sound.play('sounds/thunder.ogg')
    choice:
        alpha 0.8
        pause 0.05
        linear 0.2 alpha 0
        pause 17
    choice:
        alpha 0.8
        pause 0.05
        linear 0.2 alpha 0
        pause 15
    choice:
        alpha 0.8
        pause 0.05
        linear 0.2 alpha 0
        pause 13
    choice:
        alpha 0.8
        pause 0.05
        linear 0.2 alpha 0
        pause 10
    repeat
Then a simple "show storm" in the text. This however has a weird effect and the sound starts a few lines early and keeps playing over itself rapidly... The lighting effect seems to work though...

If someone could give me a point in the right direction I'd be most grateful!

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Lightning with Sound

#2 Post by Imperf3kt »

You can't place sound inside an ATL block like that. Separate them and just use two commands to play the sound and show the ATL at the same time.


Alternatively, create a screen that includes your ATL and a command to play the sound on show (and stop it on hide)

show the screen when needed, and hide it when not needed.
Do not use call screen function, and make sure the screen is modal False
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
PixelVirus89
Newbie
Posts: 3
Joined: Mon Aug 27, 2018 9:09 pm
Contact:

Re: Lightning with Sound

#3 Post by PixelVirus89 »

Thank you for your reply, I was hoping I could make the lighting random with the sound playing when it flashes. I think I may just keep it a set time if I can not do that.

Many thanks Imperf3kt!

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Lightning with Sound

#4 Post by Imperf3kt »

That should still be easy enough.

I'll see what I can create tonight after work. If you can supply the sound file, it would be a bit easier to tune it for your use.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
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:

Re: Lightning with Sound

#5 Post by Donmai »

Please look here: http://renpyfordummies.blogspot.com/201 ... st_19.html
Click on the link over the picture to download a sample project.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

Post Reply

Who is online

Users browsing this forum: Google [Bot]