-- Clouds -- a scrolling platformer 

Instructions: EN: arrow keys to move. R to restart a level\nRECOMMANDED: play in full screen\nThe blue trampolins make you jump higher.\nNew game: https://scratch.mit.edu/projects/404808615/\nFR: Les flèches directionnelles pour bouger. R pour recommençer un niveau.\nLes trampolines bleus vous font sauter plus haut.\nNouveau jeu:  https://scratch.mit.edu/projects/404808615/

@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 [_-_In_The_Clouds_-_David_Fesliyan v] until done\nend\n\nwhen I receive [green flag clicked v]\nhide\ngo to [front v] layer\nset [time v] to [0]\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    set size to (80) %\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 [exit v] to []\nset [sy v] to [0]\nset [xpos v] to [0]\nset [ypos v] to [-70]\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?> and <not <touching color (#000dfe)?>>> then\n    if <(in air?) < [4]> then\n        set [sy v] to [16]\n    end\nend\nif <touching color (#0000ff)?> then\n    broadcast (trampolins v)\n    set [sy v] to [32]\nend\nif <(sy) > [-24]> then\n    change [sy v] by (-2)\nend\nchange y by (sy)\nif <<(SCROLL X) > [779]> and <(LEVEL) = [2]>> then\n    set size to (50) %\nelse\n    if <<<[-200] > (SCROLL X)> and <(SCROLL Y) > [720]>> or <(SCROLL X) < [-505]>> then\n        set size to (150) %\n    else\n        set size to (80) %\n    end\nend\nset [scroll x v] to (xPos)\nif <(LEVEL) < [3]> then\n    if <(SCROLL X) < [-100]> then\n        set [scroll x v] to [-100]\n    end\nelse\n    if <[200] < (SCROLL X)> then\n        set [scroll x v] to [200]\n    end\nend\nchange [scroll y v] by (round (((yPos) - (SCROLL Y)) / (10)))\nif <(SCROLL Y) < [0]> then\n    set [scroll y v] to [0]\nend\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)?>>\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 <<<(SCROLL X) < [-1426]> and <(SCROLL Y) < [140]>> 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        stop [all v]\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 color (#ff0000)?> or <key (r v) pressed?>> 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) = [1]> then\n    switch costume to (costume13 v)\n    repeat (5)\n        Clone at x [475] y: [0]\n    end\n    set [xpos v] to [1400]\n    set [ypos v] to [475]\n    Clone at x [300] y: [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (costume9 v)\n        set [xpos v] to [0]\n        set [ypos v] to [0]\n        repeat (3)\n            Clone at x [475] y: [0]\n        end\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (costume6 v)\n            set [xpos v] to [0]\n            set [ypos v] to [0]\n            repeat (2)\n                Clone at x [0] y: [475]\n            end\n            change [ypos v] by (-250)\n            repeat (4)\n                Clone at x [-475] y: [0]\n            end\n            set [ypos v] to [0]\n            change [xpos v] by (150)\n            Clone at x [150] y: [0]\n        end\n    end\nend\nset [ypos v] to [9999]\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 size to (100) %\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) = [1]> then\n    Clone at x [146] y: [0]\n    Clone at x [-20] y: [90]\n    Clone at x [127] y: [164]\n    Clone at x [432] y: [72]\n    Clone at x [790] y: [80]\n    Clone at x [1225] y: [-26]\n    Clone at x [1269] y: [101]\n    Clone at x [1613] y: [253]\nelse\n    if <(LEVEL) = [2]> then\n        Clone at x [136] y: [50]\n        Clone at x [-30] y: [90]\n        set size to (50) %\n        Clone at x [810] y: [-70]\n        Clone at x [1078] y: [-59]\n        Clone at x [1095] y: [102]\n        Clone at x [959] y: [133]\n        Clone at x [878] y: [175]\n        Clone at x [995] y: [216]\n    end\n    if <(LEVEL) = [3]> then\n        Clone at x [-21] y: [130]\n        Clone at x [-172] y: [675]\n        set size to (150) %\n        Clone at x [-547] y: [875]\n        Clone at x [-547] y: [1005]\n        Clone at x [-1288] y: [735]\n        Clone at x [-1288] y: [830]\n        Clone at x [-1288] y: [925]\n    end\nend\nset [xpos v] to [-99999]\n\nswitch costume to (costume1 v)\n\nClone at x [50] y: [35]\nClone at x [215] y: [40]\nClone at x [338] y: [42]\nClone at x [562] y: [138]\nClone at x [570] y: [-5]\nClone at x [920] y: [142]\n\nif <(LEVEL) = [3]> then\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@spikes\n\nwhen I receive [green flag clicked v]\nhide\n\nwhen I receive [tick v]\n\nposition ((xPos) - (SCROLL X)) ((yPos) - (SCROLL Y))\n\nwhen I receive [setup v]\n\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)\n\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\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@BOUNCIES\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\nswitch costume to (costume2 v)\nset size to (100) %\nif <(LEVEL) = [1]> then\n    Clone at x [1715] y: [59]\n    Clone at x [1630] y: [59]\nelse\n    if <(LEVEL) = [3]> then\n        Clone at x [33] y: [-50]\n        Clone at x [129] y: [165]\n        Clone at x [-58] y: [390]\n        set size to (150) %\n        Clone at x [-1285] y: [585]\n    end\nend\nset [xpos v] to [-9999]\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\nwhen I start as a clone\nforever\n    if <touching (player v)?> then\n        switch costume to (costume3 v)\n        wait (0.5) seconds\n        switch costume to (costume2 v)\n    end\nend\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 [981] y: [432]\nelse\n    if <(LEVEL) = [1]> then\n        switch costume to (exit closed v)\n        Clone at x [1372] y: [612]\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