Combining Flash and Shake effects when damaged?

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
Plioket
Newbie
Posts: 4
Joined: Fri Jul 22, 2016 12:50 am
Contact:

Combining Flash and Shake effects when damaged?

#1 Post by Plioket » Fri Jul 22, 2016 1:03 am

Hello! I'm new to the forums and Ren'Py itself.
I'm currently making a game that has a really simple battle scene where you (as the player) will choose from 4 different moves and attack the opponent. When dealing damage/or when you're attacked, the screen shakes while flash is going on (and an attack sound effect will occur).
It's similar to Anghel's battle in Hatoful Boyfriend (Link is a bit spoilery) https://youtu.be/7AaNUyZYpTo?t=42s

I tried to make an init block to combine a shake effect with flash, but in the game, one effect would work while the other one wouldn't.

Code: Select all

init:
    define fflash = Fade(0.1, 0.0, 0.5, color="#fff")
init:
    $ sshake = Shake((0, 0, 0, 0), 1.0, dist=15)

init:
    define flash = Fade(.25, 0.0, .25, color="#fff")
    define quickflash = Fade(0.1, 0.0, 0.5, color="#fff")
    define attack = ComposeTransition(sshake, quickflash)
So I tried using an ATL code I found while looking for answers and I got a error message instead everytime I use 'at' instead of 'with.' I've looked over other forum posts/discussion, but none of them helped me solve my problem...
Thank you :U

User avatar
PyTom
Ren'Py Creator
Posts: 15893
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: Combining Flash and Shake effects when damaged?

#2 Post by PyTom » Sat Jul 23, 2016 1:27 am

Consider an ATL transition:

viewtopic.php?f=32&t=14678
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Combining Flash and Shake effects when damaged?

#3 Post by nyaatrap » Sat Jul 23, 2016 9:39 am

Shake transform I'm using.

Code: Select all

init -1 python:
    
    def _shake_function(trans, st, at, dt=.5, dist=64):
       #dt is duration timebase, dist is maximum shake distance in pixel
        if st <= dt: 
            trans.xoffset = int((dt-st)*dist*(.5-renpy.random.random())*2)
            trans.yoffset = int((dt-st)*dist*(.5-renpy.random.random())*2)
            return 1.0/60
        else:
            return None

transform shake(t=.5, d=64):
    function renpy.curry(_shake_function)(dt=t, dist=d)

User avatar
Plioket
Newbie
Posts: 4
Joined: Fri Jul 22, 2016 12:50 am
Contact:

Re: Combining Flash and Shake effects when damaged?

#4 Post by Plioket » Tue Jul 26, 2016 4:13 pm

PyTom wrote:Consider an ATL transition:

viewtopic.php?f=32&t=14678
I've been looking at this for a few days and I don't think I'm doing this right since I'm pretty new to Ren'Py and coding in general.
I don't know how to add the flash and shake to ATL transitions or coding ATL transitions in general.......

Code: Select all

transform attack(new_widget, old_widget):
    delay 0

    old_widget 
    fflash
    
    new_widget
    sshake

User avatar
Plioket
Newbie
Posts: 4
Joined: Fri Jul 22, 2016 12:50 am
Contact:

Re: Combining Flash and Shake effects when damaged?

#5 Post by Plioket » Wed Jul 27, 2016 12:49 am

Is there a way to combine https://www.renpy.org/wiki/renpy/doc/co ... ake_effect with a simple flash effect?
Like I did find an ATL shake transition where the screen keeps shaking but that's not what I want. I just want a shake that has one flash happening simultaneously in a few seconds. A little help please? I just need to know how to do this to finish my game..........

User avatar
Renpie
Newbie
Posts: 14
Joined: Sat Jul 11, 2015 9:49 am
Contact:

Re: Combining Flash and Shake effects when damaged?

#6 Post by Renpie » Sat Jun 27, 2020 11:49 am

Found this ancient thread about this issue and I solved it with solution like this:

Defined an image sequence like this:

Code: Select all

    image testbg:
        "testbg1.png"
        pause 0.05
        "testbg2.png"
        pause 0.05
        "red.png"
        pause 0.05
        "testbg3.png"
        pause 0.05
        "black.png" with fade
testbg1 is clear bg
testbg2 is bg with 50% red overlay
red is 100% red image
testbg3 is bg with blood on it
black is 100% black

And in the script I used:

Code: Select all

show testbg with vpunch
So it flashes to red once while shaking and fades in black.

Epilepsy warning if someone uses this.

-Renpie

Post Reply

Who is online

Users browsing this forum: No registered users