Infinite Pen Platformer

Instructions: Infinite Pen Platformer\n\n▶ There are infinite pen-generated levels\n▶ Sorry if you come across an impossible level - Space to skip\n▶ TheFatRat for music\n▶ See how many you can get past - Post your score in the comments!\n▶ Follow @-Invert- for more awesome content!

@Stage\n\n@Thumbnail\n\nwhen flag clicked\nhide\n\n@Text engine\n\nwhen flag clicked\nwait (.001) seconds\nset [number v] to [1]\nrepeat (30)\n    create clone of (_myself_ v)\n    change [number v] by (1)\nend\nhide\nhide\n\nwhen I start as a clone\nshow\nforever\n    go to [front v] layer\n    set size to (200) %\n    go to x: (((Number) * (30)) - (42)) y: (120)\n    if <(length of (Level)) < (Number)> then\n        hide\n    else\n        show\n        switch costume to (letter (Number) of (Level))\n    end\nend\n\n@Player\n\nwhen flag clicked\ngo to x: (-220) y: (0)\nshow\nset [level v] to [1]\nset [x velocity v] to [0]\nset [y velocity v] to [0]\nforever\n    go to [front v] layer\n    show\n    change [y velocity v] by (-1)\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        switch costume to (left v)\n        change [x velocity v] by (-1)\n    end\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        switch costume to (right v)\n        change [x velocity v] by (1)\n    end\n    set [x velocity v] to ((X Velocity) * (0.9))\n    change x by (X Velocity)\n    if <touching color (#000000)?> then\n        change y by (5)\n    end\n    if <touching color (#000000)?> then\n        change y by (-4)\n        change x by ((X Velocity) * (-1))\n        if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n            set [y velocity v] to [9]\n            if <([abs v] of (X Velocity) ) = (X Velocity)> then\n                set [x velocity v] to [-7]\n            else\n                set [x velocity v] to [7]\n            end\n        else\n            set [x velocity v] to [0]\n        end\n    end\n    change y by (Y Velocity)\n    if <touching color (#000000)?> then\n        change y by ((Y Velocity) - ((Y Velocity) * (2)))\n        set [y velocity v] to [0]\n    end\n    change y by (-1)\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> and <touching color (#000000)?>> then\n        set [y velocity v] to [13]\n    end\n    change y by (1)\n    if <<(x position) = [240]> or <(x position) > [235]>> then\n        go to x: (-220) y: (0)\n        change [level v] by (1)\n        broadcast (Generate Level v)\n    end\n    if <<(y position) < [-175]> or <touching color (#ff0000)?>> then\n        go to x: (-220) y: (0)\n    end\nend\n\nwhen [space v] key pressed\ngo to x: (-220) y: (0)\n\n@Pen Level Generator\n\nwhen flag clicked\ndelete all of [black v]\ndelete all of [red v]\ndelete all of [y pos v]\nshow list [red v]\nshow list [y pos v]\nshow list [generator v]\nshow list [black v]\nset [die v] to [4]\nset [none v] to [7]\nhide variable [die v]\nhide variable [none v]\nerase all\nbroadcast (Generate Level v)\n\ndefine Render Ground\ngo to x: (-240) y: (item (1) of [y pos v])\nRender Stack (B)\nif <not <(item (1) of [generator v]) = [1]>> then\n    set y to (item (2) of [y pos v])\nelse\n    set y to (item (1) of [y pos v])\nend\nchange x by (30)\nRender Stack (B)\nif <not <(item (2) of [generator v]) = [1]>> then\n    set y to (item (3) of [y pos v])\nelse\n    set y to (item (2) of [y pos v])\nend\nchange x by (30)\nif <(item (1) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (1) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\nif <not <(item (3) of [generator v]) = [1]>> then\n    set y to (item (4) of [y pos v])\nelse\n    set y to (item (3) of [y pos v])\nend\nchange x by (30)\nif <(item (2) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (2) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\nif <not <(item (4) of [generator v]) = [1]>> then\n    set y to (item (5) of [y pos v])\nelse\n    set y to (item (4) of [y pos v])\nend\nchange x by (30)\nif <(item (3) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (3) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\nif <not <(item (5) of [generator v]) = [1]>> then\n    set y to (item (6) of [y pos v])\nelse\n    set y to (item (5) of [y pos v])\nend\nchange x by (30)\nif <(item (4) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (4) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\nif <not <(item (6) of [generator v]) = [1]>> then\n    set y to (item (7) of [y pos v])\nelse\n    set y to (item (6) of [y pos v])\nend\nchange x by (30)\nif <(item (5) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (5) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\nif <not <(item (7) of [generator v]) = [1]>> then\n    set y to (item (8) of [y pos v])\nelse\n    set y to (item (7) of [y pos v])\nend\nchange x by (30)\nif <(item (6) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (6) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\nif <not <(item (8) of [generator v]) = [1]>> then\n    set y to (item (9) of [y pos v])\nelse\n    set y to (item (8) of [y pos v])\nend\nchange x by (30)\nif <(item (7) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (7) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\nif <not <(item (9) of [generator v]) = [1]>> then\n    set y to (item (10) of [y pos v])\nelse\n    set y to (item (9) of [y pos v])\nend\nchange x by (30)\nif <(item (8) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (8) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\nif <not <(item (10) of [generator v]) = [1]>> then\n    set y to (item (11) of [y pos v])\nelse\n    set y to (item (10) of [y pos v])\nend\nchange x by (30)\nif <(item (9) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (9) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\nif <not <(item (11) of [generator v]) = [1]>> then\n    set y to (item (12) of [y pos v])\nelse\n    set y to (item (11) of [y pos v])\nend\nchange x by (30)\nif <(item (10) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (10) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\nif <not <(item (12) of [generator v]) = [1]>> then\n    set y to (item (13) of [y pos v])\nelse\n    set y to (item (12) of [y pos v])\nend\nchange x by (30)\nif <(item (11) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (11) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\nif <not <(item (13) of [generator v]) = [1]>> then\n    set y to (item (14) of [y pos v])\nelse\n    set y to (item (13) of [y pos v])\nend\nchange x by (30)\nif <(item (12) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (12) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\nif <not <(item (14) of [generator v]) = [1]>> then\n    set y to (item (15) of [y pos v])\nelse\n    set y to (item (14) of [y pos v])\nend\nchange x by (30)\nif <(item (13) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (13) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\nif <not <(item (15) of [generator v]) = [1]>> then\n    set y to (item (16) of [y pos v])\nelse\n    set y to (item (15) of [y pos v])\nend\nchange x by (30)\nif <(item (14) of [red v]) = [1]> then\n    Render Stack (R)\nelse\n    if <not <(item (14) of [black v]) = [1]>> then\n        Render Stack (B)\n    end\nend\n\ndefine Render (B) Block\nset pen color to (#000000)\nset pen size to (7)\npen down\nchange x by (30)\nchange y by (-30)\nchange x by (-30)\nchange y by (30)\nchange y by (-5)\nchange x by (30)\nchange y by (-5)\nchange x by (-30)\nchange y by (-5)\nchange x by (30)\nchange y by (-5)\nchange x by (-30)\nchange y by (-5)\nchange x by (30)\nchange y by (25)\nchange x by (-30)\npen up\n\ndefine Render (R) Block\nset pen color to (#ff0000)\nset pen size to (7)\npen down\nchange x by (30)\nchange y by (-30)\nchange x by (-30)\nchange y by (30)\nchange y by (-5)\nchange x by (30)\nchange y by (-5)\nchange x by (-30)\nchange y by (-5)\nchange x by (30)\nchange y by (-5)\nchange x by (-30)\nchange y by (-5)\nchange x by (30)\nchange y by (25)\nchange x by (-30)\npen up\n\ndefine Render Stack (B)\nRender (B) Block\nchange y by (-30)\nRender (B) Block\nchange y by (-30)\nRender (B) Block\nchange y by (-30)\nRender (B) Block\nchange y by (-30)\nRender (B) Block\nchange y by (-30)\nRender (B) Block\nchange y by (-30)\nRender (B) Block\nchange y by (-30)\nRender (B) Block\nchange y by (-30)\nRender (B) Block\n\nwhen I receive [generate level v]\ndelete all of [black v]\ndelete all of [y pos v]\ndelete all of [red v]\ndelete all of [generator v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (-170) to (-20)) to [y pos v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (Die)) to [red v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (None)) to [black v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nadd (pick random (1) to (3)) to [generator v]\nerase all\nRender Ground\n\ndefine Render Stack (R)\nRender (R) Block\nchange y by (-30)\nRender (R) Block\nchange y by (-30)\nRender (R) Block\nchange y by (-30)\nRender (R) Block\nchange y by (-30)\nRender (R) Block\nchange y by (-30)\nRender (R) Block\nchange y by (-30)\nRender (R) Block\nchange y by (-30)\nRender (R) Block\nchange y by (-30)\nRender (R) Block\n\nwhen [space v] key pressed\nbroadcast (Generate Level v)\n\n