Scratch cat stretchy platformer engine

Instructions: CLICK FLAG 2 TIMES\nREAD ALL THE INSTRUCTIONS BEOFRE ASKING\nWelcome to Adventure,a scrolling platformer.\nYou are in the wild on a epic adventure,but you are lost,can you find your way back?\ncontrols:arrow keys,wasd,or mobile to move.\nCollect all the orbs and get to the portal to win.\n(the portal will lighten up if you collected all the orbs,if you have not it will be dark and going through it will not bring you to the next level)

@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\nwhen [h v] key pressed\nhide variable [mouse v]\n\nwhen flag clicked\nhide variable [mouse v]\nforever\n    play sound [Theory of Everything 2 v] until done\nend\n\n@Blank\n\n@PLAYER\n\nwhen flag clicked\nbroadcast (Green Flag v) and wait\nbroadcast (Begin Game v) and wait\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\n\nwhen I receive [begin game 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    end\n    if <(EXIT) = [Win]> then\n        Game Win\n    else\n        Game Die\n    end\nend\n\ndefine Game On\nif <(LEVEL) = [5]> then\n    hide\nelse\n    set rotation style [left-right v]\n    set [x v] to [0]\n    set [y v] to [100]\n    set [scroll x v] to [0]\n    set [yvel v] to [0]\n    set [in air v] to [0]\n    set [exit v] to []\n    set [collected max v] to [0]\n    set [ghost v] effect to (0)\n    set size to (60) %\n    show\n    set rotation style [left-right v]\n    point in direction (90)\nend\n\ndefine Tick\nif <key (left arrow v) pressed?> then\n    change [xvel v] by (-2)\n    point in direction (-90)\nend\nif <key (right arrow v) pressed?> then\n    change [xvel v] by (2)\n    point in direction (90)\nend\nset [xvel v] to ((xvel) * (0.8))\nif <([abs v] of (xvel) ) > [0.9]> then\n    Change Player X by (round (xvel))\nend\nif <key (up arrow v) pressed?> then\n    if <(In Air) < [4]> then\n        set [yvel v] to [16]\n    end\nend\nif <(yvel) > [-20]> then\n    change [yvel v] by (-2)\nend\nChange Player Y by (yvel)\nPosition\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 (platform 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 [yvel v] to [0]\nend\n\ndefine Position\ngo to x: ((X) - (SCROLL X)) y: ((Y) - (SCROLL Y))\n\ndefine Change Player X by (sx)\nchange [x v] by (sx)\nPosition\nif <touching (platform v)?> then\n    repeat (12)\n        change [y v] by (1)\n        if <not <touching (platform v)?>> then\n            stop [this script v]\n        end\n    end\n    if <key (up arrow v) pressed?> then\n        if <(sx) > [0]> then\n            set [xvel v] to [-16]\n        else\n            set [xvel v] to [16]\n        end\n        set [in air v] to [0]\n    else\n        set [xvel v] to [0]\n    end\n    change [y v] by (-12)\n    repeat until <not <touching (platform 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 (-1)\n    change [ghost v] effect by (2)\nend\nchange [level v] by (1)\nwait (1) seconds\nhide\n\n@PLATFORM\n\nwhen I receive [green flag 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]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1 1 v)\n    Clone at X: [420] Y: [0]\n    Clone at X: [420] Y: [0]\n    Clone at X: [420] Y: [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2 1 v)\n        Clone at X: [0] Y: [240]\n        Clone at X: [0] Y: [360]\n        Clone at X: [420] Y: [0]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (level 3 1 v)\n            Clone at X: [480] Y: [0]\n            Clone at X: [480] Y: [0]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (level 4  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: [0]\n            else\n                switch costume to (level 5 1 v)\n                wait (1) seconds\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\nwhen I start as a clone\ngo to [front v] layer\n\nwhen flag clicked\ngo to [front v] layer\n\n@COLLECTABLES\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((X) - (SCROLL X)) ((Y) - (SCROLL Y))\nif <touching (player v)?> then\n    change [collected v] by (1)\n    delete this clone\nend\n\nwhen I receive [setup v]\nhide\nset [collected v] to [0]\nset [collected maximum v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (coin v)\n    Clone at X: [142] Y: [-13]\n    Clone at X: [410] Y: [109]\n    Clone at X: [802] Y: [48]\n    Clone at X: [1167] Y: [169]\n    Clone at X: [1310] Y: [172]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (coin v)\n        Clone at X: [-190] Y: [-10]\n        Clone at X: [-187] Y: [242]\n        Clone at X: [221] Y: [325]\n        Clone at X: [-219] Y: [634]\n        Clone at X: [607] Y: [641]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (coin v)\n            Clone at X: [280] Y: [27]\n            Clone at X: [374] Y: [-76]\n            Clone at X: [451] Y: [105]\n            Clone at X: [554] Y: [40]\n            Clone at X: [648] Y: [-46]\n            Clone at X: [787] Y: [-49]\n            Clone at X: [374] Y: [-76]\n            Clone at X: [863] Y: [9]\n            Clone at X: [927] Y: [100]\n            Clone at X: [1015] Y: [10]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (coin v)\n                Clone at X: [50] Y: [153]\n                Clone at X: [139] Y: [38]\n                Clone at X: [425] Y: [29]\n                Clone at X: [528] Y: [-8]\n                Clone at X: [768] Y: [-5]\n                Clone at X: [940] Y: [43]\n                Clone at X: [1109] Y: [-8]\n                Clone at X: [1379] Y: [4]\n                Clone at X: [1650] Y: [-3]\n                Clone at X: [2214] Y: [-49]\n                Clone at X: [398] Y: [455]\n            end\n        end\n    end\nend\nset [x v] to [-9999999999999999999999999999999999999999]\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)\nchange [collected maximum v] by (1)\ncreate clone of (_myself_ v)\n\n@DANGER\n\nwhen I receive [green flag 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]\nif <(username) = [SGChase18]> then\n    switch costume to (nothing v)\nelse\n    if <(LEVEL) = [1]> then\n        switch costume to (level 1 1 v)\n        Clone at X: [420] Y: [0]\n        Clone at X: [420] Y: [0]\n        Clone at X: [420] Y: [0]\n    else\n        if <(LEVEL) = [2]> then\n            switch costume to (level 2 1 v)\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (level 4 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: [0]\n            else\n                switch costume to (nothing v)\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\n@EXIT\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((X) - (SCROLL X)) ((Y) - (SCROLL Y))\nif <(COLLECTED) = (COLLECTED MAXIMUM)> then\n    broadcast (OPEN PORTAL v)\nend\nif <touching (player v)?> then\n    if <(costume [number v]) = [2]> then\n        set [exit v] to [Win]\n    end\nend\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (closed v)\n    Clone at X: [1567] Y: [253]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (closed v)\n        Clone at X: [747] Y: [733]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (closed v)\n            Clone at X: [1200] Y: [170]\n        else\n            switch costume to (closed v)\n            Clone at X: [2020] Y: [79]\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 I receive [open portal v]\nswitch costume to (open v)\n\n@TN\n\nwhen flag clicked\nset [ghost v] effect to (100)\nforever\n    go to [front v] layer\nend\n\n@DECOR\n\nwhen I receive [green flag 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]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1 1 v)\n    Clone at X: [420] Y: [0]\n    Clone at X: [420] Y: [0]\n    Clone at X: [420] Y: [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2 1 v)\n        Clone at X: [0] Y: [240]\n        Clone at X: [0] Y: [360]\n        Clone at X: [420] Y: [0]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (level 3 1 v)\n            Clone at X: [480] Y: [0]\n            Clone at X: [480] Y: [0]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (level 4  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: [0]\n            else\n                switch costume to (level 5 1 v)\n                wait (1) seconds\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\n