An Unexpected Platformer

Instructions: Expect the Unexpected in this Blockhead platformer. Everything in this platformer is not as it seems. Anything could be safe. Anything could be a trap.\nUse the usual arrow keys (up, right, left) to control Blockhead.\nIf we get to 100 likes, I'll make a sequel!

@Stage\n\n@Blockhead\n\ndefine touch ground\nrepeat until <<not <touching (moving platform v)?>> and <not <touching (ground v)?>>>\n    if <(ySpeed) > [0]> then\n        change y by (-1)\n    else\n        change y by (1)\n    end\n    set [yspeed v] to [0]\nend\n\ndefine walk (speed)\nchange x by (speed)\nset [slope v] to [0]\nrepeat until <<(slope) = [8]> or <not <touching (ground v)?>>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <(slope) = [8]> then\n    if <key (up arrow v) pressed?> then\n        change x by ((0) - ((speed) * (4)))\n        set [yspeed v] to [10]\n    else\n        change y by ((0) - (slope))\n        change x by ((0) - (speed))\n    end\nelse\n    set [xspeed v] to (speed)\n    change x by ((0) - (speed))\nend\n\nwhen I receive [play v]\nwait (0.25) seconds\nforever\n    look for traps\n    set [ghost v] effect to (0)\nend\n\nwhen I receive [play v]\nset [xspeed v] to [0]\nset [ghost v] effect to (0)\ngo to x: (-200) y: (-50)\nset [yspeed v] to [0]\nforever\n    if <(level) = [16]> then\n        hide\n        broadcast (complete v)\n        stop [this script v]\n    else\n        loop\n    end\nend\n\nwhen flag clicked\nbroadcast (play v)\n\ndefine jump\nchange y by (-1)\nif <<key (up arrow v) pressed?> and <<touching (moving platform v)?> or <touching (ground v)?>>> then\n    set [yspeed v] to [12]\nend\nchange y by (1)\n\ndefine look for traps\nchange y by (-2)\nif <<(y position) < [-170]> or <touching (traps v)?>> then\n    broadcast (die v)\nend\nchange y by (2)\n\nwhen I receive [die v]\nchange [blunders v] by (1)\nstop [other scripts in sprite v]\nrepeat (25)\n    change [ghost v] effect by (4)\nend\nbroadcast (play v)\nstop [this script v]\n\ndefine hittop\nif <[0] < (ySpeed)> then\n    change y by (ySpeed)\n    if <<touching (moving platform v)?> or <touching (ground v)?>> then\n        repeat until <<not <touching (moving platform v)?>> and <not <touching (ground v)?>>>\n            change y by (-1)\n            set [yspeed v] to [-1]\n        end\n    end\n    change y by ((0) - (ySpeed))\nend\n\ndefine moveOnPlatform\nchange y by (-2)\nif <touching (moving platform v)?> then\n    change x by (platformPushX)\nend\nchange y by (2)\n\ndefine slow down\nchange y by (-2)\nif <touching color (#32e6f0)?> then\n    set [xspeed v] to ((xSpeed) * (0.95))\nelse\n    set [xspeed v] to [0]\nend\nchange y by (2)\n\ndefine loop\nshow\nlayer\nif <key ((item (2) of [arrowkeys v]) v) pressed?> then\n    walk [4]\nelse\n    if <key ((item (1) of [arrowkeys v]) v) pressed?> then\n        walk [-4]\n    else\n        slow down\n    end\nend\nif <[235] < (x position)> then\n    broadcast (next level v)\n    broadcast (play v)\nend\nchange x by (xSpeed)\nchange y by (ySpeed)\nchange [yspeed v] by (-1)\njump\ntouch ground\nhittop\nmoveOnPlatform\n\ndefine layer\ngo to [front v] layer\ngo [backward v] (1) layers\n\nwhen flag clicked\nset [blunders v] to [0]\nreset timer\n\nwhen flag clicked\ndelete all of [arrowkeys v]\nadd [right arrow] to [arrowkeys v]\nadd [left arrow] to [arrowkeys v]\n\nwhen [e v] key pressed\nif <(item (1) of [arrowkeys v]) = [right arrow]> then\n    delete all of [arrowkeys v]\n    add [left arrow] to [arrowkeys v]\n    add [right arrow] to [arrowkeys v]\nelse\n    delete all of [arrowkeys v]\n    add [right arrow] to [arrowkeys v]\n    add [left arrow] to [arrowkeys v]\nend\n\n@Ground\n\nwhen I receive [next level v]\nnext costume\nset [level v] to (costume [number v])\n\nwhen flag clicked\nswitch costume to (1 v)\nforever\n    layer\n    set [level v] to (costume [number v])\nend\n\ndefine layer\nshow\ngo to [front v] layer\ngo [backward v] (1) layers\n\n@Traps\n\nwhen I receive [next level v]\nnext costume\n\nwhen flag clicked\ngo to [back v] layer\nswitch costume to (1 v)\n\n@Ha, fooled you!\n\nwhen flag clicked\nswitch costume to (1 v)\n\nwhen I receive [next level v]\nnext costume\n\n@Moving Platform\n\nwhen flag clicked\nhide\nforever\n    if <<(level) = [8]> or <(level) = [12]>> then\n        if <(level) = [8]> then\n            go to x: (-131) y: (-112)\n        else\n            go to x: (0) y: (0)\n        end\n        show\n        repeat (60)\n            set [platformpushx v] to [3]\n            change x by (3)\n        end\n        repeat (60)\n            set [platformpushx v] to [-3]\n            change x by (-3)\n        end\n    else\n        hide\n        go to x: (-134) y: (-112)\n    end\nend\n\nwhen flag clicked\nhide\nforever\n    if <<(level) = [8]> or <(level) = [12]>> then\n        show\n    else\n        hide\n    end\nend\n\n@Splash\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    set [ghost v] effect to (100)\nend\n\nshow\n\n@Highscore Table\n\nwhen I receive [complete v]\nDecode (☁ data)\nif <not < [] contains (username)?>> then\n    set [completers v] to (join (join (username) [ , ]) (Completers))\nend\nEncode (Completers)\nset [☁ data v] to (Return)\n\ndefine Encode (characters)\nset [encoded message v] to []\nset [repeats v] to [1]\nrepeat (length of (characters))\n    switch costume to ( v)\n    repeat until <(costume [name v]) = (letter (Repeats) of (characters))>\n        next costume\n    end\n    set [encoded message v] to (join (Encoded Message) ((costume [number v]) + (10)))\n    change [repeats v] by (1)\nend\nset [☁ data v] to (Encoded Message)\n\ndefine Decode (numbers)\nset [return v] to []\nset [repeats v] to [0]\nrepeat (round ((length of (numbers)) / (2)))\n    repeat until <((costume [number v]) + (10)) = (join (letter ((Repeats) + (1)) of (numbers)) (letter ((Repeats) + (2)) of (numbers)))>\n        next costume\n    end\n    set [return v] to (join (Return) (costume [name v]))\n    change [repeats v] by (2)\n    if <(costume [name v]) = [ ]> then\n        set [return v] to []\n        set [completers v] to (join (Return) (Completers))\n    end\nend\n\n