99% pen platformer

Instructions: Press the green flag and enjoy\n100% by me\n10 levels\n\n[Obstacles]\n\nArrow keys - to move\nAvoid lava - red\nElevator - grey\nLand - green\nLock - brown (get the key to open it)\nKey - yellow (get it to open locks)\n\n[Finish]\nGet to the black square as fast as you can\n\n\n\n\n\n\n\n

@Stage\n\nwhen flag clicked\nforever\n    play sound [Kalimba.mp3 v] until done\nend\n\n@Main character\n\nwhen flag clicked\nset [y v] to [0]\nset [x v] to [0]\nshow\ngo to x: (-230) y: (0)\nerase all\nhide variable [level v]\nhide variable [x v]\nhide variable [y v]\nforever\n    if <touching color (#e1a91a)?> then\n        broadcast (3 v)\n    end\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        change [x v] by (1)\n    end\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        change [x v] by (-1)\n    end\n    set [x v] to ((X) * (0.9))\n    change x by (X)\n    if <touching color (#0e9a6c)?> then\n        change y by (1)\n        if <touching color (#0e9a6c)?> then\n            change y by (1)\n        end\n        if <touching color (#0e9a6c)?> then\n            change y by (1)\n            if <touching color (#0e9a6c)?> then\n                change y by (1)\n            end\n        end\n    end\n    if <touching color (#0e9a6c)?> then\n        change x by ((X) * (-1))\n        change y by (-4)\n        if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n            if <(X) > [0]> then\n                set [x v] to [-5]\n            else\n                set [x v] to [5]\n            end\n            set [y v] to [10]\n        else\n            set [y v] to [0]\n        end\n    end\n    change [y v] by (-1)\n    change y by (Y)\n    if <<<touching color (#0e9a6c)?> or <touching color (#ba7413)?>> or <touching color (#353444)?>> then\n        change y by ((Y) * (-1))\n        set [y v] to [1]\n    end\n    change y by (-1)\n    if <<<touching color (#0e9a6c)?> or <touching color (#ba7413)?>> or <touching color (#353444)?>> then\n        if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n            set [y v] to [15]\n        end\n    end\n    change y by (1)\n    if <(y position) < [-178]> then\n        go to x: (-230) y: (0)\n        set [key v] to [0]\n    end\n    if <<touching color (#f34dff)?> or <touching color (#bb42c3)?>> then\n        go to x: (188) y: (97)\n    end\n    if <touching color (#000000)?> then\n        change [level1 v] by (1)\n        if <(level1) = [7]> then\n            go to x: (-211) y: (-118)\n        else\n            if <<(level1) = [8]> or <(level1) = [10]>> then\n                go to x: (-240) y: (-44)\n            else\n                go to x: (-230) y: (0)\n            end\n        end\n    end\n    if <<touching color (#e81818)?> or <touching color (#e81111)?>> then\n        if <(level1) = [7]> then\n            set [key v] to [0]\n            go to x: (-211) y: (-118)\n        else\n            if <<(level1) = [8]> or <(level1) = [10]>> then\n                go to x: (-240) y: (-44)\n            else\n                go to x: (-230) y: (0)\n            end\n        end\n    end\n    if <touching color (#ee7d16)?> then\n        set [y v] to [20]\n    end\nend\n\nwhen flag clicked\nset [level1 v] to [0]\nwait until <(level1) = [11]>\nthink [You've finished] for (3) seconds\n\nwhen flag clicked\nforever\n    repeat until <not <touching color (#353444)?>>\n        change y by (6)\n    end\nend\n\nwhen flag clicked\nwait until <(level1) = [10]>\ngo to x: (-240) y: (-66)\n\n@render background\n\nwhen flag clicked\nset [key v] to [0]\nset [level1 v] to [0]\nchange [level1 v] by (1)\ngo to x: (-240) y: (-180)\nset [lifes v] to [3]\nforever\n    if <(level1) = [1]> then\n        erase all\n        level 1\n        Render Lava 1\n        Render Flag 2\n    end\n    if <(level1) = [2]> then\n        erase all\n        level 1\n        render hill\n        render flag 3\n    end\n    if <(level1) = [2]> then\n        erase all\n        level 1\n        render hill\n        splints\n        render flag 3\n    end\n    if <(level1) = [3]> then\n        erase all\n        barrier\n        level 1\n        Render Lava 1\n        Render Flag 2\n        render lava 2\n        render lava 4\n    end\n    if <<(level1) = [4]> and <(key) = [yes]>> then\n        erase all\n        level 1\n        barrier2\n        flag 4\n    else\n        if <(level1) = [4]> then\n            erase all\n            set [key v] to [0]\n            level 1\n            barrier2\n            flag 4\n            lock1\n            key 1\n        end\n    end\n    if <(level1) = [5]> then\n        set [key v] to [0]\n        erase all\n        level 1\n        render hill\n        spike 3\n        spike 2\n        b\n        line aside\n        flag 5\n    end\n    if <(level1) = [6]> then\n        set [key v] to [0]\n        erase all\n        holeb\n        level 1\n        level 2\n        portal\n        portal 2 \n        spike 4\n        spike 5\n        flag 7\n        spike 6\n        lava\n    end\n    if <<(level1) = [7]> and <(key) = [yes]>> then\n        erase all\n        holeb\n        render lava 3\n        level 1\n        level 2 (1)\n        hole 4\n        flag\n        hole 5\n        hole 7\n        hole 8\n        render lava 3\n        lava\n    else\n        if <(level1) = [7]> then\n            erase all\n            holeb\n            level 1\n            render lava 3\n            level 2 (1)\n            hole 4\n            flag\n            hole 5\n            hole 7\n            lock 2\n            hole 8\n            render lava 3\n            lava\n            key 2\n        end\n    end\n    set [xv v] to [-90]\n    if <(level1) = [8]> then\n        set [key v] to [0]\n        erase all\n        level 1\n        level 2 (1)\n        spike 2\n        spikes\n        spike 3\n        spike 10\n        spike 11\n        holec\n        line of bounce back\n        spike 16\n        spike 17\n        flag 12\n        render lava 7\n        line aside 3\n    end\n    if <(level1) = [9]> then\n        set [key v] to [0]\n        erase all\n        level 1\n        lava\n        flag13\n        line of bounce back 2\n        render lava 3\n        border\n        spike 18\n    end\n    if <(level1) = [10]> then\n        erase all\n        level 1\n        Render Lava 1\n        level 2 (1)\n        hole 11\n        last flag\n        elevator red\n        render lava 2\n        render lava 4\n    end\n    if <(level1) = [11]> then\n        erase all\n        level 1\n        fun bounce of line\n    end\n    if <(level1) = [12]> then\n        erase all\n        level 1\n    end\nend\n\nrender lava 3\n\ndefine level 1\npen up\nset pen color to (#0e9a6c)\ngo to x: (-240) y: (-180)\npen down\nset pen size to (100)\ngo to x: (240) y: (-180)\npen up\n\ndefine render hill\npen up\ngo to x: (150) y: (-140)\nset pen size to (150)\nset pen color to (#0e9a6c)\npen down\npen down\nchange y by (200)\nchange x by (-150)\nchange y by (-200)\npen up\n\ndefine Render Flag 2\npen up\nset pen color to (#000000)\nset pen size to (10)\npen up\ngo to x: (180) y: (-100)\npen down\nchange x by (10)\nchange y by (-10)\nchange x by (-10)\nchange y by (10)\n\ndefine Render Lava 1\npen up\ngo to x: (-50) y: (-140)\nset pen size to (20)\nset pen color to (#e81818)\npen down\ngo to x: (20) y: (-140)\nchange y by (-20)\nchange x by (-70)\nchange y by (20)\nchange y by (-40)\nchange x by (70)\nchange y by (20)\npen up\ngo to x: (180) y: (-130)\n\ndefine render lava 2\npen up\ngo to x: (130) y: (-140)\nset pen size to (20)\nset pen color to (#e81818)\npen down\ngo to x: (130) y: (-140)\nchange y by (-20)\nchange x by (-70)\nchange y by (20)\nchange y by (-40)\nchange x by (70)\nchange y by (20)\nchange y by (20)\nchange x by (-70)\ngo to x: (130) y: (-140)\npen up\n\ndefine barrier\npen up\ngo to x: (150) y: (-140)\nset pen size to (10)\nset pen color to (#0e9a6c)\npen down\npen down\nchange y by (150)\nchange x by (10)\nchange y by (-150)\npen up\n\ndefine barrier2\npen up\ngo to x: (0) y: (-140)\nset pen size to (10)\nset pen color to (#0e9a6c)\npen down\npen down\nchange y by (150)\nchange x by (10)\nchange y by (-150)\npen up\ngo to x: (0) y: (0)\nset pen size to (10)\nset pen color to (#0e9a6c)\npen down\npen down\nchange y by (10)\nchange x by (150)\nchange y by (-10)\nchange x by (-150)\npen up\n\ndefine lock1\npen up\ngo to x: (150) y: (0)\nset pen size to (10)\nset pen color to (#ba7413)\npen down\npen down\nchange y by (10)\nchange x by (150)\nchange y by (-10)\npen up\n\ndefine flag 4\npen up\nset pen color to (#000000)\nset pen size to (10)\npen up\ngo to x: (30) y: (-100)\npen down\nchange x by (10)\nchange y by (-10)\nchange x by (-10)\nchange y by (10)\n\ndefine render flag 3\npen up\nset pen color to (#000000)\nset pen size to (10)\npen up\ngo to x: (180) y: (150)\npen down\nchange x by (10)\nchange y by (-10)\nchange x by (-10)\nchange y by (10)\n\nwhen I receive [3 v]\nset [key v] to [yes]\n\ndefine key 1\npen up\npen up\nset pen color to (#e1a91a)\nset pen size to (10)\npen up\ngo to x: (-30) y: (-100)\npen down\nchange x by (10)\nchange y by (-10)\nchange x by (-10)\nchange y by (10)\nchange y by (-5)\nchange x by (20)\n\ndefine render lava 4\npen up\ngo to x: (-150) y: (-140)\nset pen size to (20)\nset pen color to (#e81818)\npen down\ngo to x: (-150) y: (-140)\nchange y by (-20)\nchange x by (-70)\nchange y by (20)\nchange y by (-40)\nchange x by (70)\nchange y by (20)\nchange y by (20)\nchange x by (-70)\npen up\ngo to x: (-150) y: (-140)\n\ndefine spike 2\npen up\nset pen color to (#e81818)\nset pen size to (5)\ngo to x: (-100) y: (-130)\npen down\nchange x by (-20)\ngo to x: (-110) y: (-120)\ngo to x: (-100) y: (-130)\n\ndefine level2\npen up\nset pen color to (#e1a91a)\ngo to x: (-240) y: (-180)\npen down\npen down\nset pen size to (100)\ngo to x: (-100) y: (-180)\npen up\n\nchange x by (-20)\ngo to x: (-90) y: (-120)\ngo to x: (-80) y: (-130)\n\ndefine spike 3\npen up\nset pen color to (#e81818)\nset pen size to (5)\ngo to x: (-80) y: (-130)\npen down\nchange x by (-20)\ngo to x: (-90) y: (-120)\ngo to x: (-80) y: (-130)\n\ndefine holeb\npen up\ngo to x: (0) y: (-100)\nset pen color to (#0e9a6c)\nset pen size to (20)\nstamp\npen down\npen up\n\ndefine level 2\npen up\nset pen size to (10)\nset pen color to (#0e9a6c)\ngo to x: (-240) y: (80)\npen down\ngo to x: (240) y: (80)\npen up\n\ndefine portal\npen up\nset pen size to (10)\nset pen color to (#bb42c3)\ngo to x: (180) y: (-20)\npen down\nchange x by (25)\nchange pen shade by (10)\nchange y by (-30)\nchange pen shade by (10)\nchange x by (-25)\nchange pen shade by (10)\nchange y by (30)\n\ndefine portal 2 <>\npen up\nset pen size to (10)\nset pen color to (#dddede)\ngo to x: (180) y: (130)\npen down\nchange x by (25)\nchange pen shade by (10)\nchange y by (-30)\nchange pen shade by (10)\nchange x by (-25)\nchange pen shade by (10)\nchange y by (30)\n\ndefine flag 6\npen up\nset pen color to (#000000)\nset pen size to (10)\npen up\ngo to x: (-180) y: (130)\npen down\nchange x by (10)\nchange y by (-10)\nchange x by (-10)\nchange y by (10)\n\ndefine spikes\npen up\nset pen color to (#e81818)\nset pen size to (5)\ngo to x: (-120) y: (-130)\npen down\nchange x by (-20)\ngo to x: (-130) y: (-120)\ngo to x: (-120) y: (-130)\n\ndefine spike 4\npen up\nset pen color to (#e81818)\nset pen size to (5)\ngo to x: (-120) y: (80)\npen down\nchange x by (-20)\ngo to x: (-130) y: (90)\ngo to x: (-120) y: (80)\n\ndefine spike 5\npen up\nset pen color to (#e81818)\nset pen size to (5)\ngo to x: (-140) y: (80)\npen down\nchange x by (-20)\ngo to x: (-150) y: (90)\ngo to x: (-140) y: (80)\n\ndefine spike 6\npen up\nset pen color to (#e81818)\nset pen size to (5)\ngo to x: (-60) y: (80)\npen down\nchange x by (-20)\ngo to x: (-70) y: (90)\ngo to x: (-60) y: (80)\n\ndefine line aside 2\npen up\ngo to x: (0) y: (180)\npen down\nchange y by (-60)\n\ndefine None\npen up\nset pen size to (200)\nset pen color to (#0e9a6c)\ngo to x: (-240) y: (80)\npen down\ngo to x: (240) y: (80)\npen up\n\ndefine flag 5\npen up\nset pen color to (#000000)\nset pen size to (10)\npen up\ngo to x: (80) y: (-140)\npen down\nchange x by (10)\nchange y by (-10)\nchange x by (-10)\nchange y by (10)\n\ndefine b\npen up\nset pen color to (#99b2ff)\nset pen size to (50)\ngo to x: (0) y: (130)\npen down\ngo to x: (0) y: (-150)\nchange x by (100)\n\ndefine flag\npen up\nset pen color to (#000000)\nset pen size to (10)\npen up\ngo to x: (0) y: (150)\npen down\nchange x by (10)\nchange y by (-10)\nchange x by (-10)\nchange y by (10)\n\ndefine flag 7\npen up\nset pen color to (#000000)\nset pen size to (10)\npen up\ngo to x: (-180) y: (150)\npen down\nchange x by (10)\nchange y by (-10)\nchange x by (-10)\nchange y by (10)\n\ndefine hole 5\npen up\nset pen color to (#0e9a6c)\nset pen size to (20)\ngo to x: (180) y: (-100)\npen down\n\ndefine hole 4\npen up\nset pen color to (#99b2ff)\nset pen size to (50)\ngo to x: (0) y: (0)\npen down\ngo to x: (0) y: (180)\n\ndefine hole 7\npen up\nset pen color to (#99b2ff)\nset pen size to (50)\ngo to x: (180) y: (0)\npen down\ngo to x: (180) y: (180)\n\ndefine key 2\npen up\npen up\nset pen color to (#e1a91a)\nset pen size to (10)\npen up\ngo to x: (180) y: (180)\npen down\nchange x by (10)\nchange y by (-10)\nchange x by (-10)\nchange y by (10)\nchange y by (-5)\nchange x by (20)\n\ndefine lock 2\npen up\ngo to x: (-20) y: (0)\nset pen size to (10)\nset pen color to (#ba7413)\npen down\npen down\nchange y by (10)\nchange x by (40)\nchange y by (-10)\npen up\n\ndefine hole 8\npen up\nset pen color to (#0e9a6c)\nset pen size to (20)\ngo to x: (90) y: (-100)\npen down\n\ndefine spike 10\npen up\nset pen color to (#e81818)\nset pen size to (5)\ngo to x: (-60) y: (-20)\npen down\nchange x by (-20)\ngo to x: (-70) y: (-30)\ngo to x: (-60) y: (-20)\n\ndefine spike 11\npen up\nset pen color to (#e81818)\nset pen size to (5)\ngo to x: (-40) y: (-20)\npen down\nchange x by (-20)\ngo to x: (-50) y: (-30)\ngo to x: (-40) y: (-20)\n\ndefine line of bounce back\npen up\nset pen size to (10)\nset pen color to (#353444)\ngo to x: (-20) y: (yv)\npen down\nchange x by (30)\n\ndefine spike 12\npen up\nset pen color to (#e81818)\nset pen size to (5)\ngo to x: (0) y: (-20)\npen down\nchange x by (-20)\ngo to x: (-10) y: (-30)\ngo to x: (0) y: (-20)\n\ndefine spike 16\npen up\nset pen color to (#e81818)\nset pen size to (5)\ngo to x: (80) y: (-20)\npen down\nchange x by (-20)\ngo to x: (70) y: (-30)\ngo to x: (80) y: (-20)\n\nwhen flag clicked\nset [yv v] to [-130]\nforever\n    repeat (45)\n        change [yv v] by (5)\n    end\n    repeat (45)\n        change [yv v] by (-5)\n    end\n    wait (1) seconds\nend\n\ndefine holec\npen up\nset pen color to (#99b2ff)\nset pen size to (50)\ngo to x: (0) y: (0)\npen down\ngo to x: (0) y: (120)\nchange x by (160)\nchange y by (-100)\nchange x by (-100)\npen up\n\ndefine flag\n\ndefine flag 12\npen up\nset pen color to (#000000)\nset pen size to (10)\npen up\ngo to x: (50) y: (20)\npen down\nchange x by (10)\nchange y by (-10)\nchange x by (-10)\nchange y by (10)\n\ndefine render lava 7\npen up\ngo to x: (-50) y: (-140)\nset pen size to (20)\nset pen color to (#e81818)\npen down\ngo to x: (20) y: (-140)\nchange y by (-20)\nchange x by (-70)\nchange y by (20)\nchange y by (-40)\nchange x by (70)\nchange y by (20)\npen up\ngo to x: (180) y: (-130)\n\ndefine line aside 3\nset pen color to (#e81818)\ngo to x: (180) y: (140)\npen down\nchange y by (-120)\npen up\n\ndefine spike 17\npen up\nset pen color to (#e81818)\nset pen size to (5)\ngo to x: (120) y: (-20)\npen down\nchange x by (-20)\ngo to x: (110) y: (-30)\ngo to x: (120) y: (-20)\n\ndefine border\npen up\nset pen color to (#0e9a6c)\nset pen size to (20)\ngo to x: (110) y: (-20)\npen down\nchange x by (500)\n\ndefine spike 18\npen up\nset pen color to (#e81818)\nset pen size to (5)\ngo to x: (100) y: (-28)\npen down\nchange y by (20)\ngo to x: (80) y: (-8)\ngo to x: (100) y: (-28)\n\ndefine flag13\npen up\nset pen color to (#000000)\nset pen size to (10)\npen up\ngo to x: (180) y: (10)\npen down\nchange x by (10)\nchange y by (-10)\nchange x by (-10)\nchange y by (10)\n\ndefine line of bounce back 2\npen up\nset pen size to (10)\nset pen color to (#353444)\ngo to x: (-20) y: (zv)\npen down\nchange x by (30)\n\nwhen flag clicked\nset [zv v] to [-130]\nforever\n    repeat (15)\n        change [zv v] by (5)\n    end\n    repeat (15)\n        change [zv v] by (-5)\n    end\n    wait (1) seconds\nend\n\ndefine flag\n\ndefine render lava 4\n\ndefine splints\npen up\nset pen color to (#e81818)\nset pen size to (5)\ngo to x: (-100) y: (-130)\npen down\nchange x by (-20)\ngo to x: (-110) y: (-120)\ngo to x: (-110) y: (-120)\ngo to x: (-100) y: (-130)\npen up\n\ndefine portal 3\npen up\nset pen size to (10)\nset pen color to (#ee7d16)\ngo to x: (180) y: (-100)\npen down\nchange x by (25)\nchange pen shade by (10)\nchange y by (-30)\nchange pen shade by (10)\nchange x by (-25)\nchange pen shade by (10)\nchange y by (30)\n\ndefine last flag\npen up\nset pen color to (#000000)\nset pen size to (10)\npen up\ngo to x: (180) y: (150)\npen down\nchange x by (10)\nchange y by (-10)\nchange x by (-10)\nchange y by (10)\n\ndefine hole 11\npen up\nset pen color to (#99b2ff)\nset pen size to (50)\ngo to x: (180) y: (0)\npen down\ngo to x: (180) y: (180)\n\ndefine elevator red\npen up\nset pen size to (10)\nset pen color to (#353444)\nset pen color to (#e81818)\ngo to x: (165) y: (yv)\npen down\nchange x by (30)\n\ndefine fun bounce of line\npen up\ngo to x: (300) y: (-140)\nset pen size to (20)\nset pen color to (#ee7d16)\npen down\ngo to x: (300) y: (-140)\nchange y by (-20)\nchange x by (0)\nchange y by (20)\nchange y by (-40)\nchange x by (-350)\nchange y by (20)\nchange y by (20)\nchange x by (350)\npen up\ngo to x: (-50) y: (-140)\npen down\ngo to x: (300) y: (-160)\nchange x by (-350)\npen up\n\ndefine render lava 3\n\nwhen flag clicked\nset [x position of enemy v] to [-130]\nforever\n    repeat (45)\n        change [x position of enemy v] by (5)\n    end\n    repeat (45)\n        change [x position of enemy v] by (-5)\n    end\nend\n\nerase all\n\nenemy\n\npen up\n\ndefine enemy\n\nrender lava 3\n\ndefine line aside\npen up\nset pen size to (20)\nset pen color to (#e81818)\ngo to x: (30) y: (140)\npen down\ngo to x: (30) y: (-120)\n\ndefine lava 3\npen up\ngo to x: (-100) y: (-140)\nset pen size to (20)\nset pen color to (#e81818)\npen down\ngo to x: (-100) y: (-140)\nchange y by (-20)\nchange x by (-250)\nchange y by (20)\nchange y by (-40)\nchange x by (250)\nchange y by (20)\nchange y by (20)\nchange x by (-250)\npen up\ngo to x: (-100) y: (-140)\n\ndefine lava 5\npen up\ngo to x: (150) y: (-140)\nset pen size to (20)\nset pen color to (#e81818)\npen down\ngo to x: (150) y: (-140)\nchange y by (-20)\nchange x by (0)\nchange y by (20)\nchange y by (-40)\nchange x by (-350)\nchange y by (20)\nchange y by (20)\nchange x by (350)\ngo to x: (150) y: (-160)\nchange x by (-350)\npen up\n\nrender lava 2\n\ndefine lava\npen up\ngo to x: (300) y: (-140)\nset pen size to (20)\nset pen color to (#e81818)\npen down\ngo to x: (300) y: (-140)\nchange y by (-20)\nchange x by (0)\nchange y by (20)\nchange y by (-40)\nchange x by (-350)\nchange y by (20)\nchange y by (20)\nchange x by (350)\npen up\ngo to x: (-50) y: (-140)\npen down\ngo to x: (300) y: (-160)\nchange x by (-350)\npen up\n\nlava\n\nlava 5\n\nlava 5\n\nlava 5\n\ndefine render line\npen up\nset pen size to (10)\nset pen color to (#0e9a6c)\npen down\ngo to x: (180) y: (-1300)\nchange y by (130)\npen up\n\ndefine sideline\npen up\ngo to x: (240) y: (0)\nset pen color to (#ff0000)\npen down\nchange x by (-60)\npen up\n\ndefine key 3\npen up\npen up\nset pen color to (#e1a91a)\nset pen size to (10)\npen up\ngo to x: (220) y: (-100)\npen down\nchange x by (10)\nchange y by (-10)\nchange x by (-10)\nchange y by (10)\nchange y by (-5)\nchange x by (20)\n\ndefine moving lines\npen up\nset pen color to (#ff0000)\nset y to (-130)\npen down\nchange x by (100)\nforever\n    set x to (xv)\nend\n\nwait (1) seconds\n\nwhen flag clicked\nset [xv v] to [-130]\nforever\n    repeat (45)\n        change [xv v] by (5)\n    end\n    repeat (45)\n        change [xv v] by (-5)\n    end\nend\n\ngo to x: (xv) y: (-130)\n\nkey 1\n\nkey 2\n\nkey 3\n\n@Sprite3\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nshow variable [level1 v]\nforever\n    go to x: (0) y: (0)\nend\n\n