Underworld (a Platformer)

Instructions: Use arrow keys or WASD to move.\nUse up arrow, W, space, or click to jump.\nPress 'M' to toggle sounds\nPress 'L' to toggle Low Detail Mode (fewer clones)\nPress 'Q+R' to restart level\nIn Knobbelboy mode, you get 3 lives.\nMobile mode makes movement buttons magically appear at the bottom of the screen. (1st to beat this in mobile mode with Knobbelboy mode turned on gets a special prize check notes and credits)\nAvoid hitting spikes.\n\nTip for UFO levels: Sometimes, it helps to tap in the rhythm of "Happy Birthday" but slowed down a bit for some reason.\n\nAccording to scratch statistics, only 4.7% of the people who play this stared it and only 5.3% of the people who play this hearted it, so please consider hearting and starring (and following)

@Stage\n\nwhen I receive [play v]\nswitch backdrop to (item ([floor v] of (level) ) of [bg v])\n\nwhen I receive [begin v]\nbroadcast (play v)\nreset timer\nforever\n    if <(level) < (Last level)> then\n        play sound [Dimrain47 - At the speed of light v] until done\n    end\nend\n\nwhen I receive [start up v]\nstop [other scripts in sprite v]\nstop all sounds\nforever\n    if <<key (m v) pressed?> and <(mPressing) = [0]>> then\n        set [volume v] to ((((volume) mod (49)) - (1)) * (-50))\n        set volume to (volume) %\n        set [mpressing v] to [1]\n    else\n        if <not <key (m v) pressed?>> then\n            set [mpressing v] to [0]\n        end\n    end\n    if <<key (l v) pressed?> and <(lPressing) = [0]>> then\n        set [ldm v] to <not <(LDM) = [true]>>\n        set [lpressing v] to [1]\n    else\n        if <not <key (l v) pressed?>> then\n            set [lpressing v] to [0]\n        end\n    end\nend\n\n@Player\n\ndefine Cube\nif <not <(level) = (Last level)>> then\n    control [-1] []\n    switch costume to (cube v)\n    if <touching (platforms v)?> then\n        change y by ((yVel) * ((gravity) * (-1)))\n        set [yvel v] to [0]\n    end\n    change y by ((gravity) * (-1))\n    if <(item (1) of [bools v]) and <touching (platforms v)?>> then\n        set [yvel v] to [13.5]\n    end\n    jump\nend\n\ndefine detection (in if loop?) (gravity)\nif <(in if loop?) = [0]> then\n    set [i v] to [1]\n    detection (i) (gravity)\nelse\n    if <(in if loop?) < [6]> then\n        if <touching (platforms v)?> then\n            change y by (gravity)\n            change [i v] by (1)\n            detection (i) (gravity)\n        end\n    else\n        if <touching (platforms v)?> then\n            change x by ((xVel) * (-1))\n            change y by ((gravity) * (-5))\n            if (item (1) of [bools v]) then\n                if <(xVel) > [0]> then\n                    set [xvel v] to [-5]\n                else\n                    set [xvel v] to [5]\n                end\n                if <[cube v] contains (level)?> then\n                    set [yvel v] to [10]\n                else\n                    set [xvel v] to [0]\n                end\n            else\n                set [xvel v] to [0]\n            end\n        end\n    end\nend\n\nwhen I receive [play v]\nif <(clone id) = [10]> then\n    go to x: (-210) y: (item (level) of [start y v])\n    if <[mini v] contains (level)?> then\n        set size to (30) %\n    else\n        set size to (53) %\n    end\n    if <[cube v] contains (level)?> then\n        set [gamemode v] to [1]\n    else\n        if <[ufo v] contains (level)?> then\n            set [gamemode v] to [4]\n        else\n            if <[ball v] contains (level)?> then\n                set [gamemode v] to [3]\n            else\n                set [gamemode v] to [2]\n            end\n        end\n    end\n    set [xvel v] to [0]\n    set [yvel v] to [0]\n    clear graphic effects\n    wait (0.1) seconds\n    forever\n        go to [front v] layer\n        if <(gamemode) = [1]> then\n            Cube\n        else\n            if <(gamemode) = [2]> then\n                Ship\n            else\n                if <(gamemode) = [3]> then\n                    ball\n                else\n                    ufo\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [die v]\nset [time v] to ((time) + (timer))\nchange [deaths v] by (1)\nset volume to (volume) %\nstop [other scripts in sprite v]\nset [particle velocity v] to [30]\nset [clone id v] to [-1]\ncreate clone of (_myself_ v)\nset [clone id v] to [10]\nset [ghost v] effect to (100)\nset [pause v] to [0]\nrepeat until <<(pause) = [36]> or <not (item (1) of [bools v])>>\n    change [pause v] by (1)\nend\nrepeat until <<(pause) = [36]> or <(item (1) of [bools v]) and <(pause) > [11]>>>\n    change [pause v] by (1)\nend\nset [gravity v] to [1]\nif <<(Knobbelboy mode) = [1]> and <(lives) = [0]>> then\n    broadcast (GG v)\n    stop [this script v]\nend\nset [level v] to ([floor v] of (level) )\ngo to x: (-210) y: (item (level) of [start y v])\nif <(level) = [16]> then\n    switch costume to (ship0 v)\n    set [gamemode v] to [2]\nend\nbroadcast (play v)\nreset timer\n\ndefine Clone (n)\nswitch costume to (death effect2 v)\nrepeat (n)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nif <(clone id) = [-1]> then\n    death effect start\n    set [clone id v] to [1]\n    explode [5] [2.01] [] [2] [0.75]\n    create clone of (_myself_ v)\n    explode [4] [2.01] [] [2] [0.75]\n    create clone of (_myself_ v)\n    explode [6] [-2.01] [] [2] [1.3333333333]\nelse\n    if <(clone id) = [0]> then\n        point in direction (pick random (0.) to (360))\n        set [ghost v] effect to (pick random (1) to (10))\n        set [particle velocity v] to (pick random (5) to (13))\n        set size to (pick random (50) to (100)) %\n        explode [15] [2] [2] [3] [0.8]\n        explode [10] [2] [-2] [3] [1.25]\n    else\n        set size to (0) %\n        switch costume to (death effect3 v)\n        set [particle velocity v] to [30]\n        go [backward v] (3) layers\n        explode [10] [2.01] [0] [3] [0.9]\n    end\nend\nforever\n    delete this clone\nend\n\ndefine explode (reps) (grow) (steps) (fade) (rate)\nrepeat (reps)\n    move ((particle velocity) * (steps)) steps\n    set [particle velocity v] to ((particle velocity) * (rate))\n    change [ghost v] effect by (fade)\n    if <([abs v] of (grow) ) > [2]> then\n        change size by ((particle velocity) * (grow))\n    else\n        change size by (grow)\n    end\nend\n\nwhen I receive [next v]\nchange [level v] by (1)\nbroadcast (play v)\n\ndefine Ship\nswitch costume to (ship hitbox v)\npoint in direction (90)\ncontrol [-1] []\nif <touching (platforms v)?> then\n    change y by ((yVel) * ((gravity) * (-1)))\n    set [yvel v] to [0]\nend\nchange y by ((gravity) * (-1))\nif (item (1) of [bools v]) then\n    change [yvel v] by (2)\nend\nchange y by (gravity)\nif <not <touching (platforms v)?>> then\n    set [dir v] to ((90) - (((yVel) * (3)) * (gravity)))\nend\nif <(x position) > [240]> then\n    broadcast (next v)\nend\nif <[-240] > (x position)> then\n    set [xvel v] to [0]\nend\npoint in direction (dir)\nswitch costume to (join [Ship] ((1) - (gravity)))\n\ndefine control (vel decrease) (dir)\nset [costume v] to (costume [number v])\nif <<<<touching (moving hazards v)?> or <touching (hazards v)?>> or <(y position) < [-160]>> and <(can die) = [1]>> then\n    broadcast (die v)\nend\nif (item (3) of [bools v]) then\n    change [xvel v] by (1)\nend\nif (item (2) of [bools v]) then\n    change [xvel v] by (-1)\nend\nif <[-20] > (xVel)> then\n    set [xvel v] to [-20]\nelse\n    if <(xVel) > [20]> then\n        set [xvel v] to [20]\n    end\nend\nchange x by (xVel)\nif <not <[ball v] contains (level)?>> then\n    detection [0] (gravity)\n    change [yvel v] by (vel decrease)\n    change y by ((yVel) * ((gravity) * ((dir) + (1))))\nelse\n    detection [0] ((-1) * (gravity))\n    change [yvel v] by (vel decrease)\n    change y by ((yVel) * (((-1) * (gravity)) * ((dir) + (1))))\nend\nset [xvel v] to ((xVel) * (0.9))\nif <(x position) < [-240]> then\n    set x to (-240)\n    set [xvel v] to [0]\nend\nif <(y position) > [200]> then\n    set y to (200)\nend\n\ndefine jump\nchange y by (gravity)\npoint in direction ((gravity) * (90))\nif <(x position) > [240]> then\n    broadcast (next v)\nend\nif <[-240] > (x position)> then\n    set [xvel v] to [0]\nend\n\ndefine ufo\nswitch costume to (ufo hitbox v)\ncontrol [-1] []\nif <touching (platforms v)?> then\n    change y by ((yVel) * ((gravity) * (-1)))\n    set [yvel v] to [0]\nend\nchange y by ((gravity) * (-1))\nif (item (1) of [bools v]) then\n    if <(key?) = [0]> then\n        set [yvel v] to [11]\n        set [key? v] to [1]\n    end\nelse\n    set [key? v] to [0]\nend\njump\nswitch costume to (ufo v)\n\ndefine ball\nswitch costume to (ball hitbox v)\npoint in direction (90)\ncontrol [-1.25] [-2]\nchange [dir v] by ((gravity) * (10))\nif <touching (platforms v)?> then\n    repeat until <<not <touching (platforms v)?>> or <touching (hazards v)?>>\n        change y by (gravity)\n    end\n    change y by ((gravity) * (-1))\n    set [yvel v] to [0]\nend\nif (item (1) of [bools v]) then\n    if <(key?) = [0]> then\n        if <touching (platforms v)?> then\n            set [gravity v] to ((gravity) * (-1))\n            set [yvel v] to [-3]\n            set [key? v] to [1]\n        end\n    end\nelse\n    set [key? v] to [0]\nend\nchange y by (gravity)\nif <(x position) > [239]> then\n    broadcast (next v)\nend\nif <[-239] > (x position)> then\n    set [xvel v] to [0]\nend\nswitch costume to (ball v)\npoint in direction (dir)\nif <touching (hazards v)?> then\n    broadcast (die v)\nend\n\nwhen I receive [gg v]\nstop [other scripts in sprite v]\nclear graphic effects\nset [opacity v] to [1]\nrepeat (15)\n    set [opacity v] to ((opacity) * (1.35935639087852566664339))\n    set [ghost v] effect to (opacity)\nend\nhide\n\nwhen I receive [begin v]\nset [time v] to [0]\nreset timer\nshow\n\nwhen I receive [play v]\npoint in direction (90)\nif <<(level) = (Last level)> and <(clone id) = [10]>> then\n    stop all sounds\n    set volume to ((volume) * (2)) %\n    start sound [endStart_02.mp3 v]\n    switch costume to (cube v)\n    go to [front v] layer\n    set [yvel v] to [13.5]\n    set [xvel v] to [10]\n    Curve 1 [-0.3125] [-0.9] [32]\n    Curve 2 [0.5] []\n    set [yvel v] to ([abs v] of (yVel) )\n    Curve 2 [] [2]\n    Curve 1 [-1] [1] [16]\n    Curve 1 [-1] [-2] [16]\nend\n\ndefine Curve 2 (growth1) (growth2)\nrepeat (4)\n    set [yvel v] to ((yVel) * (growth1))\n    change y by (yVel)\n    set [yvel v] to ((yVel) * (growth2))\n    turn right (8) degrees\n    change x by ([abs v] of (xVel) )\n    change [xvel v] by (-0.3333333333)\nend\n\ndefine Curve 1 (x growth) (y growth) (iterations)\nrepeat (iterations)\n    change [yvel v] by (y growth)\n    change y by (yVel)\n    turn right (8) degrees\n    change x by (([abs v] of (xVel) ) * (1.125))\n    change [xvel v] by (x growth)\nend\n\nwhen I receive [play v]\nif <<(level) = (Last level)> and <(clone id) = [10]>> then\n    set [time v] to ((time) + (timer))\n    wait (4.38) seconds\n    broadcast (GG v)\nend\n\ndefine death effect start\nset volume to (volume) %\nclear graphic effects\nstart sound [explode_11.mp3 v]\nset [clone id v] to [0]\nClone (pick random (45) to (55))\nswitch costume to (death effect1 v)\nset [ghost v] effect to (30)\nset size to (0) %\n\nwhen I receive [play v]\nrepeat (10)\n    set [gravity v] to [1]\nend\nforever\n    delete this clone\nend\n\nwhen I receive [start up v]\nset [can die v] to [1]\nset [deaths v] to [0]\nset [clone id v] to [10]\nhide variable [global_display_style v]\nhide variable [deaths v]\nhide variable [time v]\nhide variable [level v]\nhide\n\nwhen flag clicked\nbroadcast (Start up v)\n\nwhen I start as a clone\nwait (0.1) seconds\nforever\n    if <<(costume [number v]) = [5]> or <(costume [number v]) = [6]>> then\n        delete this clone\n    end\nend\n\nforever\n    if <(is dead) = [true]> then\n        broadcast (die v) and wait\n    end\nend\n\nwhen I receive [play v]\n\nwhen I receive [play v]\nforever\n    if <<<not < (costume [name v]) contains [death]?>> and <(can die) = [1]>> and <<touching (moving hazards v)?> or <touching (hazards v)?>>> then\n        broadcast (die v)\n    end\nend\n\n@Platforms\n\nwhen I receive [collect v]\nnext costume\n\nwhen I receive [play v]\nswitch costume to (join [Level ] (level))\nif <<(level) = [16]> or <(level) = [12]>> then\n    set [ghost v] effect to (100)\nelse\n    clear graphic effects\nend\n\nwhen I receive [begin v]\ngo to [front v] layer\ngo to x: (0) y: (0)\nshow\n\nwhen I receive [start up v]\nhide\n\n@Hazards\n\nwhen I receive [collect v]\nnext costume\n\ndefine spin (lvl)\nset [lvl v] to ((level) + (lvl))\nrepeat until <(level) = (lvl)>\n    repeat (3)\n        next costume\n    end\n    switch costume to (join [Level ] (level))\nend\n\nwhen I receive [play v]\nswitch costume to (join [Level ] (level))\ngo to [front v] layer\ngo [backward v] (1) layers\n\nwhen I receive [begin v]\nshow\ngo to x: (0) y: (0)\nforever\n    if <[multisteps v] contains (level)?> then\n        spin [0.1]\n    else\n        spin [1]\n    end\nend\n\nwhen I receive [start up v]\nhide\n\n@Deco\n\nwhen I receive [next v]\nnext costume\nset [level v] to ([floor v] of (level) )\n\nwhen I receive [collect v]\nnext costume\n\nwhen I receive [play v]\ngo to [back v] layer\nswitch costume to (join [Level ] (level))\nshow\nif <<(level) > [2]> and <not <(level) = [6]>>> then\n    go to [front v] layer\nend\nif <[gear deco v] contains (level)?> then\n    repeat until <(level) = (lvl)>\n        if <(level) = [5]> then\n            repeat (3)\n                next costume\n            end\n        else\n            repeat (7)\n                next costume\n            end\n        end\n        switch costume to (join [Level ] (level))\n    end\nend\n\nwhen I receive [begin v]\ngo to x: (0) y: (0)\nshow\n\nwhen I receive [start up v]\nset [cloned v] to [0]\nhide\n\nset [brightness v] effect to (100)\n\n@Moving Hazards\n\nwhen I start as a clone\nif <(level) = [8]> then\n    if <(costume [number v]) = [2]> then\n        change y by (-15)\n    else\n        change y by (15)\n    end\n    set [y v] to (y position)\n    go to [front v] layer\n    repeat until <not <(level) = [8]>>\n        if <(([x position v] of [player v]) + (240)) > (x position)> then\n            glide (0.125) secs to x: (x position) y: (0)\n        else\n            if <(y position) = [0]> then\n                glide (0.125) secs to x: (x position) y: (y)\n            end\n        end\n    end\nelse\n    if <(costume [number v]) = [4]> then\n        go to x: (0) y: (0)\n        repeat until <not <(level) = [16]>>\n            if <(([x position v] of [player v]) + (210)) > (x position)> then\n                glide (0.125) secs to x: (x position) y: (35)\n            else\n                glide (0.125) secs to x: (x position) y: (0)\n            end\n        end\n    else\n        go to x: (125) y: (-180)\n        point in direction (180)\n        repeat until <not <(level) = [16]>>\n            if <(([x position v] of [player v]) + (100)) > (x position)> then\n                if <(direction) = [180]> then\n                    repeat (10)\n                        turn left (9) degrees\n                    end\n                end\n            else\n                if <(direction) = [90]> then\n                    repeat (10)\n                        turn right (9) degrees\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine clone (level)\nif <(level) = [8]> then\n    repeat (7)\n        switch costume to (level 8.1 v)\n        create clone of (_myself_ v)\n        next costume\n        create clone of (_myself_ v)\n        change x by (50.5)\n    end\n    hide\nelse\n    switch costume to (level 16.1 v)\n    create clone of (_myself_ v)\n    next costume\n    create clone of (_myself_ v)\n    hide\nend\n\nwhen I receive [next v]\nwait (0.01) seconds\npoint in direction (90)\nhide\ngo to x: (0) y: (0)\nif <<(level) = [8]> or <(level) = [16]>> then\n    show\n    if <(level) = [8]> then\n        clone [8]\n    else\n        clone [16]\n    end\nelse\n    delete this clone\nend\n\nwhen I receive [start up v]\nhide\n\n@Jump pads/portals\n\nwhen I receive [collect v]\nset [first run v] to [1]\nwait (0.001) seconds\nswitch costume to (join [Level ] (level))\nif <(level) = [2.2]> then\n    Read code\n    go to x: (item (2) of [portal data v]) y: (item (3) of [portal data v])\n    repeat until <not <(level) = [2.2]>>\n        if <<touching (player v)?> and <(distance to [player v]) < (item (costume [number v]) of [max distances v])>> then\n            portal action [1]\n            wait until <not <touching (player v)?>>\n        end\n    end\n    switch costume to (level 2 v)\nend\n\nwhen I receive [next v]\nset [first run v] to [1]\ndelete this clone\n\nwhen I receive [play v]\nif <[portals v] contains (level)?> then\n    forever\n        Burst\n    end\nend\n\nwhen I start as a clone\nforever\n    switch costume to (join (join [Level ] (level)) [.1])\n    go to x: (item (5) of [portal data v]) y: (item (6) of [portal data v])\n    repeat until <(is dead) = [true]>\n        Find Distance from (x position) (y position) to ([x position v] of [player v]) ([y position v] of [player v])\n        if <<touching (player v)?> and <(Distance) < (item (costume [number v]) of [max distances v])>> then\n            portal action [4]\n            if <not <(level) = [6]>> then\n                wait until <<(is dead) = [true]> or <not <<touching (player v)?> or <(Distance) < (item (costume [number v]) of [max distances v])>>>>\n            else\n                wait until <<(is dead) = [true]> or <not <<touching (player v)?> and <(Distance) < (item (costume [number v]) of [max distances v])>>>>\n            end\n        end\n    end\n    wait until <(is dead) = [false]>\nend\n\ndefine Burst\nif <not < ([costume name v] of [player v]) contains [death]?>> then\n    if <<touching (player v)?> and <(distance to [player v]) < (item (costume [number v]) of [max distances v])>> then\n        change [brightness v] effect by (100)\n        change [ghost v] effect by (-10)\n        repeat (10)\n            change [brightness v] effect by (-10)\n            change [ghost v] effect by (1)\n        end\n    end\n    wait until <not <<touching (player v)?> and <(distance to [player v]) < (item (costume [number v]) of [max distances v])>>>\nend\n\nwhen I start as a clone\nif <[portals v] contains (level)?> then\n    repeat until <(level) = (lvl)>\n        Burst\n    end\nend\n\ndefine pulse\nset [origcostume v] to (costume [number v])\nset [pulseframe v] to [0]\nrepeat (3)\n    change [pulseframe v] by (1)\n    if <(is dead) = [false]> then\n        switch costume to ((origCostume) + (pulseFrame))\n    else\n        switch costume to (origCostume)\n    end\nend\nrepeat (3)\n    change [pulseframe v] by (-1)\n    if <(is dead) = [false]> then\n        switch costume to ((origCostume) + (pulseFrame))\n    else\n        switch costume to (origCostume)\n    end\nend\n\nwhen I receive [start up v]\nhide\n\ndefine Find Distance from (x) (y) to (x2) (y2)\nset [distance v] to ([sqrt v] of ((((x) - (x2)) * ((x) - (x2))) + (((y) - (y2)) * ((y) - (y2)))) )\n\ndefine read (string)\nset [portal data v] to []\nrepeat until <(letter ((i2) + (1)) of (string)) = [;]>\n    change [i2 v] by (1)\n    set [portal data v] to (join (portal data) (letter (i2) of (string)))\nend\nchange [i2 v] by (1)\n\ndefine Read code\nset [item v] to (item (item # of (level) in [jump pads or portals v]) of [portals/jump pad data v])\ndelete all of [portal data v]\nset [i2 v] to [2]\nrepeat ((3) * (letter (1) of (item)))\n    read (item)\n    add (portal data) to [portal data v]\nend\n\ndefine portal action (type)\nif <(item (type) of [portal data v]) = [1]> then\n    set [yvel v] to [20]\nelse\n    if <(item (type) of [portal data v]) = [2]> then\n        set [gravity v] to [-1]\n        if <not <(level) = [9]>> then\n            set [yvel v] to [0]\n        else\n            set [yvel v] to [-10]\n        end\n    else\n        if <(item (type) of [portal data v]) = [3]> then\n            set [gravity v] to [1]\n            if <not <(level) = [9]>> then\n                set [yvel v] to [0]\n            else\n                set [yvel v] to [20]\n            end\n        else\n            repeat until <<([x position v] of [player v]) > [-10]> or <not <touching (player v)?>>>\n                set [yvel v] to [0]\n            end\n            set [gamemode v] to [1]\n            set [gravity v] to [1]\n        end\n    end\nend\n\nwhen I receive [die v]\nset [is dead v] to [true]\n\nwhen I receive [play v]\nset [is dead v] to [false]\nset [lvl v] to ([ceiling v] of ((level) + (0.1)) )\nswitch costume to (join [Level ] (level))\nshow\nif <[jump pads or portals v] contains (level)?> then\n    Read code\n    if <<[portals v] contains (level)?> and <not <(level) = [15]>>> then\n        set [ghost v] effect to (10)\n        set [brightness v] effect to (-100)\n    else\n        clear graphic effects\n    end\n    if <(first run) = [1]> then\n        if <(letter (1) of (item)) = [2]> then\n            create clone of (_myself_ v)\n        end\n    end\n    set [cloned v] to [1]\n    go to x: (item (2) of [portal data v]) y: (item (3) of [portal data v])\nend\nset [first run v] to [false]\nrepeat until <(level) = (lvl)>\n    if <<(is dead) = [false]> and <<touching (player v)?> and <(distance to [player v]) < (item (costume [number v]) of [max distances v])>>> then\n        portal action [1]\n        wait until <not <<touching (player v)?> or <(distance to [player v]) < (item (costume [number v]) of [max distances v])>>>\n    end\nend\n\nbroadcast (next v)\n\nwhen I receive [play v]\nif <(level) = [15]> then\n    repeat until <(level) = (lvl)>\n        pulse\n    end\nend\n\nwhen I receive [play v]\nif <(costume [number v]) = [28]> then\n    repeat until <not <(level) = [16]>>\n        if <(is dead) = [true]> then\n            set [swappedmodes? v] to [0]\n        end\n        if <<([x position v] of [player v]) > [-10]> or <(swappedModes?) = [1]>> then\n            set [swappedmodes? v] to [1]\n            set [gamemode v] to [1]\n            set [gravity v] to [1]\n        else\n            set [gamemode v] to [2]\n            if <([x position v] of [player v]) > [-170]> then\n                if <(gravity) = [1]> then\n                    set [yvel v] to [0]\n                end\n                set [gravity v] to [-1]\n            else\n                set [gravity v] to [1]\n            end\n        end\n    end\nend\n\n@Keys\n\nwhen I receive [play v]\nswitch costume to (join [Level ] (level))\ngo\n\nwhen I receive [next v]\nnext costume\n\nwhen I receive [die v]\nstop [other scripts in sprite v]\n\nwhen I receive [collect v]\nchange [level v] by (0.1)\nnext costume\nclear graphic effects\ngo\n\ndefine go\nshow\nclear graphic effects\npoint in direction (0)\nif <(level) = [2]> then\n    go to x: (-198) y: (87)\nelse\n    if <(level) = [2.1]> then\n        go to x: (-47) y: (-97)\n    else\n        go to x: (0) y: (0)\n        hide\n    end\nend\nwait until <touching (player v)?>\nbroadcast (collect v)\ncreate clone of (_myself_ v)\n\ndefine drop (reps) (-vel) (fade) (rotate) (down) (right)\nrepeat (reps)\n    turn right (rotate) degrees\n    change x by ((right) * ([abs v] of ([atan v] of (key vel) ) ))\n    change y by ((down) * (key vel))\n    change [key vel v] by (-vel)\n    change [ghost v] effect by (fade)\nend\n\nwhen I receive [begin v]\nswitch costume to (level 1 v)\nshow\n\nwhen I start as a clone\nclear graphic effects\nshow\npoint in direction (0)\nset [key vel v] to [10]\ngo to [front v] layer\ndrop [7] [-1] [0] [4] [1] [0.03333]\ndrop [10] [-1.2] [0] [3] [1] [0.05]\ndrop [7] [-1.2] [14.2857142857142857143] [2] [1] [0.0666666]\ndelete this clone\n\nwhen I receive [start up v]\nhide\n\n@Particles\n\nwhen I receive [start up v]\nhide\nInnit\nforever\n    draw\nend\n\ndefine draw\nshow\nset [particle id v] to [0]\nerase all\nif <(LDM) = [false]> then\n    repeat (200)\n        change [particle id v] by (1)\n        set pen color to (item (particle ID) of [clone colors v])\n        set pen (brightness v) to ((item (particle ID) of [clone brightness v]) - ((2) * (item (particle ID) of [clone frame v])))\n        set pen (transparency v) to ((item (particle ID) of [clone ghost v]) + ((15) * (item (particle ID) of [clone frame v])))\n        go to x: (item (particle ID) of [clone x v]) y: ((item (particle ID) of [clone y v]) - ((2) * (item (particle ID) of [clone frame v])))\n        replace item (particle ID) of [clone frame v] with ((item (particle ID) of [clone frame v]) + (1))\n        pen down\n        pen up\n        set pen size to (3)\n        if <(item (particle ID) of [clone frame v]) = [5]> then\n            replace item (particle ID) of [clone frame v] with [0]\n            replace item (particle ID) of [clone brightness v] with (pick random (80) to (15))\n            replace item (particle ID) of [clone colors v] with (item (pick random (1) to (3)) of [colors v])\n            replace item (particle ID) of [clone ghost v] with (pick random (10) to (20))\n            replace item (particle ID) of [clone x v] with (pick random (-240) to (240))\n            replace item (particle ID) of [clone y v] with (pick random (-150) to (180))\n        end\n    end\nend\nhide\n\ndefine Innit\ndelete all of [clone brightness v]\ndelete all of [clone colors v]\ndelete all of [clone frame v]\ndelete all of [clone ghost v]\ndelete all of [clone x v]\ndelete all of [clone y v]\nrepeat (200)\n    add (pick random (0) to (-87.5)) to [clone brightness v]\n    add (pick random (0) to (5)) to [clone frame v]\n    add (pick random (1) to (3)) to [clone colors v]\n    add (pick random (10) to (20)) to [clone ghost v]\n    add (pick random (-240) to (240)) to [clone x v]\n    add (pick random (-150) to (180)) to [clone y v]\nend\n\n@Glow effect\n\nwhen I receive [begin v]\nshow\nswitch costume to ( v)\nset size to (133) %\nnext costume\nset [ghost v] effect to (50)\nforever\n    glide (0.75) secs to x: (pick random (-220) to (220)) y: (pick random (-140) to (140))\n    go to [back v] layer\nend\n\nwhen I receive [start up v]\nhide\n\n@Beam effect\n\nwhen flag clicked\nhide\npoint in direction (90)\ngo to x: (0) y: (180)\nforever\n    if <(LDM) = [false]> then\n        repeat (144)\n            turn right (2.5) degrees\n            create clone of (_myself_ v)\n            next costume\n            create clone of (_myself_ v)\n            next costume\n            wait (0.125) seconds\n        end\n        repeat (144)\n            turn right (-2.5) degrees\n            create clone of (_myself_ v)\n            next costume\n            create clone of (_myself_ v)\n            next costume\n            wait (0.125) seconds\n        end\n    end\nend\n\nwhen I start as a clone\ngo to [back v] layer\nset y to ((costume [name v]) * (180))\nset [ghost v] effect to (93)\nshow\nrepeat (72)\n    rotate [2.5] [1.8]\nend\nrepeat (72)\n    rotate [-2.5] [-1.8]\nend\ndelete this clone\n\ndefine rotate (deg) (brightness)\nset [brightness v] effect to ((costume [name v]) * ((y position) / (brightness)))\nturn right ((costume [name v]) * (deg)) degrees\nchange y by ((costume [name v]) * (-2.5))\n\nwhen I start as a clone\nforever\n    if <(LDM) = [true]> then\n        delete this clone\n    end\nend\n\n@Menu\n\nwhen I start as a clone\nif <<(costume [number v]) = [1]> or <(costume [number v]) = [15]>> then\n    set x to (-215)\n    forever\n        if <(Help Screen) = [0]> then\n            show\n        else\n            hide\n        end\n        if <<touching (mouse-pointer v)?> and <mouse down?>> then\n            wait until <not <mouse down?>>\n            if <touching (mouse-pointer v)?> then\n                if <(x position) = [-194]> then\n                    if <(costume [number v]) = [1]> then\n                        set [knobbelboy mode v] to [0]\n                        glide (0.12) secs to x: (-215) y: (162)\n                    else\n                        set [mobile mode v] to [0]\n                        glide (0.12) secs to x: (-215) y: (110)\n                    end\n                else\n                    if <(costume [number v]) = [1]> then\n                        set [knobbelboy mode v] to [1]\n                        glide (0.12) secs to x: (-194) y: (162)\n                    else\n                        set [mobile mode v] to [1]\n                        glide (0.12) secs to x: (-194) y: (110)\n                    end\n                end\n            end\n        end\n    end\nelse\n    if <(costume [number v]) = [3]> then\n        forever\n            if <(Help Screen) = [0]> then\n                show\n            else\n                hide\n            end\n            go to x: (0) y: (-60)\n            if <touching (mouse-pointer v)?> then\n                set [brightness v] effect to (10)\n                set size to (121) %\n                if <mouse down?> then\n                    set size to (140) %\n                    set [brightness v] effect to (25)\n                    wait until <not <mouse down?>>\n                    set size to (120) %\n                    if <touching (mouse-pointer v)?> then\n                        set [help screen v] to [1]\n                        set [slide_number v] to [5]\n                        hide\n                    end\n                end\n            else\n                clear graphic effects\n                set size to (120) %\n            end\n        end\n    else\n        if <(costume [number v]) = [12]> then\n            forever\n                Arrow at: [200] [-125] with increment: [1] sizes: [107] [113]\n                if <<(Help Screen) = [1]> and <not <(Slide_Number) = [11]>>> then\n                    show\n                    go to [front v] layer\n                else\n                    hide\n                    go to [back v] layer\n                    go to x: (300) y: (-250)\n                end\n            end\n        else\n            if <(costume [number v]) = [13]> then\n                forever\n                    Arrow at: [-200] [-125] with increment: [-1] sizes: [107] [113]\n                    if <<(Help Screen) = [1]> and <not <(Slide_Number) = [5]>>> then\n                        show\n                        go to [front v] layer\n                    else\n                        hide\n                        go to [back v] layer\n                        go to x: (-300) y: (-250)\n                    end\n                end\n            else\n                if <(costume [number v]) = [14]> then\n                    forever\n                        Arrow at: [-200] [140] with increment: [0] sizes: [107] [113]\n                        if <(Help Screen) = [1]> then\n                            show\n                            go to [front v] layer\n                        else\n                            hide\n                            go to [back v] layer\n                            go to x: (-300) y: (250)\n                        end\n                    end\n                else\n                    if <<(costume [number v]) = [2]> or <(costume [number v]) = [16]>> then\n                        forever\n                            if <(Help Screen) = [0]> then\n                                show\n                            else\n                                hide\n                            end\n                        end\n                    else\n                        if <(costume [number v]) = [17]> then\n                            show\n                            clear graphic effects\n                            go to x: (0) y: (0)\n                            set [ghost v] effect to (100)\n                            wait (0.25) seconds\n                            repeat (33)\n                                go to [front v] layer\n                                change [ghost v] effect by (-3.3333333333)\n                            end\n                            wait (0.5) seconds\n                            broadcast (begin v)\n                            delete this clone\n                        else\n                            forever\n                                set size to (100) %\n                                go to x: (0) y: (0)\n                                if <not <(Help Screen) = [0]>> then\n                                    show\n                                    clear graphic effects\n                                    switch costume to (Slide_Number)\n                                    go to [front v] layer\n                                    go [backward v] (3) layers\n                                else\n                                    hide\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [transition v]\nstop [other scripts in sprite v]\nwait (0) seconds\nif <(costume [number v]) = [4]> then\n    switch costume to (fade v)\n    create clone of (_myself_ v)\n    switch costume to (play v)\n    set size to (120) %\n    clear graphic effects\nend\n\ndefine Create\nshow\nclear graphic effects\nset size to (120) %\ngo to x: (-194) y: (162)\nswitch costume to (knobbelboy mode v)\nrepeat (3)\n    create clone of (_myself_ v)\n    next costume\nend\nnext costume\ncreate clone of (_myself_ v)\nswitch costume to (next v)\nrepeat (3)\n    create clone of (_myself_ v)\n    next costume\nend\ngo to x: (-194) y: (110)\nswitch costume to (mobile mode v)\nrepeat (2)\n    create clone of (_myself_ v)\n    next costume\nend\ngo to x: (0) y: (20)\nswitch costume to (play v)\n\ndefine Arrow at: (x) (y) with increment: (increment) sizes: (size1) (size2)\ngo to x: (x) y: (y)\nif <touching (mouse-pointer v)?> then\n    set [brightness v] effect to (10)\n    set size to (size1) %\n    if <mouse down?> then\n        set size to (size2) %\n        set [brightness v] effect to (25)\n        wait until <not <mouse down?>>\n        if <touching (mouse-pointer v)?> then\n            if <(increment) = [0]> then\n                broadcast (main menu v)\n            else\n                if <(increment) = [10]> then\n                    broadcast (Start up v)\n                    set [shut off? v] to [1]\n                else\n                    change [slide_number v] by (increment)\n                end\n            end\n        end\n        set size to (size1) %\n    end\nelse\n    clear graphic effects\n    set size to (size1) %\nend\n\nwhen I receive [main menu v]\nif <(costume [number v]) = [4]> then\n    set [help screen v] to [0]\n    forever\n        if <(Help Screen) = [0]> then\n            show\n        else\n            hide\n        end\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (10)\n            set size to (121) %\n            if <mouse down?> then\n                set size to (140) %\n                set [brightness v] effect to (25)\n                wait until <not <mouse down?>>\n                set size to (120) %\n                if <touching (mouse-pointer v)?> then\n                    start sound [Start v]\n                    wait (0) seconds\n                    broadcast (transition v)\n                    stop [this script v]\n                end\n            end\n        else\n            clear graphic effects\n            set size to (120) %\n        end\n    end\nend\n\nwhen I receive [begin v]\nhide\ndelete this clone\n\nwhen I receive [start up v]\nswitch backdrop to (background1 v)\nhide variable [time v]\nset [shut off? v] to [0]\nset [level v] to [1]\nset [help screen v] to [0]\nset [slide_number v] to [5]\nCreate\nset volume to (volume) %\nbroadcast (main menu v)\nforever\n    play sound [Spaze - Underworld \(Demo\) v] until done\nend\n\nwhen I receive [show button v]\nswitch costume to (main menu2 v)\ngo to [front v] layer\nshow\nforever\n    Arrow at: [-200] [140] with increment: [10] sizes: [75] [81]\n    if <(shut off?) = [1]> then\n        stop [this script v]\n    end\nend\n\nwhen I receive [start up v]\nforever\n    set volume to (volume) %\nend\n\nwhen flag clicked\nset [knobbelboy mode v] to [0]\nset [mobile mode v] to [0]\n\n@End Screen\n\nwhen I receive [gg v]\nwait (1) seconds\nswitch costume\nset [drop velocity v] to [0]\ngo to x: (0) y: (345)\nshow\nrepeat until <(y position) < [1]>\n    Fall [-1]\nend\nset [drop velocity v] to ([abs v] of ((drop velocity) / (1.25)) )\nrepeat (1)\n    Fall [-1.25]\nend\nrepeat until <(y position) < [1]>\n    Fall [-1.25]\nend\nrepeat (5)\n    set [drop velocity v] to ([abs v] of ((drop velocity) / (1.4)) )\n    repeat (1)\n        Fall [-1]\n    end\n    repeat until <(y position) < [1]>\n        Fall [-1]\n    end\nend\nshow variable [time v]\nif <(Knobbelboy mode) = [0]> then\n    show variable [deaths v]\n    Decode Global (☁ Global)\n    if <not <(time) < (item (2) of [global decode v])>> then\n        set [global_display_style v] to (join (join (item (1) of [global decode v]) [ — ]) (item (2) of [global decode v]))\n    else\n        start sound [achievement v]\n        delete all of [global encode v]\n        add (username) to [global encode v]\n        add (((round (time)) * (1000)) / (1000)) to [global encode v]\n        Encode Global\n        broadcast (encode v) and wait\n        set [global_display_style v] to (join (join (username) [ — ]) (time))\n    end\nelse\n    show variable [level v]\n    Decode Global (☁ Knobbelboy Mode Global)\n    if <not <<(level) > (item (2) of [global decode v])> or <<(level) = (item (2) of [global decode v])> and <(time) < (item (3) of [global decode v])>>>> then\n        set [global_display_style v] to (join (join (join (item (1) of [global decode v]) [ — Level ]) (item (2) of [global decode v])) (join (join [ in ] (item (3) of [global decode v])) [ seconds]))\n    else\n        start sound [achievement v]\n        delete all of [global encode v]\n        add (username) to [global encode v]\n        add (level) to [global encode v]\n        add (((round (time)) * (1000)) / (1000)) to [global encode v]\n        Encode Global\n        broadcast (encode v) and wait\n        set [global_display_style v] to (join (join (join (username) [ — Level ]) (level)) (join (join [ in ] (time)) [ seconds]))\n    end\nend\nshow variable [global_display_style v]\nswitch costume\ngo to [front v] layer\nbroadcast (show button v)\n\ndefine Fall (increment)\nchange [drop velocity v] by (increment)\nchange y by (([abs v] of (drop velocity) ) * (drop velocity))\ngo to [front v] layer\n\ndefine Encode Global\nset [holder v] to []\nset [j v] to [1]\nrepeat (length of [global encode v])\n    set [k v] to [0]\n    repeat (length of (item (j) of [global encode v]))\n        change [k v] by (1)\n        switch costume to (letter (k) of (item (j) of [global encode v]))\n        set [char v] to ((costume [number v]) - (2))\n        if <(char) > [9]> then\n            set [holder v] to (join (Holder) (char))\n        else\n            set [holder v] to (join (Holder) (join [0] (char)))\n        end\n    end\n    change [j v] by (1)\n    set [holder v] to (join (Holder) [00])\nend\n\ndefine Decode Global (string)\ndelete all of [global decode v]\nset [j v] to [1]\nset [string v] to []\nrepeat ((length of (string)) / (2))\n    set [char v] to (join (letter (j) of (string)) (letter ((j) + (1)) of (string)))\n    if <not <(char) = [0]>> then\n        set [string v] to (join (string) (letter (char) of (Chars)))\n    else\n        add (string) to [global decode v]\n        set [string v] to []\n    end\n    change [j v] by (2)\nend\n\ndefine switch costume\nif <(Knobbelboy mode) = [0]> then\n    switch costume to (end screen v)\nelse\n    switch costume to (end screen2 v)\nend\n\nwhen I receive [start up v]\nset [chars v] to [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyx1234567890-_.]\nhide\n\nwhen I receive [encode knobbelboy mode v]\nset [☁ knobbelboy mode global v] to (Holder)\n\nwhen I receive [encode v]\nset [☁ global v] to (Holder)\n\n@Lives\n\nwhen I receive [begin v]\nif <(Knobbelboy mode) = [1]> then\n    Create\n    forever\n        set [lives v] to ((3) - (deaths))\n    end\nend\n\nwhen I start as a clone\nshow\nforever\n    if <(lives) < (letter (10) of (costume [name v]))> then\n        Break (letter (8) of (costume [name v]))\n    end\n    go to [front v] layer\nend\n\ndefine Break (half)\npoint in direction (90)\nswitch costume to (join [Heart_Break_] (half))\nset [half v] to ((-2) * ((half) - (0.5)))\nset [vel v] to [5]\nfall [3] [-1.6666666666667] [0] ((5) / (3))\nfall [2] [-1.75] [0] [2.5]\nfall [2] [-2] [2.5] [5]\nfall [3] [-3] ((95) / (3)) ((80) / (3))\ndelete this clone\n\ndefine Create\npoint in direction (90)\nclear graphic effects\nswitch costume to (heart3.0 1 v)\nset size to (75) %\nrepeat (2)\n    go to x: (-210) y: (155)\n    repeat (3)\n        create clone of (_myself_ v)\n        change x by (40)\n        next costume\n    end\n    next costume\nend\n\ndefine fall (times) (rate) (fade) (dark)\nrepeat (times)\n    turn right ((vel) * (half)) degrees\n    change x by (([abs v] of ((vel) * (0.5)) ) * (half))\n    change y by (vel)\n    change [ghost v] effect by (fade)\n    change [brightness v] effect by ((-1) * (dark))\n    change [vel v] by (rate)\nend\n\nwhen I receive [start up v]\nhide\n\n@Controls\n\nwhen I receive [begin v]\nif <(Mobile Mode) = [1]> then\n    create\nelse\n    hide\n    forever\n        replace item (1) of [bools v] with <<<<mouse down?> or <key (up arrow v) pressed?>> or <key (space v) pressed?>> or <key (w v) pressed?>>\n        replace item (2) of [bools v] with <<key (left arrow v) pressed?> or <key (a v) pressed?>>\n        replace item (3) of [bools v] with <<key (right arrow v) pressed?> or <key (d v) pressed?>>\n    end\nend\n\ndefine create\nswitch costume to (left v)\nshow\nrepeat (3)\n    create clone of (_myself_ v)\n    next costume\nend\nhide\n\nwhen I start as a clone\nforever\n    set size to (120) %\n    if <(costume [number v]) = [1]> then\n        replace item (2) of [bools v] with <<touching (mouse-pointer v)?> and <mouse down?>>\n        go to x: (-200) y: (-150)\n    else\n        if <(costume [number v]) = [2]> then\n            replace item (3) of [bools v] with <<touching (mouse-pointer v)?> and <mouse down?>>\n            go to x: (-140) y: (-150)\n        else\n            replace item (1) of [bools v] with <<touching (mouse-pointer v)?> and <mouse down?>>\n            go to x: (180) y: (-150)\n        end\n    end\n    go to [front v] layer\nend\n\nwhen I receive [gg v]\ndelete this clone\n\nwhen I receive [start up v]\ndelete all of [bools v]\nadd [] to [bools v]\nadd [] to [bools v]\nadd [] to [bools v]\n\nwhen I receive [begin v]\nforever\n    if <<key (r v) pressed?> and <key (q v) pressed?>> then\n        set [can die v] to [1]\n        broadcast (play v)\n        wait until <not <<key (r v) pressed?> and <key (q v) pressed?>>>\n    end\nend\n\n@Text Engine (or soon to be)\n\n@Thumbnail\n\nwhen flag clicked\ngo to x: (0) y: (0)\nforever\n    set [ghost v] effect to (100)\n    show\n    go to [front v] layer\nend\n\n