1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. The long-awaited results for Concept Art Contest #11 have finally been released!
    Dismiss Notice
  3. Join Texturing Contest #30 now in a legendary battle of mythological creatures!
    Dismiss Notice
  4. The Aftermath has been revealed for the 19th Terraining Contest! Be sure to check out the Results and see what came out of it.
    Dismiss Notice
  5. Hivers united and created a bunch of 2v2 melee maps. Vote for the best in our Melee Mapping Contest #4 - Poll!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice

Fade System

Submitted by Chaosy
This bundle is marked as approved. It works and satisfies the submission rules.
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)​

[​IMG]

Code (WurstScript):

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)
Code (WurstScript):

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....
  1. stan0033

    stan0033

    Joined:
    Jun 27, 2010
    Messages:
    1,599
    Resources:
    14
    Models:
    4
    Packs:
    1
    Skins:
    2
    Maps:
    6
    Spells:
    1
    Resources:
    14
    Dude your map is empty.
     
  2. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,529
    Resources:
    17
    Maps:
    1
    Spells:
    10
    Tutorials:
    6
    Resources:
    17
    1. Wurst code is injected directly into the map which is why there are no triggers.
    2. There is no DEMO code to showcase the system since it is one function with one argument
     
  3. stan0033

    stan0033

    Joined:
    Jun 27, 2010
    Messages:
    1,599
    Resources:
    14
    Models:
    4
    Packs:
    1
    Skins:
    2
    Maps:
    6
    Spells:
    1
    Resources:
    14
    If it is injected then how are users supposed to use it?
     
  4. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,529
    Resources:
    17
    Maps:
    1
    Spells:
    10
    Tutorials:
    6
    Resources:
    17
    Wurst is not really compatible with jass and vjass, but if you already use wurst in your project you just copy the code from the main post.
    The wurst workflow takes care of the rest.
     
  5. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,529
    Resources:
    17
    Maps:
    1
    Spells:
    10
    Tutorials:
    6
    Resources:
    17
    Added demo triggers + preview gif.
     
  6. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,854
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    I should really write an Easings library
     
  7. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,220
    Resources:
    5
    Models:
    1
    Icons:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    5

    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.
     
  8. trebla ratilla

    trebla ratilla

    Joined:
    Oct 20, 2016
    Messages:
    349
    Resources:
    2
    Maps:
    2
    Resources:
    2
    hmm.. interesting spell :aht: