Glitched - A 100% Pen Platformer Challenge


@Stage\n\nwhen flag clicked\nforever\n    play sound [Theme B v] until done\nend\n\nwhen flag clicked\nset [pitch v] effect to (0)\nforever\n    set [pitch v] effect to ((Glitch) * (10))\nend\n\n@pen\n\nwhen flag clicked\nCreate Level\nset [xv v] to [0]\nset [yv v] to [0]\nset [x position v] to [0]\nset [y position v] to [0]\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nset [glitch v] to [1]\nforever\n    Draw\n    Update\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        change [xv v] by (1)\n    end\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        change [xv v] by (-1)\n    end\n    set [xv v] to ((Xv) * (0.9))\n    change [x position v] by (Xv)\n    Update\n    if <[touching v] contains [1]?> then\n        change [y position v] by (1)\n        Update\n        if <[touching v] contains [1]?> then\n            change [y position v] by (1)\n            Update\n            if <[touching v] contains [1]?> then\n                change [y position v] by (1)\n                Update\n                if <[touching v] contains [1]?> then\n                    change [y position v] by (1)\n                    Update\n                    if <[touching v] contains [1]?> then\n                        change [y position v] by (1)\n                        Update\n                        if <[touching v] contains [1]?> then\n                            change [x position v] by ((Xv) * (-1))\n                            change [y position v] by (-5)\n                            if  then\n                                if <(Xv) > [0]> then\n                                    set [xv v] to [-5]\n                                else\n                                    set [xv v] to [5]\n                                end\n                                set [yv v] to [10]\n                            else\n                                set [xv v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    Update\n    change [yv v] by (-1)\n    change [y position v] by (Yv)\n    Update\n    if <[touching v] contains [1]?> then\n        change [y position v] by ((Yv) * (-1))\n        set [yv v] to [0]\n    end\n    Update\n    change [y position v] by (-1)\n    Update\n    if <[touching v] contains [1]?> then\n        if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n            set [yv v] to [15]\n        end\n    end\n    Update\n    if <[touching v] contains [2]?> then\n        set [yv v] to [20]\n    end\n    Update\n    if <<[touching v] contains [3]?> or <(Scroll Y) > [500]>> then\n        set [xv v] to [0]\n        set [yv v] to [0]\n        set [x position v] to [0]\n        set [y position v] to [0]\n        set [scroll x v] to [0]\n        set [scroll y v] to [0]\n        stop all sounds\n    end\n    Update\n    change [y position v] by (1)\n    Scrolling\nend\n\ndefine None\ngo to x: (((x) + (Scroll X)) + (pick random (() - (Glitch)) to (Glitch))) y: (((y) + (Scroll Y)) + (pick random (() - (Glitch)) to (Glitch)))\n\ndefine Create Level\nset [offset v] to [0]\ndelete (all) of [level xs v]\ndelete (all) of [level ys v]\ndelete (all) of [level widths v]\ndelete (all) of [level heights v]\ndelete (all) of [level types v]\nrepeat (2)\n    Add Rectangle (-150) (-50) (300) (25) (1)\n    Add Rectangle (150) (-50) (50) (25) (2)\n    Add Rectangle (200) (-50) (25) (150) (1)\n    Add Rectangle (225) (75) (50) (25) (1)\n    Add Rectangle (275) (50) (50) (25) (1)\n    Add Rectangle (325) (25) (50) (25) (1)\n    Add Rectangle (375) (0) (75) (25) (1)\n    Add Rectangle (450) (0) (50) (20) (3)\n    Add Rectangle (500) (0) (50) (25) (1)\n    Add Rectangle (550) (0) (50) (20) (3)\n    Add Rectangle (600) (0) (125) (25) (1)\n    Add Rectangle (725) (0) (25) (75) (3)\n    Add Rectangle (750) (0) (50) (25) (1)\n    Add Rectangle (800) (0) (25) (75) (3)\n    Add Rectangle (825) (0) (50) (25) (1)\n    Add Rectangle (950) (0) (50) (25) (2)\n    Add Rectangle (1000) (0) (100) (100) (3)\n    Add Rectangle (1100) (0) (100) (25) (1)\n    Add Rectangle (1200) (0) (25) (75) (3)\n    Add Rectangle (1275) (50) (25) (150) (3)\n    Add Rectangle (1225) (0) (125) (25) (1)\n    Add Rectangle (1300) (175) (400) (25) (3)\n    Add Rectangle (1350) (0) (100) (25) (2)\n    Add Rectangle (1450) (0) (50) (25) (1)\n    Add Rectangle (1500) (0) (150) (25) (2)\n    Add Rectangle (1650) (0) (150) (25) (1)\n    Add Rectangle (1800) (0) (25) (100) (3)\n    Add Rectangle (1825) (0) (50) (25) (1)\n    Add Rectangle (1875) (0) (25) (100) (3)\n    Add Rectangle (1900) (0) (50) (25) (1)\n    Add Rectangle (1950) (0) (25) (100) (3)\n    Add Rectangle (1975) (0) (25) (25) (1)\n    Add Rectangle (2000) (0) (25) (100) (3)\n    Add Rectangle (2025) (0) (75) (25) (1)\n    Add Rectangle (2100) (0) (50) (25) (2)\n    Add Rectangle (2150) (0) (200) (50) (3)\n    Add Rectangle (2350) (0) (60) (25) (1)\n    Add Rectangle (2410) (0) (25) (100) (3)\n    Add Rectangle (2435) (0) (40) (25) (1)\n    Add Rectangle (2475) (0) (25) (100) (3)\n    Add Rectangle (2500) (0) (150) (25) (1)\n    change [offset v] by (2800)\nend\n\ndefine Draw\npen up\nerase all\nset pen size to (5)\nset [i v] to [0]\nrepeat (length of [level xs v])\n    change [i v] by (1)\n    if <<<((Scroll Y) + (((item (i) of [level ys v]) + (item (i) of [level heights v])) - (5))) > [-180]> and <((Scroll Y) + ((item (i) of [level ys v]) + (5))) < [240]>> and <<((Scroll X) + (((item (i) of [level xs v]) + (item (i) of [level widths v])) - (5))) > [-240]> and <((Scroll X) + ((item (i) of [level xs v]) + (5))) < [240]>>> then\n        Go To ((item (i) of [level xs v]) + (5)) ((item (i) of [level ys v]) + (5))\n        set [initial x v] to (x position)\n        set [initial y v] to (y position)\n        set pen color to (#000000)\n        if <(item (i) of [level types v]) = [2]> then\n            set pen color to (#2ca5e2)\n        end\n        if <(item (i) of [level types v]) = [1]> then\n            set pen color to (#ffffff)\n        end\n        if <(item (i) of [level types v]) = [3]> then\n            set pen color to (#5cb712)\n        end\n        pen down\n        Go To (((item (i) of [level xs v]) + (item (i) of [level widths v])) - (5)) ((item (i) of [level ys v]) + (5))\n        Go To (((item (i) of [level xs v]) + (item (i) of [level widths v])) - (5)) (((item (i) of [level ys v]) + (item (i) of [level heights v])) - (5))\n        Go To ((item (i) of [level xs v]) + (5)) (((item (i) of [level ys v]) + (item (i) of [level heights v])) - (5))\n        go to x: (Initial X) y: (Initial Y)\n        pen up\n    end\nend\nset pen color to (#ee7d16)\ngo to x: ((x position) + (pick random (() - (Glitch)) to (Glitch))) y: ((y position) + (pick random (() - (Glitch)) to (Glitch)))\nset [initial x v] to (x position)\nset [initial y v] to (y position)\npen down\ngo to x: ((x position) + (pick random (() - (Glitch)) to (Glitch))) y: (((y position) + (20)) + (pick random (() - (Glitch)) to (Glitch)))\ngo to x: (((x position) + (20)) + (pick random (() - (Glitch)) to (Glitch))) y: (((y position) + (20)) + (pick random (() - (Glitch)) to (Glitch)))\ngo to x: (((x position) + (20)) + (pick random (() - (Glitch)) to (Glitch))) y: ((y position) + (pick random (() - (Glitch)) to (Glitch)))\ngo to x: (Initial X) y: (Initial Y)\npen up\n\ndefine Update\nset [glitch v] to ((Scroll X) * (() - ((1) / (500))))\ndelete (all) of [touching v]\nset [i v] to [0]\nrepeat (length of [level xs v])\n    change [i v] by (1)\n    if <<<(x position) < (((item (i) of [level xs v]) + (Scroll X)) + (item (i) of [level widths v]))> and <((x position) + (20)) > ((item (i) of [level xs v]) + (Scroll X))>> and <<(y position) < (((item (i) of [level ys v]) + (Scroll Y)) + (item (i) of [level heights v]))> and <((y position) + (20)) > ((item (i) of [level ys v]) + (Scroll Y))>>> then\n        if <not <[touching v] contains (item (i) of [level types v])?>> then\n            add (item (i) of [level types v]) to [touching v]\n        end\n    end\nend\n\ndefine Scrolling\nset [offset v] to (pick random (() - (Glitch)) to (Glitch))\nchange [scroll x v] by (() - (round ((x position) / (10))))\nchange [x position v] by (() - (round ((x position) / (10))))\nset [offset v] to (pick random (() - (Glitch)) to (Glitch))\nchange [scroll y v] by (() - (round ((y position) / (10))))\nchange [y position v] by (() - (round ((y position) / (10))))\n\ndefine None\nadd ((x) + (offset)) to [level xs v]\nadd (y) to [level ys v]\nadd (width) to [level widths v]\nadd (height) to [level heights v]\nadd (tyoe) to [level types v]\n\nwhen I receive [message1 v]\nstop [other scripts in sprite v]\npen up\nerase all\nset pen color to (#e6e8e8)\nset pen size to (20)\ngo to x: (-240) y: (180)\npen down\nrepeat (13)\n    set y to (180)\n    repeat (18)\n        change y by (-20)\n    end\n    change x by (20)\n    set y to (-180)\n    repeat (18)\n        change y by (20)\n    end\n    change x by (20)\nend\n\nwhen flag clicked\nforever\n    Update\n    if <(Scroll X) < [-5400]> then\n        broadcast (message1 v)\n    end\nend\n\n