Colors (A Scrolling Platformer)

Instructions:  Use the arrow keys or the mouse to move.\n\nComment if you won!\n\nMake a nice comment or win and you might get on the credit crew. 

@Stage\n\n@player\n\nwhen flag clicked\nhide\nset volume to (100) %\nbroadcast (green flag v) and wait\nbroadcast (start! v) and wait\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\ngo [backward v] (1) layers\n\ndefine game on!\nset [scroll x v] to ((SCROLL X) / (5))\nset [scroll y v] to ((SCROLL Y) / (5))\nset [scroll x v] to (round (SCROLL X))\nset [scroll y v] to (round (SCROLL Y))\nset [x v] to [0]\nset [y v] to [0]\nset [sy v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nbroadcast (close space v)\nset rotation style [all around v]\npoint in direction (90)\nswitch costume to (base v)\nset [ghost v] effect to (0)\nclear graphic effects\nset size to (75) %\nshow\n\ndefine Tick\nif <touching (bounce v)?> then\n    set [sy v] to [30]\nend\nif <<key (right arrow v) pressed?> or <<mouse down?> and <(mouse x) > [10]>>> then\n    change player x by [8]\nelse\n    if <<key (left arrow v) pressed?> or <<mouse down?> and <(mouse x) < [-10]>>> then\n        change player x by [-8]\n    end\nend\nif <<key (up arrow v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>> then\n    if <(in air) < [4]> then\n        set [sy v] to [16]\n    end\nend\nif <touching (platforms v)?> then\nchange [sy v] by (-2)\nchange player y by (sy)\ntest die\nchange [scroll x v] by (round (((x) - (SCROLL X)) / (10)))\nif <(SCROLL X) < [0]> then\n    set [scroll x v] to [0]\nend\nchange [scroll y v] by (round (((y) - (SCROLL Y)) / (10)))\nif <(SCROLL Y) < [0]> then\n    set [scroll y v] to [0]\nend\nposition\nif <(y) < [-180]> then\n    set [exit v] to [die]\nend\n\ndefine change player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nposition\nrepeat until <not <touching (platforms v)?>>\n    if <(sy) > [0]> then\n        change [y v] by (-1)\n    else\n        change [y v] by (1)\n        set [in air v] to [0]\n    end\n    position\n    set [sy v] to [0]\nend\n\ndefine change player x by (sx)\nchange [x v] by (sx)\nposition\nif <touching (platforms v)?> then\n    repeat (10)\n        change [y v] by (1)\n        position\n        if <not <touching (platforms v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-10)\n    repeat until <not <touching (platforms v)?>>\n        if <(sx) > [0]> then\n            change [x v] by (-1)\n        else\n            change [x v] by (1)\n        end\n        position\n    end\nend\n\ndefine game-die\nset [exit v] to []\nrepeat (5)\n    hide\n    wait (0.1) seconds\n    show\n    wait (0.1) seconds\nend\nhide\nwait (0.5) seconds\n\ndefine test die\nif <touching (danger v)?> then\n    set [exit v] to [die]\nend\n\ndefine game - win\nrepeat (50)\n    point towards (exit v)\n    turn right (65) degrees\n    move ((distance to [exit v]) / (2)) steps\n    change size by (-0.5)\n    change [ghost v] effect by (2)\nend\nhide\nchange [level v] by (1)\nwait (1) seconds\n\nwhen I receive [green flag v]\nset [level v] to [1]\nforever\n    broadcast (reset v) and wait\n    broadcast (setup v) and wait\n    game on!\n    repeat until <(EXIT) > []>\n        Tick\n        broadcast (tick v) and wait\n        broadcast (attack? v)\n    end\n    if <(EXIT) = [win]> then\n        game - win\n        set [scroll x v] to [0]\n        set [scroll y v] to [0]\n    else\n        game-die\n    end\nend\n\ndefine position\ngo to x: ((x) - (SCROLL X)) y: ((y) - (SCROLL Y))\n\n@THUMBNAIL\n\nwhen flag clicked\nhide\n\ngo to [front v] layer\n\nshow\n\n@stages\n\nwhen I receive [tick v]\ngo to [front v] layer\nswitch costume to (LEVEL)\n\n@bounce\n\nwhen I receive [green flag v]\nswitch costume to (level 1 1 v)\nset size to (100) %\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\npoint in direction ((([sin v] of ((timer) * (300)) ) * (turn?)) + (90))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nset [turn? v] to [0]\nswitch costume to (level 1 1 v)\nif <(LEVEL) = [1]> then\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\n    go to [back v] layer\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y) with rotation (turn)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nset [turn? v] to (turn)\nnext costume\n\n@Exit\n\nwhen I receive [green flag v]\nhide\nswitch costume to (open v)\nset [ghost v] effect to (0)\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) (((y) - (SCROLL Y)) + (([sin v] of ((timer) * (300)) ) * (-5)))\nif <touching (player v)?> then\n    set [exit v] to [win]\nend\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    Clone at x: [2359] y: [119]\nelse\n    if <(LEVEL) = [2]> then\n        Clone at x: [2952] y: [375]\n    else\n        if <(LEVEL) = [3]> then\n            Clone at x: [2705] y: [-64]\n        else\n            if <(LEVEL) = [4]> then\n                Clone at x: [2689] y: [-75]\n            else\n                if <(LEVEL) = [5]> then\n                    Clone at x: [225] y: [144]\n                else\n                    if <(LEVEL) = [6]> then\n                        Clone at x: [10000] y: [144]\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\nset [x v] to (x)\nset [y v] to (y)\n\nwhen [m v] key pressed\nshow variable [mouse v]\nset [mouse v] to (join ((mouse x) + (SCROLL X)) (join [,] ((mouse y) + (SCROLL Y))))\n\n@Danger\n\nwhen I receive [green flag v]\nset [ghost v] effect to (10)\nswitch costume to (level 1 1 v)\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (level 1 1 v)\nif <(my variable) = [1]> then\n    Clone at x: [1554] y: [-28]\n    Clone at x: [360] y: []\nelse\n    if <(my variable) = [2]> then\n        switch costume to (level 2 1 v)\n        Clone at x: [486] y: [-85]\n        Clone at x: [900] y: [200]\n        Clone at x: [1200] y: [200]\n    else\n        if <(my variable) = [3]> then\n            switch costume to (level 3 1 v)\n            Clone at x: [600] y: []\n            Clone at x: [1200] y: [303]\n            Clone at x: [400] y: [-303]\n        else\n            if <(my variable) = [4]> then\n                switch costume to (level 4 1 v)\n                Clone at x: [720] y: []\n                Clone at x: [360] y: []\n                Clone at x: [360] y: []\n                Clone at x: [800] y: []\n                Clone at x: [360] y: []\n            else\n                if <(my variable) = [5]> then\n                    switch costume to (level 5 1 v)\n                    Clone at x: [360] y: []\n                    Clone at x: [180] y: []\n                    Clone at x: [360] y: []\n                    Clone at x: [] y: [100]\n                else\n                    if <(my variable) = [6]> then\n                        switch costume to (level 6 1 v)\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\ngo to [back v] layer\ngo [forward v] (1) layers\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\n@platforms\n\nwhen I receive [green flag v]\nset [ghost v] effect to (0)\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nclear graphic effects\nhide\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (level 1 1 v)\nif <(my variable) = [1]> then\n    Clone at x: [480] y: [0]\n    Clone at x: [340] y: [0]\n    Clone at x: [400] y: [0]\n    Clone at x: [400] y: [0]\n    Clone at x: [400] y: [0]\nelse\n    if <(my variable) = [2]> then\n        switch costume to (level 2 1 v)\n        Clone at x: [480] y: [0]\n        Clone at x: [480] y: [0]\n        Clone at x: [480] y: [0]\n        Clone at x: [480] y: [100]\n        Clone at x: [480] y: [100]\n    else\n        if <(my variable) = [3]> then\n            switch costume to (level 3 1 v)\n            Clone at x: [480] y: []\n            Clone at x: [480] y: []\n            Clone at x: [615] y: []\n            Clone at x: [480] y: []\n            Clone at x: [480] y: []\n            Clone at x: [480] y: []\n        else\n            if <(my variable) = [4]> then\n                switch costume to (level 4 1 v)\n                Clone at x: [480] y: []\n                Clone at x: [480] y: []\n                Clone at x: [450] y: []\n                Clone at x: [450] y: []\n                Clone at x: [800] y: []\n            else\n                if <(my variable) = [5]> then\n                    switch costume to (level 5 1 v)\n                    Clone at x: [480] y: []\n                    Clone at x: [480] y: []\n                    Clone at x: [-1200] y: [200]\n                else\n                    if <(my variable) = [6]> then\n                        switch costume to (level 6 1 v)\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nClone at x: [480] y: []\nClone at x: [450] y: []\nClone at x: [450] y: []\nClone at x: [800] y: []\n\n