Blocks! Random (Platformer)

Instructions: arrow keys or WASD\nAll Levels are random.\nSpace to generate a new Level.\nP to place a Block.\nC to hide "Level" and "WorldBest"\nDon't press 9! I'm sorry if you did but I told you.\nDon't touch the lava!\n\nThis Platformer never ends!\n\n--Credits--\nThe Platformer-Player-Engine is made by @Benelem12\nThe Music was made by Nintendo.\nEverything else was made by @Benni2007\n\nPlay Blocks! (a Platformer)\nhttps://scratch.mit.edu/projects/401760494/\nand Blocks! 2 (a Platformer)\nhttps://scratch.mit.edu/projects/402626274

@Stage\n\nwhen flag clicked\nforever\n    play sound [Wii Shop Channel v] until done\nend\n\n@Sprite1\n\nwhen flag clicked\nset [level v] to [0]\nset [level v] to [0]\nhide\ngenerrate\n\nset [level type v] to (pick random (1) to (2))\nif <(Level type) = [1]> then\nend\n\nset [y v] to [0]\n\ndefine generrate\nhide\nset [color v] effect to (0)\nerase all\ngo to x: (-210) y: (-150)\nstamp\nset [y v] to [0]\nset [number v] to (pick random (1) to (2))\nif <(number) = [1]> then\n    repeat (8)\n        change x by (64)\n        if <(pick random (1) to (2)) = [1]> then\n            if <(y position) < [130]> then\n                if <(x position) < [240]> then\n                    if <(pick random (1) to (15)) = [1]> then\n                        set [color v] effect to (155)\n                    else\n                        set [color v] effect to (0)\n                    end\n                    stamp\n                end\n            end\n        end\n    end\nelse\n    if <(number) = [2]> then\n        repeat (7)\n            set [old y v] to (y)\n            change x by (64)\n            if <(pick random (1) to (3)) = [1]> then\n                change y by (64)\n                change [y v] by (1)\n            end\n            set [color v] effect to (0)\n            repeat (y)\n                change y by (-64)\n                if <(y position) < [130]> then\n                    if <(x position) < [240]> then\n                        stamp\n                    end\n                end\n            end\n            repeat (y)\n                change y by (64)\n            end\n            if <(pick random (1) to (2)) = [1]> then\n                if <(y position) < [130]> then\n                    if <(x position) < [240]> then\n                        if <(pick random (1) to (3)) = [1]> then\n                            if <<(old y) = (y)> or <(y) < ((old y) - (1))>> then\n                                set [color v] effect to (155)\n                            end\n                        else\n                            set [color v] effect to (0)\n                        end\n                        stamp\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [level up! v]\ngenerrate\n\nwhen [space v] key pressed\nbroadcast (New Level v)\n\nset [y v] to [0]\n\nwhen I receive [new level v]\ngenerrate\n\nwhen [p v] key pressed\nbroadcast (Place Block v)\n\nwhen I receive [place block v]\nset [color v] effect to (0)\nshow\nrepeat until <mouse down?>\n    go to (mouse-pointer v)\nend\n\nwait (2) seconds\n\nif <(y position) < [130]> then\nend\n\nif <(x position) < [240]> then\n    stamp\nend\n\n@Made by Benelem12\n\ndefine Platformer physics\nchange [yv v] by (-1)\nif <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(x position) > (mouse x)>>> then\n    change [xv v] by (-1)\nend\nif <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(mouse x) > (x position)>>> then\n    change [xv v] by (1)\nend\nset [xv v] to ((Xv) * (0.9))\nchange x by (Xv)\nif <<<touching color (#7fff54)?> or <touching color (#71d948)?>> or <touching (moving platforms v)?>> then\n    change y by (1)\nend\nif <<<touching color (#7fff54)?> or <touching color (#71d948)?>> or <touching (moving platforms v)?>> then\n    change y by (1)\nend\nif <<<touching color (#7fff54)?> or <touching color (#71d948)?>> or <touching (moving platforms v)?>> then\n    change y by (1)\nend\nif <<<touching color (#7fff54)?> or <touching color (#71d948)?>> or <touching (moving platforms v)?>> then\n    change y by (1)\nend\nif <<<touching color (#7fff54)?> or <touching color (#71d948)?>> or <touching (moving platforms v)?>> then\n    change y by (-4)\n    change x by ((Xv) * (-1))\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > ((y position) + (20))>>> then\n        set [yv v] to [15]\n        if <(Xv) > [0]> then\n            set [xv v] to [-10]\n        else\n            set [xv v] to [10]\n        end\n    end\nend\nchange y by (Yv)\nif <<<touching color (#7fff54)?> or <touching color (#71d948)?>> or <touching (moving platforms v)?>> then\n    change y by ((Yv) * (-1))\n    set [yv v] to [0]\nend\nchange y by (-1)\nif <<<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > ((y position) + (20))>>> and <<<touching color (#7fff54)?> or <touching color (#71d948)?>> or <touching (moving platforms v)?>>> then\n    set [yv v] to [15]\n    broadcast (enemy_killed v)\nend\nchange y by (1)\nif <<touching (spikes v)?> or <touching (another_danger v)?>> then\n    if <not <(LEVEL) = [10]>> then\n        broadcast (oof v)\n        go to x: (-180) y: (0)\n        set [xv v] to [0]\n        set [yv v] to [0]\n    else\n        if <[-3] > (Yv)> then\n            broadcast (enemy_killed v)\n            wait (0.2) seconds\n        else\n            broadcast (oof v)\n            go to x: (-180) y: (0)\n            set [xv v] to [0]\n            set [yv v] to [0]\n        end\n    end\nend\nif <(y position) < [-180]> then\n    go to x: (-180) y: (0)\n    set [xv v] to [0]\n    set [yv v] to [0]\nend\nif <(x position) > [220]> then\n    broadcast (LEVEL UP! v)\n    change [level v] by (1)\n    change [level v] by (1)\n    hide\n    go to x: (-180) y: (0)\n    show\nend\nif <touching (trampolins v)?> then\n    set [yv v] to [25]\nend\nif <<touching color (#ff9854)?> or <touching color (#d97d48)?>> then\n    go to x: (-180) y: (0)\nend\nif <touching (boss v)?> then\n    go to x: (-180) y: (-50)\nend\n\nwait (0.25) seconds\n\nwhen flag clicked\nset [level v] to [4]\ngo to x: (107) y: (-83)\nswitch costume to (costume1 v)\nforever\n    if <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(mouse x) > (x position)>>> then\n        point in direction (90)\n    end\n    if <<key (left arrow v) pressed?> or <<key (a v) pressed?> or <<mouse down?> and <(x position) > (mouse x)>>>> then\n        point in direction (-90)\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nshow\nset [level v] to [1]\ngo to x: (-180) y: (0)\nforever\n    Platformer physics\nend\n\nwhen flag clicked\nforever\n    set rotation style [left-right v]\n    switch costume to (yellow v)\nend\n\npoint towards (mouse-pointer v)\n\npoint in direction (90)\n\nwhen flag clicked\nset size to (75) %\n\nwhen I receive [enemy_killed v]\n\nif <(s) = [0]> then\n    play sound [yahoo v] until done\nend\n\nwhen flag clicked\nbroadcast (start v)\nsay (join (join [Hi ] (username)) [! All Levels are random. You can go to the end of the Level or Press Space to generate a new Level! You can Press "P" to place a Block! ]) for (10) seconds\n\nwhen I receive [new level v]\ngo to x: (-180) y: (0)\n\nwhen flag clicked\nshow variable [level v]\nshow variable [☁ worldbest v]\nforever\n    if <<(Level) > (☁ WorldBest)> and <not <<(username) = [Benni2007]> or <(username) = [Benni2007_test]>>>> then\n        set [☁ worldbest v] to (Level)\n    end\nend\n\nwhen [c v] key pressed\nhide variable [level v]\nhide variable [☁ worldbest v]\n\n@Cloud\n\nwhen flag clicked\nforever\n    set [ghost v] effect to (25)\n    go to x: (240) y: (130)\n    show\n    glide (5) secs to x: (-240) y: (130)\n    hide\n    wait (pick random (5) to (15)) seconds\nend\n\n@Sprite2\n\nwhen flag clicked\nhide\n\ngo to x: (0) y: (0)\nshow\ngo to [front v] layer\n\nwhen flag clicked\n\nwhen flag clicked\nhide\n\nwhen [9 v] key pressed\nshow\ngo to [front v] layer\ngo to x: (0) y: (0)\n\n