Unnamed Platformer

Instructions: --=Unnamed Platformer=--\n\n- Arrow keys or WAD to move\n- You can double jump\n- Avoid red

@Stage\n\nwhen flag clicked\nbroadcast (GreenFlag v)\nbroadcast (SetUp v)\n\nwhen I receive [greenflag v]\nforever\n    play sound [Panda Eyes - Rainbow Road v] until done\nend\n\n@Player\n\nwhen I receive [greenflag v]\nhide\n\nwhen I receive [setup v]\nshow\nbroadcast (Reset v) and wait\nbroadcast (Clone Level v) and wait\nbroadcast (GameOn v)\n\nwhen I receive [reset v]\nset [double jump v] to [0]\nset [level v] to [1]\nset [in air? v] to [0]\nset [scroll x v] to [0]\nset [scroll y v] to [-50]\nset [camx v] to [0]\nset [camy v] to [25]\nset [speed v] to [6]\nset [% v] to []\n\ndefine Tick\nif <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(mouse x) > (x position)>>> then\n    change player x by (speed)\nend\nif <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(x position) > (mouse x)>>> then\n    change player x by (join [-] (speed))\nend\nchange [yv v] by (-2)\nchange player y by (Yv)\nposition\nchange [camx v] by (round (((Scroll X) - (CamX)) / (4)))\nchange [camy v] by (round (((Scroll Y) - (CamY)) / (4)))\nif <(CamX) < [125]> then\n    set [camx v] to [125]\nend\nif <(CamY) < [25]> then\n    set [camy v] to [25]\nend\nif <[100] < (CamY)> then\n    set [camy v] to [100]\nend\nif <(Scroll X) < [-105]> then\n    set [scroll x v] to [-105]\nend\nif <[1300] < (CamX)> then\n    set [camx v] to [1300]\nend\nif <touching (win v)?> then\n    set [% v] to [Win]\nend\nDie?\nposition\n\ndefine change player y by (sy)\nchange [scroll y v] by (sy)\nchange [in air? v] by (1)\nposition\nDie?\nrepeat until <not <touching (platform v)?>>\n    if <(sy) > [0]> then\n        change [scroll y v] by (-1)\n    else\n        change [scroll y v] by (1)\n        set [in air? v] to [0]\n        set [double jump v] to [0]\n    end\n    position\n    set [yv v] to [0]\nend\n\ndefine position\ngo to x: ((Scroll X) - (CamX)) y: ((Scroll Y) - (CamY))\n\ndefine change player x by (sx)\nchange [scroll x v] by (sx)\nposition\nDie?\nif <touching (platform v)?> then\n    repeat (15)\n        change [scroll y v] by (1)\n        position\n        if <not <touching (platform v)?>> then\n            stop [this script v]\n        end\n    end\n    change [scroll y v] by (-12)\n    repeat until <not <touching (platform v)?>>\n        if <(sx) > [0]> then\n            change [scroll x v] by (-1)\n        else\n            change [scroll x v] by (1)\n        end\n        position\n    end\nend\n\ndefine Die?\nif <<touching (_edge_ v)?> and <(Scroll Y) < [-150]>> then\n    set [% v] to [Die]\nend\nif <touching (die v)?> then\n    set [% v] to [Die]\nend\n\nwhen I receive [gameon v]\nset [double jump v] to [0]\nset [yv v] to [0]\nrepeat until <not <(%) = []>>\n    Tick\n    broadcast (Tick v) and wait\nend\nif <(%) = [Win]> then\n    wait (1) seconds\n    broadcast (Win v)\n    stop [other scripts in sprite v]\n    stop [this script v]\nelse\n    if <(%) = [Die]> then\n        Die\n    end\nend\n\ndefine Die\nset [% v] to []\nwait (1) seconds\nset [scroll x v] to [0]\nset [scroll y v] to [-50]\nrepeat until <<(round (CamX)) = [125]> and <(round (CamY)) = [25]>>\n    change [camx v] by (((125) - (CamX)) / (4))\n    change [camy v] by (((25) - (CamY)) / (4))\n    go to x: ((Scroll X) - (CamX)) y: ((Scroll Y) - (CamY))\nend\nbroadcast (GameOn v)\n\ndefine Jump\nforever\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>> then\n        if <<(in air?) < [4]> or <(double jump) = [1]>> then\n            set [yv v] to [15]\n            change [double jump v] by (1)\n            wait until <not <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>>>\n        end\n    end\n    if <touching (bouncy v)?> then\n        set [yv v] to [28]\n        set [double jump v] to [1]\n        wait (0.25) seconds\n        wait until <not <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>>>\n    end\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>> then\n        if <<not <(in air?) < [4]>> and <(double jump) = [0]>> then\n            set [yv v] to [15]\n            set [double jump v] to [2]\n        end\n    end\nend\n\nwhen I receive [gameon v]\nJump\n\n@Platform\n\ndefine levels\nhide\nif <(level) = [1]> then\n    clone level 1\nend\n\ndefine clone level 1\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (1-1 v)\ncreate clone of (_myself_ v)\nset [x v] to [500]\nset [y v] to [0]\nswitch costume to (1-2 v)\ncreate clone of (_myself_ v)\nset [x v] to [1000]\nset [y v] to [0]\nswitch costume to (1-3 v)\ncreate clone of (_myself_ v)\nset [x v] to [1500]\nset [y v] to [0]\nswitch costume to (1-4 v)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nforever\n    Go to X ((X) - (CamX)) Y ((Y) - (CamY))\nend\n\ndefine Go to X ( x) Y (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 [clone level v]\nlevels\n\n@Die\n\ndefine levels\nhide\nif <(level) = [1]> then\n    clone level 1\nend\n\ndefine clone level 1\ngo to [back v] layer\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (1-1 v)\ncreate clone of (_myself_ v)\nset [x v] to [500]\nset [y v] to [0]\nswitch costume to (1-2 v)\ncreate clone of (_myself_ v)\nset [x v] to [1000]\nset [y v] to [0]\nswitch costume to (1-3 v)\ncreate clone of (_myself_ v)\nset [x v] to [1500]\nset [y v] to [0]\nswitch costume to (1-4 v)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nforever\n    Go to X ((X) - (CamX)) Y ((Y) - (CamY))\nend\n\ndefine Go to X ( x) Y (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 [clone level v]\nlevels\n\n@text\n\ndefine levels\nhide\nif <(level) = [1]> then\n    clone level 1\nend\n\ndefine clone level 1\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (1-1 v)\ncreate clone of (_myself_ v)\nset [x v] to [500]\nset [y v] to [0]\nswitch costume to (1-2 v)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nforever\n    Go to X ((X) - (CamX)) Y ((Y) - (CamY))\nend\n\ndefine Go to X ( x) Y (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 [clone level v]\nlevels\n\n@Bouncy\n\ndefine levels\nhide\nif <(level) = [1]> then\n    clone level 1\nend\n\ndefine clone level 1\nset [x v] to [1000]\nset [y v] to [0]\nswitch costume to (1-3 v)\ncreate clone of (_myself_ v)\nset [x v] to [1500]\nset [y v] to [0]\nswitch costume to (1-4 v)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nforever\n    Go to X ((X) - (CamX)) Y ((Y) - (CamY))\nend\n\ndefine Go to X ( x) Y (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 [clone level v]\nlevels\n\n@Win\n\ndefine Go to X ( x) Y (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 [clone level v]\nset [x v] to [872]\nset [y v] to [261]\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nforever\n    Go to X ((X) - (CamX)) Y ((Y) - (CamY))\n    go to [back v] layer\nend\n\n@ \n\ndefine Glide to x: (x) y: (y) size: (size) speed: (speed) dir (dir)\nrepeat until <<<(round (x position)) = (x)> and <(round (y position)) = (y)>> and <<(round (size)) = (size)> and <(round (direction)) = (dir)>>>\n    change x by (((x) - (x position)) / (speed))\n    change y by (((y) - (y position)) / (speed))\n    turn right (((dir) - (direction)) / (speed)) degrees\n    change size by (((size) - (size)) / (speed))\n    go to [front v] layer\nend\ngo to x: (x) y: (y)\nset size to (size) %\npoint in direction (dir)\n\nwhen I receive [greenflag v]\nhide\n\nwhen I receive [win v]\nswitch costume to (costume2 v)\ncreate clone of (_myself_ v)\nswitch costume to (costume1 v)\nshow\ngo to x: (0) y: (180)\nGlide to x: [0] y: [0] size: [100] speed: [4] dir [90]\n\nwhen I start as a clone\nshow\nset [ghost v] effect to (100)\nrepeat (25)\n    change [ghost v] effect by (-3)\n    go to [front v] layer\n    go [backward v] (1) layers\nend\n\n@Thubnail\n\nwhen I receive [greenflag v]\nset [ghost v] effect to (100)\nshow\n\n