The Challenge
@Stage\n\nwhen flag clicked\nhide variable [timer v]\nhide variable [death count v]\nset [level v] to [0]\nset [volume v] to [100]\nset [timer v] to [0]\nset [player v] to [1]\nset [death count v] to [0]\nwait (0.5) seconds\nbroadcast (intro v)\n\ndelete (all) of [start x v]\ndelete (all) of [start y v]\ndelete (all) of [level codes v]\nadd [-220] to [start x v]\nadd [-50] to [start y v]\nadd [..............................................................................................g.......................aa.......................d.......................................bb..aa..................aa..d...............b......................aaa.....................a.ac....................a.ac..........aaaa...eaaa.ac......affa........dd..a.......d..d............aaaaa.......................................................] to [level codes v]\nadd [-160] to [start x v]\nadd [100] to [start y v]\nadd [........................................g.............................................................bbbbb....aaa........eaaaaaaaa....d.d................abbb........a...........aaaa........d.............a.......................d............................................b........aaffa.aaa.....aaa.......a..............d....eaaaa.......................d...........eac.eac...........................................................] to [level codes v]\nadd [-140] to [start x v]\nadd [40] to [start y v]\nadd [..............................................................................................g.......................aa.......bbbbbbb........d........aaaaaaa...eac......bb...a..d..a............aaaaaa.....aa.............a.......................a...................b...a...................aa..ai......................aa....a....aaffaa....h..ad....d....a....ac..aaaaa.........ea....a...dd.dd..........a....ac................ea....a...] to [level codes v]\nadd [-220] to [start x v]\nadd [50] to [start y v]\nadd [...........aa......................aa......................dd..........................................ea..bb..ac..............ea.eaac.ac...............a.eaac.a................a..dd..a.......iaaaf....a..bb..a....faaa.....eaaa.eaac.aaac.........b.....eaac.....b......aaa......dd......aaa....a........aa........a....ah.......aa.......ga....aaabbbbaaaaaabbbbaaa.......aaaa......aaaa.....................................................] to [level codes v]\nadd [-80] to [start x v]\nadd [80] to [start y v]\nadd [.....................................a.a..............b.......a...............a.......d..............ga............eac........a......eac....a.......aaaaa..........aa......b...............ad...a..a.....b..bbb.b.aa....d.......aa..aaaaaaad.............a..a..d.dd..............a..a...................ia..ah..........a..a.....a..a.......a...affa...b.a..a............dd..eaaaa..aac.................dd..dd.....a............................] to [level codes v]\nadd [-220] to [start x v]\nadd [-100] to [start y v]\nadd [..............................................................b.g.....................aaaa.......i..........ea......................ad..........aaaaa......a...................................................bbbb..................eaaaaaaa.................ah....................eaaaaaa..................ad.d.d................eaa......................ad..........aaaaa......aa......................d........effc........................] to [level codes v]\nadd [-20] to [start x v]\nadd [-90] to [start y v]\nadd [...........aaaaa.....................a.......................d.......................h......................bab............aa.......a.a.......g...a..a.....a.i.a......a......................bb.b...................eaaaaa............aaac...a.d.d..............a...ea.................ea.bb.ac.................aaaaaa...........b..b....dd..d...........a..a...........aaaffa....aa.............dd.............................................] to [level codes v]\nadd [90] to [start x v]\nadd [-10] to [start y v]\nadd [.........................................................................b....bbb................ac..aaaaa.....ea........b.....a........d........ac....d.....b.....b.....b.....b.....a..a..a.....ac....a.....a..a..a..........faf....aa...aa...........d......aaaaa.................b......................ba...i........h........ba......................a.......................a....aaa................ag....................................] to [level codes v]\nadd [-210] to [start x v]\nadd [-100] to [start y v]\nadd [................................................b........b........b.....aa......aaa......ggg....d........d........d..............................................................................b........b........b....fff......aaa......aaa....d........d........d..............................................................................b........b........b....aaa......aaa......fff....d........d........d...........................] to [level codes v]\nadd [-190] to [start x v]\nadd [-80] to [start y v]\nadd [.................................................................................b..............eagac...aa...aaac.........d.....aa...aaa.................d....d.ac......................ha.....b....aa...aa...aa.dac..aa................abia.....................a.......e.c..e.c..e.c....a........................ac.......................a....efc..efc..efc......efc.........................................................................] to [level codes v]\n\nwhen I receive [next.level v]\nchange [level v] by (1)\n\nwhen flag clicked\nset volume to (100) %\nforever\n    play sound [Circumnavigating the Glob.mp3 v] until done\nend\n\nwhen I receive [next.level v]\nrepeat (10)\n    change volume by ((-0.07) * (Volume))\nend\n\nwhen I receive [volume.change v]\nset volume to (Volume) %\n\nwhen I receive [game.play v]\nrepeat (10)\n    change volume by ((0.07) * (Volume))\nend\n\n@Intro/Outro\n\nwhen flag clicked\nhide\n\nwhen I receive [intro v]\nswitch costume to (title v)\nSlide In (-30)\nwait (2) seconds\nFade Out\nwait (0.5) seconds\nswitch costume to (controls v)\nSlide In (-30)\nwait (2) seconds\nFade Out\nbroadcast (next.level v)\nset [delay v] to (timer)\nrepeat until <(Level) > [10]>\n    set [timer v] to (round ((timer) - (delay)))\nend\n\nwhen I receive [outro v]\nswitch costume to (statistics v)\nSlide In (-30)\nshow variable [timer v]\nshow variable [death count v]\nwait (7) seconds\nbroadcast (end v)\n\ndefine None\ngo to x: (0) y: (y)\nset [ghost v] effect to (100)\nshow\nrepeat (15)\n    change [ghost v] effect by ((-100) / (15))\n    change y by (((0) - (y position)) / (5))\nend\n\ndefine Fade Out\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\n@Player\n\nwhen flag clicked\nhide\nset [vel x v] to [0]\nset [vel y v] to [0]\nset [portal v] to [1]\n\ndefine Hit Ground <ceiling>\nchange [fall v] by (1)\nrepeat until <not <touching (normal v)?>>\n    if <ceiling> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [fall v] to [0]\n    end\n    set [vel y v] to [0]\nend\n\ndefine Walk (dir) (speed)\npoint in direction (dir)\nchange x by (speed)\nif <touching (normal v)?> then\n    Hit Wall (speed)\nend\n\ndefine Hit Wall (speed)\nchange x by ((0) - (speed))\nif <(speed) < [0]> then\n    repeat until <touching (normal v)?>\n        change x by (-1)\n    end\n    change x by (1)\nelse\n    repeat until <touching (normal v)?>\n        change x by (1)\n    end\n    change x by (-1)\nend\nset [vel x v] to [0]\n\nwhen I receive [game.play v]\nclear graphic effects\ngo to x: (item (Level) of [start x v]) y: (item (Level) of [start y v])\nswitch costume to (Player)\nshow\nforever\n    change [vel y v] by (-1.2)\n    change y by (vel y)\n    Hit Ground <(vel y) > [0]>\n    set [vel x v] to ((vel x) * (0.75))\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        change [vel x v] by (-1.35)\n    end\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        change [vel x v] by (1.35)\n    end\n    if <(vel x) < [-0.5]> then\n        Walk (-90) (vel x)\n    end\n    if <(vel x) > [0.5]> then\n        Walk (90) (vel x)\n    end\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> and <(fall) = [0]>> then\n        set [vel y v] to [13]\n    end\n    Block Detection\nend\n\ndefine Block Detection\nif <<touching (spikes v)?> or <(y position) < [-175]>> then\n    set [vel x v] to [0]\n    set [vel y v] to [0]\n    Fade (10)\n    change [death count v] by (1)\n    go to x: (item (Level) of [start x v]) y: (item (Level) of [start y v])\n    Fade (-10)\nend\nif <touching (bouncy v)?> then\n    Bounce Up\n    set [vel y v] to [18]\nend\nif <touching (finish v)?> then\n    set [vel x v] to [0]\n    set [vel y v] to [0]\n    broadcast (next.level v)\nend\nif <<touching (portal in v)?> and <(portal) = [1]>> then\n    broadcast (portal.in v)\n    set [portal v] to [0]\n    Fade (10)\n    go to (portal out v)\n    Fade (-10)\nend\nif <<touching (portal out v)?> and <(portal) = [1]>> then\n    broadcast (portal.in v)\n    set [portal v] to [0]\n    Fade (10)\n    go to (portal in v)\n    Fade (-10)\nend\n\nwhen I receive [next.level v]\nstop [other scripts in sprite v]\n\nwhen I receive [portal.in v]\nwait until <<not <touching (portal in v)?>> and <not <touching (portal out v)?>>>\nset [portal v] to [1]\n\ndefine Bounce Up\nrepeat until <not <touching (bouncy v)?>>\n    change y by (1)\nend\n\ndefine Fade (speed)\nrepeat ((100) / ([abs v] of (speed) ))\n    change [ghost v] effect by (speed)\nend\n\nwhen I receive [costume.change v]\nswitch costume to (Player)\n\nwhen I receive [outro v]\nhide\n\n@Normal\n\nwhen flag clicked\nhide\n\nwhen I receive [game.render v]\nRender\n\nwhen I receive [game.clear v]\ndelete this clone\n\nwhen I start as a clone\ngo [backward v] (999) layers\nshow\n\ndefine Render\ngo to x: (-230) y: (170)\nset [current v] to [0]\nrepeat (18)\n    repeat (24)\n        change [current v] by (1)\n        if <(letter (current) of (item (Level) of [level codes v])) = [a]> then\n            create clone of (_myself_ v)\n        end\n        change x by (20)\n    end\n    go to x: (-230) y: ((y position) - (20))\nend\n\n@Spikes\n\nwhen I receive [game.render v]\nRender\n\nwhen I start as a clone\ngo [backward v] (999) layers\nshow\n\nwhen flag clicked\nhide\n\ndefine Render\ngo to x: (-230) y: (170)\nset [current v] to [0]\nrepeat (18)\n    repeat (24)\n        change [current v] by (1)\n        Switch (letter (current) of (item (Level) of [level codes v]))\n        change x by (20)\n    end\n    go to x: (-230) y: ((y position) - (20))\nend\n\ndefine None\nif <(current) = [b]> then\n    switch costume to (spike_up v)\n    create clone of (_myself_ v)\nend\nif <(current) = [c]> then\n    switch costume to (spike_right v)\n    create clone of (_myself_ v)\nend\nif <(current) = [d]> then\n    switch costume to (spike_down v)\n    create clone of (_myself_ v)\nend\nif <(current) = [e]> then\n    switch costume to (spike_left v)\n    create clone of (_myself_ v)\nend\n\nwhen I receive [game.clear v]\ndelete this clone\n\n@Bouncy\n\nwhen flag clicked\nhide\n\ndefine Render\ngo to x: (-230) y: (170)\nset [current v] to [0]\nrepeat (18)\n    repeat (24)\n        change [current v] by (1)\n        if <(letter (current) of (item (Level) of [level codes v])) = [f]> then\n            create clone of (_myself_ v)\n        end\n        change x by (20)\n    end\n    go to x: (-230) y: ((y position) - (20))\nend\n\nwhen I receive [game.render v]\nRender\n\nwhen I receive [game.clear v]\ndelete this clone\n\nwhen I start as a clone\ngo [backward v] (999) layers\nshow\n\n@Finish\n\nwhen flag clicked\nhide\n\ndefine Render\ngo to x: (-230) y: (170)\nset [current v] to [0]\nrepeat (18)\n    repeat (24)\n        change [current v] by (1)\n        if <(letter (current) of (item (Level) of [level codes v])) = [g]> then\n            create clone of (_myself_ v)\n        end\n        change x by (20)\n    end\n    go to x: (-230) y: ((y position) - (20))\nend\n\nwhen I receive [game.render v]\nRender\n\nwhen I start as a clone\ngo [backward v] (999) layers\nshow\n\nwhen I receive [game.clear v]\ndelete this clone\n\n@Portal In\n\nwhen flag clicked\nhide\n\ndefine Render\nhide\ngo to x: (-230) y: (170)\nset [current v] to [0]\nrepeat (18)\n    repeat (24)\n        change [current v] by (1)\n        if <(letter (current) of (item (Level) of [level codes v])) = [h]> then\n            go [backward v] (999) layers\n            show\n            stop [this script v]\n        end\n        change x by (20)\n    end\n    go to x: (-230) y: ((y position) - (20))\nend\n\nwhen I receive [game.render v]\nRender\n\nwhen I receive [outro v]\nhide\n\n@Portal Out\n\nwhen flag clicked\nhide\n\ndefine Render\nhide\ngo to x: (-230) y: (170)\nset [current v] to [0]\nrepeat (18)\n    repeat (24)\n        change [current v] by (1)\n        if <(letter (current) of (item (Level) of [level codes v])) = [i]> then\n            go [backward v] (999) layers\n            show\n            stop [this script v]\n        end\n        change x by (20)\n    end\n    go to x: (-230) y: ((y position) - (20))\nend\n\nwhen I receive [game.render v]\nRender\n\nwhen I receive [outro v]\nhide\n\n@Icon\n\nwhen flag clicked\nhide\n\nwhen I receive [game.clear v]\nset [settings v] to [0]\nset size to (100) %\nif <<(Level) = [3]> or <(Level) = [6]>> then\n    go to x: (120) y: (-150)\nelse\n    go to x: (210) y: (-150)\nend\nswitch costume to (settings v)\nshow\nforever\n    turn right (1.5) degrees\n    if <(Settings) = [0]> then\n        if <mouse down?> then\n            if <touching (mouse-pointer v)?> then\n                set [settings v] to [1]\n                create clone of (_myself_ v)\n            end\n        end\n    end\nend\n\ndefine None\nrepeat ((100) / ([abs v] of (speed) ))\n    change [ghost v] effect by (speed)\nend\n\nwhen I start as a clone\nbroadcast (settings.fade.in v)\ngo to x: (0) y: (115)\nset size to (200) %\nset [ghost v] effect to (100)\nFade (-10)\nrepeat until <(Settings) = [0]>\n    turn right (1.5) degrees\nend\nbroadcast (settings.fade.out v)\nFade (10)\ndelete this clone\n\nwhen I receive [outro v]\nstop [other scripts in sprite v]\nhide\n\n@Window\n\nwhen flag clicked\ngo to [front v] layer\nhide\n\nwhen I receive [settings.fade.in v]\ngo to x: (0) y: (-20)\nset [ghost v] effect to (100)\nshow\nFade (-10)\n\ndefine None\nrepeat ((100) / ([abs v] of (speed) ))\n    change [ghost v] effect by (speed)\nend\n\nwhen I receive [settings.fade.out v]\nFade (10)\nhide\n\n@Knob\n\nwhen flag clicked\nhide\n\nwhen I receive [settings.fade.in v]\ngo to x: (((Volume) / ((100) / (86))) - (43)) y: (-68)\nset [ghost v] effect to (100)\ngo to [front v] layer\nshow\nFade (-10)\nforever\n    if <mouse down?> then\n        if <touching (mouse-pointer v)?> then\n            repeat until <not <mouse down?>>\n                set x to (mouse x)\n                Constrain (-43) (43)\n                set [volume v] to (round (((x position) + (43)) * ((100) / (86))))\n                broadcast (volume.change v)\n            end\n        end\n    end\nend\n\ndefine None\nif <(mouse x) < (low)> then\n    set x to (low)\nend\nif <(mouse x) > (high)> then\n    set x to (high)\nend\n\nwhen I receive [settings.fade.out v]\nFade (10)\nhide\n\ndefine None\nrepeat ((100) / ([abs v] of (speed) ))\n    change [ghost v] effect by (speed)\nend\n\n@Select\n\ndefine Fade (speed)\nrepeat ((100) / ([abs v] of (speed) ))\n    change [ghost v] effect by (speed)\nend\n\nwhen I receive [costume.left v]\nif <(Player) = [1]> then\n    set [player v] to [4]\nelse\n    set [player v] to ((Player) - (1))\nend\nbroadcast (costume.change v)\n\nwhen I receive [costume.right v]\nif <(Player) = [4]> then\n    set [player v] to [1]\nelse\n    set [player v] to ((Player) + (1))\nend\nbroadcast (costume.change v)\n\nwhen I receive [settings.fade.in v]\ngo to x: (0) y: (20)\nset size to (175) %\nset [ghost v] effect to (100)\ngo to [front v] layer\nswitch costume to (Player)\nshow\nFade (-10)\n\nwhen I receive [settings.fade.out v]\nFade (10)\nhide\n\nwhen I receive [costume.change v]\nswitch costume to (Player)\n\nwhen flag clicked\nhide\n\n@Arrows\n\nwhen I receive [settings.fade.in v]\ngo to x: (0) y: (20)\nset [ghost v] effect to (100)\ngo to [front v] layer\nshow\nFade (-10)\nforever\n    if <mouse down?> then\n        if <touching (mouse-pointer v)?> then\n            if <(mouse x) < [0]> then\n                broadcast (costume.left v)\n                wait until <not <mouse down?>>\n            else\n                broadcast (costume.right v)\n                wait until <not <mouse down?>>\n            end\n        end\n    end\nend\n\nwhen flag clicked\nhide\n\ndefine None\nrepeat ((100) / ([abs v] of (speed) ))\n    change [ghost v] effect by (speed)\nend\n\nwhen I receive [settings.fade.out v]\nFade (10)\nhide\n\n@Close\n\nwhen flag clicked\nhide\n\nwhen I receive [settings.fade.in v]\ngo to x: (0) y: (-95)\nset [ghost v] effect to (100)\ngo to [front v] layer\nshow\nFade (-10)\nforever\n    if <mouse down?> then\n        if <touching (mouse-pointer v)?> then\n            set [settings v] to [0]\n            stop [this script v]\n        end\n    end\nend\n\nwhen I receive [settings.fade.out v]\nFade (10)\nhide\n\ndefine None\nrepeat ((100) / ([abs v] of (speed) ))\n    change [ghost v] effect by (speed)\nend\n\n@Fade In/Out\n\nwhen flag clicked\nset [ghost v] effect to (100)\ngo to x: (0) y: (0)\nshow\n\nwhen I receive [next.level v]\ngo to [front v] layer\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nbroadcast (game.clear v)\nwait (0.4) seconds\nif <(Level) = [11]> then\n    broadcast (outro v)\nelse\n    broadcast (game.render v)\n    wait (0.2) seconds\n    broadcast (game.play v)\nend\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\n@Thumbnail\n\nwhen flag clicked\nhide\n\nwhen I receive [end v]\ngo to x: (0) y: (-320)\ngo to [front v] layer\nshow\nrepeat until <(y position) = [0]>\n    if <(round (((0) - (y position)) / (5))) > [0]> then\n        change y by (round (((0) - (y position)) / (5)))\n    else\n        change y by (1)\n    end\nend\n\n