Bronya-Rand / DDLCModTemplate2.0

A new template for producing DDLC mods that adhere to Team Salvato's guidelines based off DDLC itself.
58 stars 18 forks source link

Better `Tear` effect #62

Closed Elckarow closed 1 year ago

Elckarow commented 1 year ago

-Better syntax / cleaner code -The size is now taken from the surface rather than renpy.get_physical_size. -Use of subpixel positioning (because why not?)

-Thanks to this 2nd change, displayables can also be "teared apart". (the code below is experimental. it works but... it also doesn't)

init python:
    class TearDisplayable(BaseTear):
        def __init__(self, number=10, offtimeMult=1, ontimeMult=1, offsetRange=(0, 50)):
            super(TearDisplayable, self).__init__(number, offtimeMult, ontimeMult, offsetRange)
            self.child = None

        def __call__(self, child):
            self.child = renpy.displayable(child)
            return self

        def render(self, w, h, st, at):
            cr = self.child.render(w, h, st, at)

            if self.tear.srf is None or self.tear.raw_size != cr.get_size():
                self.tear.update_srf(cr)

            return super(TearDisplayable, self).render(w, h, st, at)

label start:
    scene bg club_day
    show sayori turned at t11
    "..."
    show sayori at TearDisplayable()
    "..."

The displayable is glitched, but its position isn't where you want it to be.

This code aside, I think the clearer code makes it worth merging (tho i haven't written any doc for it)

Elckarow commented 1 year ago

im gonna close it for now. i'll get back to it later

Elckarow commented 1 year ago

i think it's good enough to be reopened

-the pieces now scale with the surface's size (imaging that you're drawing on a sheet of paper that's being stretched. you want to be able to draw as the paper's size changes. that's what this change does). -doc (ofc) -the TearDisplayable class. works perfectly. image sayori glitch = LayeredImageProxy("sayori turned", TearDisplayable())

enjoy

Elckarow commented 1 year ago

-added the chroma effect. it applies chromatic aberration to the pieces. -the size of the pieces is now a floating point value between 0.0 and 1.0. it's multiplied to the surface's height to get the correct size.

tl;dr: this pr is basically Gouvernathor's ChromaGlitch but better :monikk:

Elckarow commented 1 year ago

both Tear and TearDisplayable work on r6

Elckarow commented 1 year ago

-the key parameter allows displayables who share the same key to use the same tear effect.

say you have a layeredimage

image sayori turned tear = LayeredImageProxy("sayori turned", TearDisplayable())

label start:
    scene bg club_day
    show sayori turned tear at t11
    "..."
    show sayori mc
    "..."

the tear effect changes when executing show sayori mc. but if you were to add a key:

image sayori turned tear = LayeredImageProxy("sayori turned", TearDisplayable(key="sayori turned tear"))

label start:
    scene bg club_day
    show sayori turned tear at t11
    "..."
    show sayori mc
    "..."

it won't change