Circles - a scrolling platformer

Instructions: arrow keys to move. \nNew game: https://scratch.mit.edu/projects/401922322/\n\nLes flèches directionnelles pour bouger. \nNouveau jeu: https://scratch.mit.edu/projects/401922322/\n

@Stage\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@player\n\nwhen flag clicked\nhide variable [time v]\nhide variable [☁ world best v]\nhide\nbroadcast (show  v)\nwait (1) seconds\nshow\nbroadcast (Green flag clicked v)\nbroadcast (Play game v)\nforever\n    play sound [Marshmello - Imagine \(Official Music Video\) v] until done\nend\n\nwhen I receive [green flag clicked v]\nhide\ngo to [front v] layer\n\nwhen I receive [play game v]\nreset timer\nset [level v] to [1]\nforever\n    broadcast (reset v)\n    broadcast (setup v)\n    game on\n    repeat until <(EXIT) > []>\n        tick\n        broadcast (Tick v) and wait\n    end\n    if <(EXIT) = [win]> then\n        Game - win\n    else\n        Game - die\n    end\nend\n\ndefine game on\npoint in direction (90)\nset size to (80) %\nset [time v] to [0]\nset [exit v] to []\nset [sy v] to [0]\nset [xpos v] to [0]\nset [ypos v] to [0]\nset [in air? v] to [0]\nset [ghost v] effect to (0)\nshow\n\ndefine tick\nif <key (left arrow v) pressed?> then\n    change x by [-8]\nend\nif <key (right arrow v) pressed?> then\n    change x by [8]\nend\nif <key (up arrow v) pressed?> then\n    if <(in air?) < [4]> then\n        set [sy v] to [16]\n    end\nend\nchange [sy v] by (-2)\nchange y by (sy)\nset [scroll x v] to (xPos)\nposition\nif <(yPos) < [-180]> then\n    set [exit v] to [die]\nend\n\ndefine change y by (sy)\nchange [ypos v] by (sy)\nchange [in air? v] by (1)\nposition\nTest die\nrepeat until <not <<touching (platforms v)?> or <touching (moving platform v)?>>>\n    if <(sy) > [0]> then\n        change [ypos v] by (-1)\n    else\n        change [ypos v] by (1)\n        set [in air? v] to [0]\n    end\n    position\n    set [sy v] to [0]\nend\n\ndefine position\ngo to x: ((xPos) - (SCROLL X)) y: ((yPos) - (SCROLL Y))\n\ndefine change x by (sx)\nchange [xpos v] by (sx)\nposition\nif <<touching color (#1363bf)?> and <(COLLECTED) = (COLLECTED MAX)>> then\n    if <(time) = [0]> then\n        set [time v] to (timer)\n        show variable [☁ world best v]\n        show variable [time v]\n        if <(☁ world best) > (time)> then\n            set [☁ world best v] to (time)\n        end\n    end\nend\nTest die\nif <<touching (platforms v)?> or <touching (moving platform v)?>> then\n    repeat (12)\n        change [ypos v] by (1)\n        position\n    end\n    if <not <<touching (platforms v)?> or <touching (moving platform v)?>>> then\n        stop [this script v]\n    end\n    change [ypos v] by (-8)\n    repeat until <not <<touching (platforms v)?> or <touching (moving platform v)?>>>\n        if <(sx) > [0]> then\n            change [xpos v] by (-1)\n        else\n            change [xpos v] by (1)\n        end\n        position\n    end\nend\n\ndefine Game - die\nset [exit v] to []\nrepeat (3)\n    hide\n    wait (0.15) seconds\n    change [ghost v] effect by (25)\n    show\n    start sound [Zoop v]\n    wait (0.15) seconds\nend\nhide\nwait (0.4) seconds\n\ndefine Test die\nif <touching (spikes v)?> then\n    set [exit v] to [die]\nend\n\ndefine Game - win\nrepeat (50)\n    point towards (portal v)\n    turn right (65) degrees\n    move ((distance to [portal v]) / (2)) steps\n    change size by (-1)\n    change [ghost v] effect by (2)\nend\nhide\nchange [level v] by (1)\nwait (1) seconds\n\n@platforms\n\nwhen I receive [green flag clicked v]\nhide\n\nwhen I receive [tick v]\nposition ((xPos) - (SCROLL X)) ((yPos) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [xpos v] to [0]\nset [ypos v] to [0]\nif <(LEVEL) = [2]> then\n    switch costume to (costume2 v)\n    repeat (3)\n        Clone at x [475] y: [0]\n    end\nelse\n    if <(LEVEL) = [1]> then\n        switch costume to (costume5 v)\n        repeat (6)\n            Clone at x [475] y: [0]\n        end\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (costume8 v)\n            repeat (4)\n                Clone at x [475] y: [0]\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 [xpos v] by (x)\nchange [ypos v] by (y)\nnext costume\n\n@collectables\n\nwhen I receive [green flag clicked v]\nhide\n\nwhen I receive [tick v]\nposition ((xPos) - (SCROLL X)) ((yPos) - (SCROLL Y))\nif <touching (player v)?> then\n    change [collected v] by (1)\n    start sound [Collect v]\n    set [coins v] to (join (COLLECTED) (join [ / ] (COLLECTED MAX)))\n    if <(COLLECTED) = (COLLECTED MAX)> then\n        broadcast (Open portal v)\n    end\n    delete this clone\nend\n\nwhen I receive [setup v]\nset [collected v] to [0]\nset [collected max v] to [0]\nset [coins v] to [0]\nshow variable [coins v]\nhide\nset [xpos v] to [0]\nset [ypos v] to [0]\nif <(LEVEL) = [2]> then\n    switch costume to (costume1 v)\n    Clone at x [50] y: [35]\n    Clone at x [215] y: [40]\n    Clone at x [338] y: [42]\n    Clone at x [562] y: [138]\n    Clone at x [570] y: [-5]\n    Clone at x [920] y: [142]\n    Clone at x [783] y: [0]\nelse\n    if <(LEVEL) = [1]> then\n        Clone at x [42] y: [54]\n        Clone at x [135] y: [89]\n        Clone at x [217] y: [139]\n        Clone at x [508] y: [-20]\n        Clone at x [735] y: [83]\n    end\n    if <(LEVEL) = [3]> then\n        Clone at x [165] y: [105]\n        Clone at x [315] y: [150]\n        Clone at x [708] y: [50]\n        Clone at x [786] y: [140]\n        Clone at x [710] y: [-47]\n    end\nend\nset [xpos v] to [-99999]\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 [xpos v] to (x)\nset [ypos v] to (y)\nchange [collected max v] by (1)\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nhide variable [coins v]\n\n@portal\n\nwhen I receive [green flag clicked v]\nhide\n\nwhen I receive [tick v]\nposition ((xPos) - (SCROLL X)) ((yPos) - (SCROLL Y))\nif <<(costume [number v]) = [2]> and <touching (player v)?>> then\n    set [exit v] to [win]\nend\n\nwhen I receive [setup v]\nset [collected v] to [0]\nhide\nset [xpos v] to [0]\nset [ypos v] to [0]\nif <(LEVEL) = [2]> then\n    switch costume to (exit closed v)\n    Clone at x [1060] y: [42]\nelse\n    if <(LEVEL) = [1]> then\n        switch costume to (exit closed v)\n        Clone at x [960] y: [42]\n    else\n        if <(LEVEL) = [3]> then\n            Clone at x [-10000] y: [0]\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 [xpos v] to (x)\nset [ypos v] to (y)\n\nwhen I receive [open portal v]\nswitch costume to (exit open v)\n\n@spikes\n\nwhen I receive [green flag clicked v]\nhide\n\nwhen I receive [tick v]\nposition ((xPos) - (SCROLL X)) ((yPos) - (SCROLL Y))\n\nwhen I receive [setup v]\npoint in direction (90)\ngo to [back v] layer\nhide\nset [ypos v] to [0]\nset [xpos v] to [0]\nif <(LEVEL) = [2]> then\n    switch costume to (costume2 v)\n    repeat until <(LEVEL) = [3]>\n        Clone at x [161] y: [-12]\n        Clone at x [285] y: [-8]\n        Clone at x [390] y: [-10]\n        wait (1) seconds\n        broadcast (delete clones v)\n        Clone at x [161] y: [40]\n        Clone at x [285] y: [44]\n        Clone at x [390] y: [39]\n        wait (1) seconds\n        broadcast (delete clones v)\n    end\n    broadcast (delete clones v)\nelse\n    if <(LEVEL) = [1]> then\n        repeat until <(LEVEL) = [2]>\n            Clone at x [42] y: [-105]\n            Clone at x [142] y: [-90]\n            wait (1) seconds\n            broadcast (delete clones v)\n            Clone at x [42] y: [-56]\n            Clone at x [142] y: [-41]\n            wait (1) seconds\n            broadcast (delete clones v)\n        end\n    else\n        if <(LEVEL) = [3]> then\n            repeat until <(LEVEL) = [4]>\n                Clone at x [182] y: [-48]\n                Clone at x [152] y: [-48]\n                Clone at x [335] y: [-15]\n                Clone at x [305] y: [-15]\n                Clone at x [875] y: [-199]\n                Clone at x [985] y: [-199]\n                wait (1) seconds\n                broadcast (delete clones v)\n                Clone at x [182] y: [-1]\n                Clone at x [152] y: [-1]\n                Clone at x [305] y: [34]\n                Clone at x [335] y: [34]\n                Clone at x [875] y: [-155]\n                Clone at x [985] y: [-155]\n                wait (1) seconds\n                broadcast (delete clones v)\n            end\n        end\n    end\nend\n\nswitch costume to (costume2 v)\nClone at x [161] y: [38]\nwait (1) seconds\nswitch costume to (costume1 v)\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 [xpos v] to (x)\nset [ypos v] to (y)\ncreate clone of (_myself_ v)\n\nnext costume\n\nhide\n\nnext costume\nset [xpos v] to [-99999]\nwait (1) seconds\n\nwhen I receive [delete clones v]\ndelete this clone\n\n@Sprite1\n\nwhen I receive [show  v]\nshow\nwait (1) seconds\nhide\n\n