Gray (Platformer)

Instructions: This is a short little precision platformer!\nHave fun!

@Stage\n\nwhen flag clicked\nforever\n    play sound [Kaled v] until done\nend\n\n@Guy\n\nwhen flag clicked\nshow\ngo to [back v] layer\nset [vy v] to [0]\nset [level v] to [1]\ngo to x: (-180) y: (0)\nset [touching tunnels? v] to [0]\nset [tunnels2 :p v] to [0]\nset [tunnelpoints v] to [0]\nforever\n    change y by (3)\n    change x by (<(vx) > [0]> * (-1))\n    change [vx v] by (<key (right arrow v) pressed?> * (1.5))\n    change [vx v] by (<key (left arrow v) pressed?> * (-1.5))\n    if <not <touching (level v)?>> then\n        change x by (vx)\n    end\n    set [vx v] to ((vx) * (0.8))\n    if <touching (level v)?> then\n        change y by (1)\n        if <touching (level v)?> then\n            change y by (1)\n            if <touching (level v)?> then\n                change y by (1)\n                if <touching (level v)?> then\n                    change y by (-3)\n                end\n            end\n        end\n    end\n    if <touching (level v)?> then\n        change y by (1)\n        if <touching (level v)?> then\n            change y by (1)\n            if <touching (level v)?> then\n                change y by (1)\n                if <touching (level v)?> then\n                    change y by (-3)\n                    z\n                    change y by (10)\n                    if <not <touching (bounce v)?>> then\n                        if <<<<key (up arrow v) pressed?> and <<not <((round ((vx) * (0.1))) / (0.1)) = [0]>> or <not <(vx-old) = [0]>>>> and <(walljump-timer) > [5]>> and <(jump-timer) > [10]>> then\n                            change y by (-35)\n                            if <<not <touching (level v)?>> or <[-150] > (y position)>> then\n                                change y by (35)\n                                set [vy v] to [0]\n                                broadcast (message0 v)\n                            else\n                                change y by (35)\n                            end\n                        end\n                    end\n                    change y by (-10)\n                end\n            end\n        end\n    end\n    change [vy v] by (-1)\n    change y by (vy)\n    if <touching (level v)?> then\n        change y by ((vy) * (-1))\n        if <(vy) > [0]> then\n            set [vy v] to [0]\n        else\n            set [i v] to [0]\n            set [vy v] to [0]\n        end\n    end\n    if <key (up arrow v) pressed?> then\n        if <not <touching (bounce v)?>> then\n            if <[5] > (i)> then\n                set [jump-timer v] to [0]\n                set [vy v] to [12]\n            end\n        end\n    end\n    if <<(x position) > [240]> or <<touching (tunnel v)?> and <(x position) > [210]>>> then\n        change [level v] by (1)\n        set [vy v] to [0]\n        set [vx v] to [0]\n        if <not <(level) = [13]>> then\n            go to x: (-180) y: (0)\n        else\n            go to x: (-180) y: (-135)\n        end\n    end\n    if <<[-180] > (y position)> or <touching (spike v)?>> then\n        set [i v] to [99]\n        set [vy v] to [0]\n        set [vx v] to [0]\n        if <not <(level) = [13]>> then\n            go to x: (-180) y: (0)\n        else\n            go to x: (-180) y: (-135)\n        end\n    end\n    if <touching (bounce v)?> then\n        set [i v] to [5]\n        if <key (up arrow v) pressed?> then\n            set [vy v] to [20]\n        end\n    end\n    change y by (-3)\n    change x by <(vx) > [0]>\n    change [jump-timer v] by (1)\n    change [walljump-timer v] by (1)\n    change [i v] by (1)\nend\n\ndefine z\nrepeat until <not <touching (level v)?>>\n    change x by ((vx) * (-0.1))\n    if <<(vx) > [-0.001]> and <[0.001] > (vx)>> then\n        set [vx v] to ((vx) * (2))\n    end\nend\n\nwhen I receive [message1 v]\nchange x by (3)\nset [vy v] to [10]\nset [walljump-timer v] to [0]\nrepeat (10)\n    set [vx v] to [10]\nend\n\nwhen I receive [message2 v]\nchange x by (-3)\nset [vy v] to [10]\nset [walljump-timer v] to [0]\nrepeat (10)\n    set [vx v] to [-10]\nend\n\nwhen I receive [message0 v]\nset [vx-old v] to ((vx) * (8))\nrepeat until <<<<<key (right arrow v) pressed?> or <key (left arrow v) pressed?>> and <(jump-timer) > [10]>> and <not <(vy) = [0]>>> and <<[-5] > (vx-old)> or <(vx-old) > [5]>>>\n    d\nend\nif <(vx-old) > [5]> then\n    repeat until <<<key (left arrow v) pressed?> and <(jump-timer) > [10]>> and <not <(vy) = [0]>>>\n        d\n    end\nelse\n    if <[-5] > (vx-old)> then\n        repeat until <<<key (right arrow v) pressed?> and <(jump-timer) > [10]>> and <not <(vy) = [0]>>>\n            d\n        end\n    end\nend\nif <<key (right arrow v) pressed?> and <[-5] > (vx-old)>> then\n    broadcast (message1 v)\nend\nif <<key (left arrow v) pressed?> and <(vx-old) > [5]>> then\n    broadcast (message2 v)\nend\nset [vx-old v] to [0]\n\ndefine d\nchange x by (3)\nif <not <touching (level v)?>> then\n    change x by (-6)\n    if <not <touching (level v)?>> then\n        change x by (3)\n        set [vx-old v] to [0]\n        stop [this script v]\n    else\n        change x by (3)\n    end\nelse\n    change x by (-3)\nend\n\n@Level\n\nwhen flag clicked\nshow\nforever\n    switch costume to (level)\nend\n\n@Spike\n\nwhen flag clicked\nshow\nforever\n    switch costume to (level)\nend\n\ngo to [front v] layer\n\n@Background\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [ghost v] effect to (95)\nshow\ngo to [front v] layer\nswitch costume to (h2 v)\ncreate clone of (_myself_ v)\nset [ghost v] effect to (60)\ngo to [back v] layer\nswitch costume to (z v)\ncreate clone of (_myself_ v)\nhide\n\n@Tunnel\n\nwhen flag clicked\nshow\nset [ghost v] effect to (0.1)\nforever\n    switch costume to (level)\nend\n\nset [ghost v] effect to (0.1)\n\n@Falling light\n\nwhen flag clicked\nset size to (100) %\ngo to [back v] layer\nhide\nrepeat (4)\n    Randomize\n    create clone of (_myself_ v)\nend\nforever\n    wait (5) seconds\n    Randomize\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nshow\nclear graphic effects\nset [move v] to (pick random (-1.) to (1.))\nset [ghost v] effect to (100)\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nrepeat (30)\n    repeat (10)\n        turn left ((move) / (10)) degrees\n        change x by (move)\n    end\n    change [ghost v] effect by (5)\nend\ndelete this clone\n\ndefine Randomize\ngo to x: (pick random (-200) to (200)) y: (0)\nswitch costume to (pick random (1) to (3))\n\n@Bounce\n\nwhen flag clicked\nshow\nforever\n    go to [back v] layer\n    switch costume to (level)\nend\n\nset [brightness v] effect to (-30)\n\nset [color v] effect to (50)\n\n@ImageSprite1Bouncies\n\nwhen flag clicked\nhide\n\n