The Platformer REVISED

Instructions: Press the green flag to start...\n\n*ALL LEVELS ARE POSSIBLE*\n\nDetailed Instructions: https://scratch.mit.edu/discuss/topic/146740/\n\nQuick Instructions (Sort of...) -\n\n-Main Menu- \nPlay - Plays the main levels of the game\nSpecial - Plays the special levels of the game\nEditor - Goes to the level editor.\nCode - Plays a level via a code\n\nWhile playing a level, you can press space to go back to the main menu\n________________________________________________________\n\n-Editor-\n\nTo select diferent tiles, go to the top left corner and then a button (sort of) with the letter "T" will appear, click it and then a menu will appear, just click the tile you want and done (click that button again to exit the menu)\n\nYou can also use the arrow keys to scroll between the diferent tiles.\n\nLeft click to place a block.\n\nTo open the options (or close it), move your mouse to the top right corner and then a button (sort of) with a gear will appear, click it and then a menu will appear.\n\n\n-Editor options-\n\nSave - Saves the current level via a code (Copy the code in list that will appear and then to close the list, press enter)\nLoad - Loads the level via a code

@Stage\n\nwhen I receive [tp.music.main v]\nset [tp.music v] to [0]\nset [tp.music.current v] to [0]\nset [tp.music.secret v] to (<(pick random (1) to (20)) = [1]> * (1))\nset volume to (50) %\nforever\n    if <(tp.mode) = [0]> then\n        set [tp.music v] to [1]\n    end\n    if <(tp.mode) = [2]> then\n        set [tp.music v] to [4]\n    end\n    if <not <(tp.music) = (tp.music.current)>> then\n        broadcast (tp.music.update v)\n    end\n    switch backdrop to ((<(tp.music) < [4]> * (tp.music)) + (<(tp.music) = [4]> + (<(tp.music) = [5]> * (2))))\nend\n\nwhen I receive [\[tp.music.play\] v]\nstop all sounds\nforever\n    play sound ((((tp.music) + ((tp.music.secret) * (3))) * <(tp.music) < [4]>) + (((tp.music) + (3)) * <(tp.music) > [3]>)) until done\nend\n\nwhen flag clicked\nbroadcast (tp.init v)\nbroadcast (Intro v)\n\nwhen I receive [tp.music.update v]\nset [tp.music.current v] to (tp.music)\nbroadcast (\[tp.music.play\] v)\n\nwhen I receive [start v]\nbroadcast (tp.music.main v)\nbroadcast (tp.menu v)\n\n@Thumbnail\n\nwhen I receive [tp.init v]\nset [ghost v] effect to (100)\nforever\n    go to [front v] layer\nend\n\n@Intro\n\nwhen I receive [intro v]\ngo to x: (0) y: (0)\nhide\nsize [0]\nreset timer\nstart sound [intro v]\nset [i v] to [0]\ncreate clone of (_myself_ v)\nwait until <(timer) > [0.3]>\nrepeat (4)\n    change [i v] by (1)\n    create clone of (_myself_ v)\nend\nwait until <(timer) > [9.6]>\nchange [i v] by (1)\ncreate clone of (_myself_ v)\nwait until <(timer) > [9.7]>\nchange [i v] by (1)\ncreate clone of (_myself_ v)\n\nwhen I receive [intro.introend v]\nif <(i) = [0]> then\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\n    broadcast (Start v)\n    delete this clone\nelse\n    delete this clone\nend\n\nwhen I start as a clone\nif <(i) = [0]> then\n    show\n    switch costume to (background v)\n    set size to (100) %\n    go to [back v] layer\nend\nif <(i) = [1]> then\n    switch costume to (square v)\n    point in direction ((90) - (22.5))\n    set [ghost v] effect to (50)\n    set [i v] to [45]\n    set [size v] to [0]\n    show\n    forever\n        change [i v] by (5)\n        change [size v] by (((100) - (size)) * (0.2))\n        size ((size) + ((([sin v] of (i) ) * (5)) * ((size) / (100))))\n    end\nend\nif <(i) = [2]> then\n    switch costume to (square v)\n    point in direction ((90) + (22.5))\n    set [ghost v] effect to (50)\n    set [i v] to [90]\n    set [size v] to [0]\n    show\n    forever\n        change [i v] by (5)\n        change [size v] by (((100) - (size)) * (0.2))\n        size ((size) + ((([sin v] of (i) ) * (5)) * ((size) / (100))))\n    end\nend\nif <(i) = [3]> then\n    switch costume to (square v)\n    set [i v] to [0]\n    set [size v] to [0]\n    show\n    forever\n        change [i v] by (5)\n        change [size v] by (((100) - (size)) * (0.2))\n        size ((size) + ((([sin v] of (i) ) * (5)) * ((size) / (100))))\n    end\nend\nif <(i) = [4]> then\n    switch costume to (logo v)\n    set [i v] to [0]\n    set [size v] to [0]\n    show\n    forever\n        change [i v] by (5)\n        change [size v] by (((100) - (size)) * (0.2))\n        size ((size) + ((([sin v] of (i) ) * (5)) * ((size) / (100))))\n    end\nend\nif <(i) = [5]> then\n    show\n    switch costume to (whitesquare v)\n    set [ghost v] effect to (50)\n    set [brightness v] effect to (99)\n    repeat until <(size) > [140]>\n        size ((size) + (((150) - (size)) * (0.2)))\n    end\nend\nif <(i) = [6]> then\n    show\n    switch costume to (whitesquare v)\n    set [brightness v] effect to (99)\n    repeat until <(size) > [140]>\n        size ((size) + (((150) - (size)) * (0.2)))\n    end\n    broadcast (intro.introEnd v)\nend\n\ndefine size (s)\nset [c v] to (costume [number v])\nif <(s) > [100]> then\n    switch costume to (size v)\nend\nset size to (s) %\nswitch costume to (c)\n\n@Main Menu\n\nwhen I receive [tp.menu v]\nbroadcast (tp.level.deleteObjects v)\nset [tp.level v] to [1]\nset [tp.mode v] to [0]\nchange [tp.menu.intro v] by (1)\nMenu\n\ndefine Menu\nset [tp.menu.cloneid v] to [0]\nrepeat (5)\n    change [tp.menu.cloneid v] by (1)\n    create clone of (_myself_ v)\nend\n\ndefine Go to X (x) Y (y)\nswitch costume to (limits v)\ngo to x: (x) y: (y)\nswitch costume to (tp.menu.cloneId)\n\nwhen I start as a clone\nif <(tp.menu.cloneId) = [1]> then\n    set [tp.menu.sine v] to [0]\n    if <(tp.menu.intro) > [1]> then\n        set [tp.menu.y v] to [125]\n    else\n        set [tp.menu.y v] to [300]\n    end\n    forever\n        change [tp.menu.y v] by (((125) - (tp.menu.y)) / (5))\n        change [tp.menu.sine v] by (10)\n        set size to ((([sin v] of (tp.menu.sine) ) * (10)) + (100)) %\n        point in direction ((([sin v] of ((tp.menu.sine) * (1.6)) ) * (6)) + (90))\n        Go to X (0) Y ((([cos v] of (tp.menu.sine) ) * (5)) + (tp.menu.y))\n    end\nend\n\nwhen I start as a clone\nif <<(tp.menu.cloneId) = [2]> or <(tp.menu.cloneId) = [3]>> then\n    forever\n        if <<(tp.mode) = [0]> and <<touching (mouse-pointer v)?> and <mouse down?>>> then\n            start sound [Select v]\n            set [tp.mode v] to [1]\n            set [tp.level.type v] to ((tp.menu.cloneId) - (1))\n            broadcast (tp.level.loadCurrent v) and wait\n        end\n    end\nend\n\nwhen I start as a clone\nif <(tp.menu.cloneId) = [4]> then\n    forever\n        if <<(tp.mode) = [0]> and <<touching (mouse-pointer v)?> and <mouse down?>>> then\n            start sound [Select v]\n            broadcast (tp.transition.show v) and wait\n            set [tp.mode v] to [2]\n            broadcast (tp.editor v)\n            broadcast (tp.transition.hide v)\n        end\n    end\nend\n\nwhen I start as a clone\nif <(tp.menu.cloneId) = [5]> then\n    forever\n        if <<(tp.mode) = [0]> and <<touching (mouse-pointer v)?> and <mouse down?>>> then\n            start sound [Select v]\n            set [tp.mode v] to [4]\n            ask [] and wait\n            delete (all) of [code v]\n            add (answer) to [code v]\n            set [tp.mode v] to [3]\n            set [tp.level.type v] to [1]\n            broadcast (tp.level.loadCustom v) and wait\n        end\n    end\nend\n\nwhen I start as a clone\nif <(tp.menu.cloneId) > [1]> then\n    set size to (75) %\n    set [tp.menu.sine v] to [0]\n    set [tp.menu.y v] to [-300]\n    if <(tp.menu.intro) > [1]> then\n        set [tp.menu.y v] to ((150) - ((tp.menu.cloneId) * (60)))\n    else\n        set [tp.menu.y v] to [-300]\n    end\n    forever\n        change [tp.menu.sine v] by (10)\n        change [tp.menu.y v] by ((((150) - ((tp.menu.cloneId) * (60))) - (tp.menu.y)) / (5))\n        Go to X (([sin v] of (tp.menu.sine) ) * (((((tp.menu.cloneId) mod (2)) * (-2)) + (1)) * (5))) Y (tp.menu.y)\n    end\nend\n\nwhen I receive [tp.init v]\nset [tp.menu.intro v] to [0]\n\nwhen I receive [tp.menu.stop v]\nstop [other scripts in sprite v]\ndelete this clone\n\nwhen I receive [tp.level.menureturn v]\nwait until <not <key (space v) pressed?>>\nwait until <key (space v) pressed?>\nbroadcast (tp.transition.show v) and wait\nset [tp.mode v] to [0]\nbroadcast (tp.transition.hide v)\nbroadcast (tp.menu v)\n\n@Player\n\nwhen I receive [tp.level.kill v]\ngo to x: (item (1) of [tp.level.spawn v]) y: (item (2) of [tp.level.spawn v])\nset [tp.player.xvel v] to [0]\nset [tp.player.yvel v] to [0]\nstart sound [dead v]\n\nwhen I receive [tp.level.deleteobjects v]\nhide\nstop [other scripts in sprite v]\n\ndefine Physics\nswitch costume to (hitbox v)\nif <key (right arrow v) pressed?> then\n    change [tp.player.xvel v] by (1)\nend\nif <key (left arrow v) pressed?> then\n    change [tp.player.xvel v] by (-1)\nend\nif <[tp.level.specialcollision v] contains [g]?> then\n    change [tp.player.xvel v] by (2)\nend\nif <[tp.level.specialcollision v] contains [h]?> then\n    change [tp.player.xvel v] by (-2)\nend\nchange [tp.player.xvel v] by ((tp.player.xVel) * ((-0.15) + (<[tp.level.specialcollision v] contains [i]?> / (10))))\nif <<([abs v] of (tp.player.xVel) ) > [7]> and <[tp.level.specialcollision v] contains [i]?>> then\n    set [tp.player.xvel v] to (((tp.player.xVel) / ([abs v] of (tp.player.xVel) )) * (7))\nend\nchange [tp.player.yvel v] by (-1)\nchange x by (tp.player.xVel)\nWalls [5] <(tp.player.xVel) > [0]>\nchange y by (tp.player.yVel)\nGround <(tp.player.yVel) < [0]>\nif <(y position) < [-178]> then\n    broadcast (tp.level.kill v)\nend\nswitch costume to (player v)\n\ndefine Ground <falling>\nif <<touching (solid blocks v)?> or <touching (special blocks v)?>> then\n    set [tp.player.yvel v] to [0]\n    repeat until <not <<touching (solid blocks v)?> or <touching (special blocks v)?>>>\n        change y by (<falling> - <not <falling>>)\n    end\nend\nchange y by (-1)\nif <<touching (solid blocks v)?> or <touching (special blocks v)?>> then\n    if <<key (up arrow v) pressed?> and <not <[tp.level.specialcollision v] contains [k]?>>> then\n        start sound [jump v]\n        if <[tp.level.specialcollision v] contains [f]?> then\n            set [tp.player.yvel v] to [15]\n        else\n            set [tp.player.yvel v] to [10]\n        end\n    end\nend\nchange y by (1)\n\ndefine Walls (slope) <right>\nset [slope v] to [0]\nrepeat until <<not <<touching (solid blocks v)?> or <touching (special blocks v)?>>> or <(slope) > (slope)>>\n    change [slope v] by (1)\n    change y by (1)\nend\nif <<touching (solid blocks v)?> or <touching (special blocks v)?>> then\n    change y by (() - (slope))\n    repeat until <not <<touching (solid blocks v)?> or <touching (special blocks v)?>>>\n        change x by (<not <right>> - <right>)\n    end\n    set [tp.player.xvel v] to [0]\nend\n\nwhen I receive [tp.init v]\nhide\n\nwhen I receive [tp.level.load v]\ngo to x: (item (1) of [tp.level.spawn v]) y: (item (2) of [tp.level.spawn v])\nset [tp.player.xvel v] to [0]\nset [tp.player.yvel v] to [0]\nshow\n\nwhen I receive [tp.level.loaded v]\nforever\n    set [brightness v] effect to ((<(tp.music) = [5]> * (-25)) + (<(tp.music) < [4]> * (((tp.music) - (1)) * (-25))))\n    Physics\nend\n\nwhen I receive [tp.level.load v]\nset [brightness v] effect to ((<(tp.music) = [5]> * (-25)) + (<(tp.music) < [4]> * (((tp.music) - (1)) * (-25))))\n\n@Editor\n\ndefine Load level\nshow\nset [tp.editor.load v] to [0]\ndelete all of [tp.editor.data v]\nerase all\nrepeat (432)\n    go to x: (((((tp.editor.load) mod (24)) - (12)) * (20)) + (10)) y: (((([floor v] of ((tp.editor.load) / (24)) ) - (9)) * (20)) + (10))\n    change [tp.editor.load v] by (1)\n    if <(letter (tp.editor.load) of (item (1) of [code v])) > [0]> then\n        switch costume to (letter (tp.editor.load) of (item (1) of [code v]))\n        stamp\n    end\n    add (letter (tp.editor.load) of (item (1) of [code v])) to [tp.editor.data v]\nend\nset [tp.level.time v] to (letter (length of (item (1) of [code v])) of (item (1) of [code v]))\nif <not <[tp.music.list v] contains (tp.level.time)?>> then\n    set [tp.level.time v] to [1]\nend\nhide\n\ndefine Load editor\ndelete all of [tp.editor.data v]\ndelete all of [tp.editor.hover v]\nset [tp.editor.mode v] to [0]\nset [tp.level.tilenum v] to [26]\nset [tp.editor.block v] to [1]\nset [tp.level.time v] to [1]\nset [tp.editor.cloneid v] to [0]\nrepeat (432)\n    add [0] to [tp.editor.data v]\nend\nrepeat (4)\n    add [0] to [tp.editor.hover v]\nend\nrepeat ((11) + (tp.level.tileNum))\n    change [tp.editor.cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nset [tp.editor.cloneid v] to [0]\n\nwhen I receive [tp.editor.showcode v]\ndelete (all) of [code v]\nadd (join (tp.editor.data) (tp.level.time)) to [code v]\nadd [Triple click on the code and press CTRL+C to copy] to [code v]\nadd [After that, click outside of the list and press space to get back to the editor] to [code v]\nhide list [code v]\nwait until <key (space v) pressed?>\nset [tp.editor.mode v] to [3]\nshow list [code v]\nwait until <not <key (space v) pressed?>>\n\nwhen I receive [tp.init v]\nhide\nerase all\nshow list [code v]\n\nwhen I receive [tp.editor v]\nbroadcast (tp.menu.stop v)\nset [tp.level.time v] to [1]\nset [tp.editor.mode v] to [0]\nset [tp.editor.block v] to [1]\nLoad editor\nerase all\nforever\n    switch costume to ((tp.editor.block) + (0))\n    go to x: ((([floor v] of ((mouse x) / (20)) ) * (20)) + (10)) y: ((([floor v] of ((mouse y) / (20)) ) * (20)) + (10))\n    if <(x position) < [-230]> then\n        set x to (-230)\n    end\n    if <(y position) > [170]> then\n        set y to (170)\n    end\n    if <<mouse down?> and <<<(item (1) of [tp.editor.hover v]) = [0]> and <(item (3) of [tp.editor.hover v]) = [0]>> and <(tp.editor.mode) = [0]>>> then\n        switch costume to (white v)\n        stamp\n        switch costume to ((tp.editor.block) + (0))\n        if <(tp.editor.block) > [1]> then\n            stamp\n        end\n        replace item ((([floor v] of ((mouse x) / (20)) ) + (13)) + ((([floor v] of ((mouse y) / (20)) ) + (9)) * (24))) of [tp.editor.data v] with (costume [name v])\n    end\n    if <(tp.editor.mode) = [0]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen I receive [tp.editor v]\nforever\n    if <key (right arrow v) pressed?> then\n        start sound [Select v]\n        Set editor block ((tp.editor.block) + (1))\n        wait until <not <key (right arrow v) pressed?>>\n    end\n    if <key (left arrow v) pressed?> then\n        start sound [Select v]\n        Set editor block ((tp.editor.block) - (1))\n        wait until <not <key (left arrow v) pressed?>>\n    end\nend\n\nwhen I start as a clone\nif <(tp.editor.cloneID) = [2]> then\n    switch costume to (tile selector menu v)\n    go to x: (0) y: (0)\nend\nif <(tp.editor.cloneID) = [3]> then\n    go to x: (0) y: (120)\n    forever\n        switch costume to ((tp.editor.block) + (0))\n    end\nend\nif <<(tp.editor.cloneID) > [3]> and <(tp.editor.cloneID) < ((tp.level.tileNum) + (4))>> then\n    switch costume to ((tp.editor.cloneID) - (3))\n    go to x: ((((((tp.editor.cloneID) - (4)) mod (15)) + (1)) * ((400) / (15))) - (((15) / (2)) * ((400) / ((15) - (1))))) y: (() - ((([floor v] of (((tp.editor.cloneID) - (4)) / (15)) ) * ((225) / (6))) - (((6) / (2)) * ((225) / ((9) - (1))))))\n    forever\n        if <<(tp.editor.mode) = [1]> and <<(distance to [mouse-pointer v]) < [11]> and <<mouse down?> and <(item (2) of [tp.editor.hover v]) = [0]>>>> then\n            replace item (2) of [tp.editor.hover v] with [1]\n            start sound [Select v]\n            Set editor block ((tp.editor.cloneID) - (3))\n            wait until <not <mouse down?>>\n            replace item (2) of [tp.editor.hover v] with [0]\n        end\n    end\nend\n\nwhen I start as a clone\nif <<(tp.editor.cloneID) > [1]> and <(tp.editor.cloneID) < ((tp.level.tileNum) + (4))>> then\n    show\n    set [tp.editor.ghost v] to [100]\n    forever\n        go to [front v] layer\n        go [backward v] (4) layers\n        if <(tp.editor.cloneID) = [2]> then\n            go [backward v] (1) layers\n            change [tp.editor.ghost v] by (((<not <<(tp.editor.mode) = [1]> or <(tp.editor.mode) = [3]>>> * (100)) - (tp.editor.ghost)) * (0.2))\n        else\n            change [tp.editor.ghost v] by (((<not <(tp.editor.mode) = [1]>> * (100)) - (tp.editor.ghost)) * (0.2))\n        end\n        set [ghost v] effect to (tp.editor.ghost)\n    end\nend\n\nwhen I start as a clone\nif <(tp.editor.cloneID) > ((tp.level.tileNum) + (7))> then\n    go to x: (100) y: ((110) - (((tp.editor.cloneID) - ((tp.level.tileNum) + (8))) * ((220) / (3))))\nend\nif <(tp.editor.cloneID) = ((tp.level.tileNum) + (8))> then\n    forever\n        switch costume to ((tp.level.time) + ((tp.level.tileNum) + (11)))\n    end\nend\nif <(tp.editor.cloneID) = ((tp.level.tileNum) + (9))> then\n    switch costume to (day v)\nend\nif <(tp.editor.cloneID) = ((tp.level.tileNum) + (10))> then\n    switch costume to (sunset v)\nend\nif <(tp.editor.cloneID) = ((tp.level.tileNum) + (11))> then\n    switch costume to (night v)\nend\nif <(tp.editor.cloneID) > ((tp.level.tileNum) + (8))> then\n    forever\n        if <<<touching (mouse-pointer v)?> or <(distance to [mouse-pointer v]) < [25]>> and <<mouse down?> and <<(item (4) of [tp.editor.hover v]) = [0]> and <(tp.editor.mode) = [3]>>>> then\n            start sound [Select v]\n            set [tp.level.time v] to ((tp.editor.cloneID) - ((tp.level.tileNum) + (8)))\n            replace item (4) of [tp.editor.hover v] with [1]\n            wait until <not <mouse down?>>\n            replace item (4) of [tp.editor.hover v] with [0]\n        end\n    end\nend\n\nwhen I start as a clone\nif <(tp.editor.cloneID) > ((tp.level.tileNum) + (4))> then\n    show\n    set [tp.editor.ghost v] to [100]\n    forever\n        go to [front v] layer\n        go [backward v] (2) layers\n        change [tp.editor.ghost v] by (((<not <(tp.editor.mode) = [3]>> * (100)) - (tp.editor.ghost)) * (0.2))\n        set [ghost v] effect to (tp.editor.ghost)\n    end\nend\n\nwhen I start as a clone\nif <(tp.editor.cloneID) = ((tp.level.tileNum) + (5))> then\n    switch costume to (save v)\n    go to x: (-50) y: (100)\n    forever\n        if <<touching (mouse-pointer v)?> and <<mouse down?> and <(tp.editor.mode) = [3]>>> then\n            start sound [Select v]\n            set [tp.editor.mode v] to [2]\n            wait (0.1) seconds\n            broadcast (tp.editor.showCode v)\n        end\n    end\nend\nif <(tp.editor.cloneID) = ((tp.level.tileNum) + (6))> then\n    switch costume to (load v)\n    go to x: (-50) y: (0)\n    forever\n        if <<touching (mouse-pointer v)?> and <<mouse down?> and <(tp.editor.mode) = [3]>>> then\n            start sound [Select v]\n            set [tp.editor.mode v] to [2]\n            ask [] and wait\n            delete all of [code v]\n            add (answer) to [code v]\n            broadcast (tp.editor.load v)\n        end\n    end\nend\nif <(tp.editor.cloneID) = ((tp.level.tileNum) + (7))> then\n    switch costume to (exit v)\n    go to x: (-50) y: (-100)\n    forever\n        if <<touching (mouse-pointer v)?> and <<mouse down?> and <(tp.editor.mode) = [3]>>> then\n            wait until <not <mouse down?>>\n            start sound [Select v]\n            broadcast (tp.transition.show v) and wait\n            erase all\n            broadcast (tp.menu v)\n            broadcast (tp.transition.hide v)\n            broadcast (tp.editor.stop v)\n        end\n    end\nend\n\nwhen I start as a clone\nif <<(tp.editor.cloneID) = [1]> or <(tp.editor.cloneID) = ((tp.level.tileNum) + (4))>> then\n    if <(tp.editor.cloneID) = [1]> then\n        switch costume to (tile selector v)\n    else\n        switch costume to (options v)\n    end\n    show\n    go to x: (((<(tp.editor.cloneID) = [1]> * (2)) - (1)) * (-215)) y: (155)\n    set [tp.editor.ghost v] to [100]\n    forever\n        go to [front v] layer\n        go [backward v] (1) layers\n    end\nend\n\ndefine Set editor block (n)\nset [tp.editor.block v] to (n)\nif <(tp.editor.block) < [1]> then\n    set [tp.editor.block v] to (tp.level.tileNum)\nend\nif <(tp.editor.block) > (tp.level.tileNum)> then\n    set [tp.editor.block v] to [1]\nend\n\nwhen I receive [tp.editor.load v]\nif <(tp.editor.cloneID) = [0]> then\n    Load level\n    set [tp.editor.mode v] to [3]\nend\n\nwhen I receive [tp.editor.stop v]\nstop [other scripts in sprite v]\ndelete this clone\n\nwhen I start as a clone\nif <(tp.editor.cloneID) = [1]> then\n    forever\n        if <(tp.editor.mode) < [2]> then\n            replace item (1) of [tp.editor.hover v] with (<(distance to [mouse-pointer v]) < [30]> * (1))\n            change [tp.editor.ghost v] by (((<not <(distance to [mouse-pointer v]) < [30]>> * (100)) - (tp.editor.ghost)) * (0.2))\n            if <<mouse down?> and <(distance to [mouse-pointer v]) < [30]>> then\n                set [tp.editor.mode v] to (<not <(tp.editor.mode) = [1]>> * (1))\n                wait until <not <mouse down?>>\n            end\n        end\n        set [ghost v] effect to (tp.editor.ghost)\n    end\nend\nif <(tp.editor.cloneID) = ((tp.level.tileNum) + (4))> then\n    forever\n        if <not <<(tp.editor.mode) = [1]> or <(tp.editor.mode) = [2]>>> then\n            replace item (3) of [tp.editor.hover v] with (<(distance to [mouse-pointer v]) < [30]> * (1))\n            change [tp.editor.ghost v] by (((<not <(distance to [mouse-pointer v]) < [30]>> * (100)) - (tp.editor.ghost)) * (0.2))\n            if <<mouse down?> and <(distance to [mouse-pointer v]) < [30]>> then\n                set [tp.editor.mode v] to (<not <(tp.editor.mode) = [3]>> * (3))\n                wait until <not <mouse down?>>\n            end\n        end\n        set [ghost v] effect to (tp.editor.ghost)\n    end\nend\n\n@Solid Blocks\n\ndefine Check Tile (i)\nset [i2 v] to [0]\nrepeat (length of [tp.editor.blocklist v])\n    change [i2 v] by (1)\n    if <(i) = (letter (1) of (item (i2) of [tp.editor.blocklist v]))> then\n        switch costume to (item (i2) of [tp.editor.blocklist v])\n    end\nend\n\nwhen I receive [tp.level.load v]\nLoad Tiles\n\ndefine Load Tiles\nset [i v] to [0]\nrepeat ((length of [tp.level.solid v]) / (3))\n    change [i v] by (1)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\ngo to x: (item (((i) * (3)) - (2)) of [tp.level.solid v]) y: (item (((i) * (3)) - (1)) of [tp.level.solid v])\nCheck Tile (item ((i) * (3)) of [tp.level.solid v])\nshow\nset [brightness v] effect to ((<(tp.music) = [5]> * (-25)) + (<(tp.music) < [4]> * (((tp.music) - (1)) * (-25))))\n\nwhen I receive [tp.level.deleteobjects v]\ndelete this clone\n\n@Special Blocks\n\nwhen I start as a clone\ngo to x: (item (((tp.level.cloneId) * (3)) - (2)) of [tp.level.special v]) y: (item (((tp.level.cloneId) * (3)) - (1)) of [tp.level.special v])\nCheck Tile (item ((tp.level.cloneId) * (3)) of [tp.level.special v])\nshow\nset [brightness v] effect to ((<(tp.music) = [5]> * (-25)) + (<(tp.music) < [4]> * (((tp.music) - (1)) * (-25))))\nif <(item ((tp.level.cloneId) * (3)) of [tp.level.special v]) = [f]> then\n    forever\n        change y by (10)\n        if <touching (player v)?> then\n            replace item (tp.level.cloneId) of [tp.level.specialcollision v] with [f]\n        else\n            replace item (tp.level.cloneId) of [tp.level.specialcollision v] with [0]\n        end\n        change y by (-10)\n    end\nend\nif <(item ((tp.level.cloneId) * (3)) of [tp.level.special v]) = [g]> then\n    forever\n        change y by (10)\n        if <touching (player v)?> then\n            replace item (tp.level.cloneId) of [tp.level.specialcollision v] with [g]\n        else\n            replace item (tp.level.cloneId) of [tp.level.specialcollision v] with [0]\n        end\n        change y by (-10)\n    end\nend\nif <(item ((tp.level.cloneId) * (3)) of [tp.level.special v]) = [h]> then\n    forever\n        change y by (10)\n        if <touching (player v)?> then\n            replace item (tp.level.cloneId) of [tp.level.specialcollision v] with [h]\n        else\n            replace item (tp.level.cloneId) of [tp.level.specialcollision v] with [0]\n        end\n        change y by (-10)\n    end\nend\nif <(item ((tp.level.cloneId) * (3)) of [tp.level.special v]) = [i]> then\n    forever\n        change y by (10)\n        if <touching (player v)?> then\n            replace item (tp.level.cloneId) of [tp.level.specialcollision v] with [i]\n        else\n            replace item (tp.level.cloneId) of [tp.level.specialcollision v] with [0]\n        end\n        change y by (-10)\n    end\nend\nif <(item ((tp.level.cloneId) * (3)) of [tp.level.special v]) = [k]> then\n    forever\n        change y by (10)\n        if <touching (player v)?> then\n            replace item (tp.level.cloneId) of [tp.level.specialcollision v] with [k]\n        else\n            replace item (tp.level.cloneId) of [tp.level.specialcollision v] with [0]\n        end\n        change y by (-10)\n    end\nend\n\ndefine Check Tile (i)\nset [i2 v] to [0]\nrepeat (length of [tp.editor.blocklist v])\n    change [i2 v] by (1)\n    if <(i) = (letter (1) of (item (i2) of [tp.editor.blocklist v]))> then\n        switch costume to (item (i2) of [tp.editor.blocklist v])\n    end\nend\n\nwhen I receive [tp.level.load v]\ndelete (all) of [tp.level.specialcollision v]\nLoad Tiles\n\ndefine Load Tiles\nset [tp.level.cloneid v] to [0]\nrepeat ((length of [tp.level.special v]) / (3))\n    change [tp.level.cloneid v] by (1)\n    add [0] to [tp.level.specialcollision v]\n    create clone of (_myself_ v)\nend\n\nwhen I receive [tp.level.deleteobjects v]\ndelete this clone\n\n@Hazards\n\nwhen I receive [tp.level.load v]\nLoad Tiles\n\ndefine Check Tile (i)\nset [i2 v] to [0]\nrepeat (length of [tp.editor.blocklist v])\n    change [i2 v] by (1)\n    if <(i) = (letter (1) of (item (i2) of [tp.editor.blocklist v]))> then\n        switch costume to (item (i2) of [tp.editor.blocklist v])\n    end\nend\n\ndefine Load Tiles\nset [i v] to [0]\nrepeat ((length of [tp.level.hazards v]) / (3))\n    change [i v] by (1)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\ngo to x: (item (((i) * (3)) - (2)) of [tp.level.hazards v]) y: (item (((i) * (3)) - (1)) of [tp.level.hazards v])\nCheck Tile (item ((i) * (3)) of [tp.level.hazards v])\nshow\nset [brightness v] effect to ((<(tp.music) = [5]> * (-25)) + (<(tp.music) < [4]> * (((tp.music) - (1)) * (-25))))\nif <(item ((i) * (3)) of [tp.level.hazards v]) = [c]> then\n    forever\n        switch costume to (goal hitbox v)\n        if <touching (player v)?> then\n            start sound [pickupGem v]\n            repeat (20)\n                change [ghost v] effect by (5)\n                change y by (2)\n            end\n            if <(tp.mode) = [1]> then\n                change [tp.level v] by (1)\n                broadcast (tp.level.loadCurrent v)\n            end\n            if <(tp.mode) = [3]> then\n                broadcast (tp.transition.show v) and wait\n                broadcast (tp.menu v)\n                broadcast (tp.transition.hide v)\n            end\n        end\n        switch costume to (c goal v)\n    end\nend\nif <(item ((i) * (3)) of [tp.level.hazards v]) = [e]> then\n    forever\n        switch costume to (spike hitbox v)\n        if <touching (player v)?> then\n            broadcast (tp.level.kill v)\n        end\n        switch costume to (e spike v)\n    end\nend\nif <(item ((i) * (3)) of [tp.level.hazards v]) = [j]> then\n    forever\n        if <touching (player v)?> then\n            broadcast (tp.level.kill v)\n        end\n    end\nend\nif <(item ((i) * (3)) of [tp.level.hazards v]) = [l]> then\n    forever\n        go to [back v] layer\n    end\nend\nif <(item ((i) * (3)) of [tp.level.hazards v]) = [n]> then\n    forever\n        go to [back v] layer\n        switch costume to (spike hitbox v)\n        if <touching (player v)?> then\n            broadcast (tp.level.kill v)\n        end\n        switch costume to (n trap spike v)\n    end\nend\n\nwhen I receive [tp.level.deleteobjects v]\ndelete this clone\n\nwhen I start as a clone\nif <(item ((i) * (3)) of [tp.level.hazards v]) = [n]> then\n    forever\n        repeat (20)\n            change y by (-1)\n        end\n        wait until <<<([x position v] of [player v]) > ((x position) - (20))> and <([x position v] of [player v]) < ((x position) + (20))>> and <([y position v] of [player v]) > (y position)>>\n        start sound [hit v]\n        repeat (5)\n            change y by (4)\n        end\n    end\nend\n\n@Level Loader\n\ndefine Load Level []\nbroadcast (tp.level.deleteObjects v) and wait\ngo to x: (-230) y: (-170)\nset [i v] to [0]\ndelete (all) of [tp.level.solid v]\ndelete (all) of [tp.level.hazards v]\ndelete (all) of [tp.level.special v]\ndelete (all) of [tp.level.spawn v]\ndelete (all) of [_tp:lights v]\nrepeat (18)\n    repeat (24)\n        change [i v] by (1)\n        if <<<(letter (i) of (code)) > [0]> and <(letter (i) of (code)) < [10]>> or <<(letter (i) of (code)) = [a]> or <<(letter (i) of (code)) = [b]> or <<(letter (i) of (code)) = [o]> or <(letter (i) of (code)) = [p]>>>>> then\n            add (x position) to [tp.level.solid v]\n            add (y position) to [tp.level.solid v]\n            add (letter (i) of (code)) to [tp.level.solid v]\n        else\n            if <<(letter (i) of (code)) = [c]> or <<(letter (i) of (code)) = [e]> or <<(letter (i) of (code)) = [l]> or <<(letter (i) of (code)) = [j]> or <(letter (i) of (code)) = [n]>>>>> then\n                add (x position) to [tp.level.hazards v]\n                add (y position) to [tp.level.hazards v]\n                add (letter (i) of (code)) to [tp.level.hazards v]\n            else\n                if <(letter (i) of (code)) = [d]> then\n                    add (x position) to [tp.level.solid v]\n                    add (y position) to [tp.level.solid v]\n                    add (x position) to [tp.level.spawn v]\n                    add ((y position) + (20)) to [tp.level.spawn v]\n                    add (letter (i) of (code)) to [tp.level.solid v]\n                else\n                    if <<(letter (i) of (code)) = [f]> or <<(letter (i) of (code)) = [g]> or <<(letter (i) of (code)) = [h]> or <<(letter (i) of (code)) = [i]> or <(letter (i) of (code)) = [k]>>>>> then\n                        add (x position) to [tp.level.special v]\n                        add (y position) to [tp.level.special v]\n                        add (letter (i) of (code)) to [tp.level.special v]\n                    else\n                        if <(letter (i) of (code)) = [m]> then\n                            add (x position) to [tp.level.spawn v]\n                            add (y position) to [tp.level.spawn v]\n                        end\n                    end\n                end\n            end\n        end\n        change x by (20)\n    end\n    change y by (20)\n    set x to (-230)\nend\nif <(tp.level.type) = [1]> then\n    set [tp.music v] to (letter (length of (code)) of (code))\n    if <not <[tp.music.list v] contains (tp.music)?>> then\n        set [tp.music v] to [1]\n    end\nelse\n    set [tp.music v] to [5]\nend\nset [tp.level.verify v] to [0]\n\nwhen I receive [tp.level.loadcustom v]\nbroadcast (tp.transition.show v) and wait\nLoad Level (item (1) of [code v])\nbroadcast (tp.level.load v) and wait\nbroadcast (tp.transition.hide v) and wait\nbroadcast (tp.level.loaded v)\n\nwhen I receive [tp.level.loadcurrent v]\nbroadcast (tp.transition.show v) and wait\nif <(tp.level.type) = [1]> then\n    if <(tp.level) > (length of [tp.levels.main v])> then\n        broadcast (tp.transition.hide v)\n        broadcast (tp.menu v)\n        stop [this script v]\n    else\n        Load Level (item (tp.level) of [tp.levels.main v])\n    end\nelse\n    if <(tp.level) > (length of [tp.levels.extra v])> then\n        broadcast (tp.transition.hide v)\n        broadcast (tp.menu v)\n        stop [this script v]\n    else\n        Load Level (item (tp.level) of [tp.levels.extra v])\n    end\nend\nbroadcast (tp.level.load v) and wait\nbroadcast (tp.transition.hide v) and wait\nbroadcast (tp.level.loaded v)\n\nwhen I receive [tp.level.load v]\nbroadcast (tp.menu.stop v)\n\nwhen I receive [tp.level.loaded v]\nbroadcast (tp.level.menuReturn v)\n\n@Transition\n\nwhen I receive [tp.transition.show v]\nset [ghost v] effect to (100)\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\n\nwhen I receive [tp.transition.hide v]\nset [ghost v] effect to (0)\nshow\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\nwhen I receive [tp.init v]\nhide\nforever\n    go to [front v] layer\nend\n\n