Random flashes for lightning effect

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
Ne0sam
Newbie
Posts: 1
Joined: Fri Apr 28, 2017 6:37 am
Contact:

Random flashes for lightning effect

#1 Post by Ne0sam » Fri Apr 28, 2017 6:45 am

Hi !

I'm trying to create a lightning effect by flashing the screen. My problem here is the random part. I want my flashes to appear after a random time, so I thought about using a transform I could apply on a white image.

This is the transform code I'm using, but the randomized pause seems to always last 1 sec (the minimum I set in my randint)

Code: Select all

transform storm:
    alpha 0.8
    pause 0.05
    linear 0.2 alpha 0
    pause renpy.random.randint(1, 5)
    repeat
Is it possible to get some random in transforms ? Because I guess the "renpy.random.randint" function doesn't work in a transform. Or am I misunderstanding the whole thing ?

I'd also like to get a screenshake everytime the flash appears. Should I do it with another transform ? How can I get it to sync with the flashes ?

Thanks in advance!

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

Re: Random in transforms

#2 Post by Imperf3kt » Fri Apr 28, 2017 6:57 am

randint is designed to work even with rollbacks, always generating the same number.
I can't currently think of a work around.

This may work if you modify it:
viewtopic.php?f=51&t=42259

I'll try something later if I get some time.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Twitter

User avatar
saguaro
Miko-Class Veteran
Posts: 556
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Projects: ?
Organization: Lucky Special Games
Tumblr: saguarofoo
itch: saguarofoo
Location: USA
Contact:

Re: Random flashes for lightning effect

#3 Post by saguaro » Sat Apr 29, 2017 4:46 pm

For the randomization, I think the easiest way is to put possible pause lengths in choice statements.

https://renpy.org/doc/html/atl.html?#choice-statement

Post Reply

Who is online

Users browsing this forum: KairuKyun