• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Fade System

  • Like
Reactions: deepstrasz
Simple fade system written in wurst.
Fades a unit in/out over X seconds.
Intended for cinematic use, but could be used when a unit dies in a TD for example.

API:

yourUnit.fadeOut(duration)
yourUnit.fadeIn(duration)​

a3cb6d7c951902d19bfa3ee32d3af168.gif


Wurst:
package Fade

import TimerUtils
import LinkedListModule

timer t

public enum fadetype
    IN
    OUT

public function unit.fade(fadetype ft, real duration)
    new Fade(this, ft, duration)

public function unit.fadeOut(real duration)
    this.fade(fadetype.OUT, duration)

public function unit.fadeIn(real duration)
    this.fade(fadetype.IN, duration)

function unit.setFade(integer raw)
    this.setVertexColor(colorA(255,255,255, raw))

public class Fade
    use LinkedListModule
    unit fader
    real changeSpeed
    real fadeState
    construct(unit u, fadetype ft, real duration)
        changeSpeed = (255 / duration) * 0.03

        if(ft == fadetype.IN)
            changeSpeed *= -1
            fadeState = 0
        else
            fadeState = 255

        fader = u

function onLoop()
    Fade current = Fade.first
    while(current != null)
        current.fadeState -= current.changeSpeed
        current.fader.setFade(R2I(current.fadeState))
        if(current.fadeState >= 255 or current.fadeState <= 0)
            Fade next = current.next
            destroy current
            current = next
        else
            current = current.next

init
    t = getTimer()
    t.startPeriodic(0.03, function onLoop)
Wurst:
package Demo

import Fade
import TimerUtils

boolean tracker = false
unit test
real speed = 1

init
test = createUnit(players[0], 'Hpal', vec2(0, 0), angle(0))

test.fadeOut(speed)

getTimer()
..startPeriodic(speed, () -> begin
if(tracker)
test.fadeOut(speed)
tracker = false
else
test.fadeIn(speed)
tracker = true
end)
Contents

Fade System (Map)

Reviews
MyPad
Nitpicks: Since there are quite some Fade Systems already made for users here, it would affect the overall rating. A bit of documentation goes a long way. Notes: None Quirks: I like how short this system is, compared to other Fade systems...

Nitpicks:

  • Since there are quite some Fade Systems already made for users here, it would affect the overall rating.
  • A bit of documentation goes a long way.

Notes:

  • None

Quirks:

  • I like how short this system is, compared to other Fade systems.
  • Since there are no Wurst equivalents of Fade Systems as far as I know, this could affect my rating.

Status:


This resource has been Approved.
 
Top