Procedurally generated Scrolling Platformer Engine

Instructions: This is a scratch remake of Sam Hogan's game 'where's bill' as a remixable engine!\n\n\nEvery time you click the green flag it renders a whole different and Randomly Generated Level!\n\nI've also animated this little Robot figure that reacts to motion :D\n\nThis is lacking in art, so maybe we could work on that? idk\n\n*Fullscreen Recommended*\n\n\nUpdates:\n\n- Added Completion screen\n- Added Highscore and Highscore holder\n- 500 views?! TYSM!!

@Stage\n\nwhen [m v] key pressed\nset [mouse v] to (join ((mouse x) + (SCROLLX)) (join [, ] ((mouse y) + (SCROLLY))))\n\n@platforms\n\nwhen I receive [green flag v]\ngo to [back v] layer\nshow\nset [x v] to [0]\nset [y v] to [0]\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLLX)) ((y) - (SCROLLY))\n\nwhen I receive [setup v]\nset [x v] to [0]\nset [y v] to [20]\nswitch costume to (dirt1 v)\nRender Platforms\nreset timer\n\nwhen I receive [dead 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 Render Platforms\ncreate clone of (_myself_ v)\nrepeat (30)\n    repeat (pick random (1) to (6))\n        change [x v] by (52)\n        switch costume to (pick random (1) to (3))\n        create clone of (_myself_ v)\n    end\n    change [x v] by (pick random (50) to (110))\n    if <(y) < [5]> then\n        change [y v] by (pick random (10) to (70))\n    else\n        change [y v] by (pick random (-50) to (70))\n    end\nend\nswitch costume to (end v)\n\nwhen flag clicked\ndelete this clone\n\n@player code\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [play game v]\nset [level v] to [1]\nbroadcast (reset v) and wait\nbroadcast (Setup v) and wait\nGame on\nrepeat until <(EXIT) > []>\n    tick\n    broadcast (tick v) and wait\nend\nif <(EXIT) = [win]> then\n    Game Win\nelse\n    Game - Die\nend\n\nforever\nend\n\ndefine Game on\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 []\npoint in direction (90)\nset size to (100) %\nshow\n\ndefine tick\nbroadcast (H v)\nif <<key (left arrow v) pressed?> or <<mouse down?> and <(mouse x) < (x position)>>> then\n    point in direction (-90)\n    Change player x by [-6]\nend\nif <<key (right arrow v) pressed?> or <<mouse down?> and <(mouse x) > (x position)>>> then\n    point in direction (90)\n    Change player x by [6]\nend\nif <<key (up arrow v) pressed?> or <<mouse down?> and <(mouse y) > ((y position) + (10))>>> then\n    if <(in air) < [4]> then\n        set [sy v] to [12]\n    end\nend\nChange player y by (sy)\nchange [sy v] by (-2)\nset [scrollx v] to (x)\nif <(SCROLLX) < [0]> then\n    set [scrollx v] to [0]\nend\nchange [scrolly v] by (round (((y) - (SCROLLY)) / (10)))\nif <(SCROLLY) < [0]> then\n    set [scrolly v] to [0]\nend\nposition\nif <(y) < [-180]> then\n    set [exit v] to [die]\nend\nbroadcast (S v)\n\ndefine Change player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nposition\nTest - Die\nrepeat until <not <<touching color (#009121)?> or <touching color (#b16918)?>>>\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 position\ngo to x: ((x) - (SCROLLX)) y: ((y) - (SCROLLY))\n\ndefine Change player x by (sx)\nchange [x v] by (sx)\nposition\nTest - Die\nif <<touching color (#009121)?> or <touching color (#b16918)?>> then\n    repeat (12)\n        position\n        change [y v] by (1)\n        if <not <<touching color (#009121)?> or <touching color (#b16918)?>>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    repeat until <not <<touching color (#009121)?> or <touching color (#b16918)?>>>\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\nwhen flag clicked\nset [ghost v] effect to (100)\nset rotation style [left-right v]\nbroadcast (green flag v) and wait\nbroadcast (play game v) and wait\n\nwhen I receive [stop loading v]\ngo to [front v] layer\n\nwhen I receive [dead v]\n\ndefine Game - Die\nset [exit v] to []\nbroadcast (play game v)\nhide\n\nwait (0.5) seconds\n\nhide\nwait (0.1) seconds\nshow\nwait (0.1) seconds\n\ndefine Test - Die\nbroadcast (H v)\nif <touching color (#fdb826)?> then\n    set [exit v] to [win]\nend\nbroadcast (S v)\n\nif <touching color (#383838)?> then\nend\n\nshow\n\nchange [y v] by (60)\n\nwhen I receive [tick v]\nset [ghost v] effect to (100)\n\nset [scrolly v] to [100]\n\ndefine Game Win\nbroadcast (Game win v)\n\nbroadcast (Game win v)\n\nwait until <(time) = [1]>\n\n@Robot\n\nwhen I receive [tick v]\ngo to (player code v)\nchange y by (-21)\nif <<key (right arrow v) pressed?> or <<mouse down?> and <(mouse x) > (x position)>>> then\n    switch costume to (a v)\n    turn right (((80) - (direction)) / (20)) degrees\nelse\n    if <<key (left arrow v) pressed?> or <<mouse down?> and <(mouse x) < (x position)>>> then\n        turn right (((100) - (direction)) / (20)) degrees\n    else\n        turn right (((90) - (direction)) / (5)) degrees\n    end\nend\n\nwhen flag clicked\nshow\nclear graphic effects\npoint in direction (90)\nswitch costume to (a v)\n\n@Sprite1\n\nwhen flag clicked\nhide\n\nshow\n\n@End 1\n\nwhen flag clicked\nhide\n\nwhen I receive [game win v]\ngo to x: (0) y: (-64)\nshow\nset [time v] to (round (timer))\nif <(☁ Cloud Highscore) > (time)> then\n    broadcast (New Highscore v)\n    switch costume to (costume2 v)\n    set [☁ cloud highscore v] to (time)\nelse\n    switch costume to (costume1 v)\nend\nset [ghost v] effect to (100)\nset [ghost v] to [100]\nrepeat until <(round (y position)) = [0]>\n    change y by (((0) - (y position)) / (20))\n    change [ghost v] effect by (((0) - (ghost)) / (20))\n    change [ghost v] by (((0) - (ghost)) / (20))\nend\n\nreset timer\n\n@Sprite2\n\nwhen flag clicked\nhide\n\nwhen I receive [game win v]\nwait (1) seconds\nshow\n\n@Sprite3\n\nwhen I receive [game win v]\nwait (1) seconds\ngo to x: (-43) y: (-17)\nset [number v] to [1]\nshow\nrepeat (length of (time))\n    switch costume to ((letter (number) of (time)) + (1))\n    create clone of (_myself_ v)\n    change x by (20)\n    change [number v] by (1)\nend\nhide\ngo to x: (74) y: (-106)\nshow\nset [number v] to [1]\nrepeat (length of (☁ Cloud Highscore))\n    switch costume to ((letter (number) of (☁ Cloud Highscore)) + (1))\n    create clone of (_myself_ v)\n    change x by (20)\n    change [number v] by (1)\nend\nhide\n\n@Sprite4\n\nwhen I receive [game win v]\nrepeat (20)\n    change [ghost v] effect by (-5)\nend\n\nwhen flag clicked\nset [ghost v] effect to (100)\n\n@Sprite5\n\ndefine write (val) encoded\nset [letter # v] to [1]\nrepeat (length of (val))\n    set [encoded v] to (join (encoded) (item # of (letter (letter #) of (val)) in [code v]))\n    change [letter # v] by (1)\nend\nset [encoded v] to (join (encoded) [00])\n\ndefine Begin decode of (val)\nset [encoded v] to (val)\nset [letter # v] to [1]\n\ndefine value = read from encoded\nset [encoded v] to [0]\nforever\n    set [idx v] to (join (letter (letter #) of (encoded)) (letter ((letter #) + (1)) of (encoded)))\n    change [letter # v] by (2)\n    if <(idx) < [1]> then\n        stop [this script v]\n    end\n    set [value v] to (join (value) (item (idx) of [code v]))\nend\n\nvalue = read from encoded\n\nwhen I receive [new highscore v]\nwrite (username) encoded\nset [☁ highscore holder v] to (encoded)\n\nwhen flag clicked\n\nwhen flag clicked\nBegin decode of (☁ Highscore Holder)\n\n