Glitch -A Scrolling Platformer-

Instructions: Play my new 3D game, 3D Tennis:\nhttps://scratch.mit.edu/projects/520716879/\n\nSubmit custom level codes here:\nhttps://scratch.mit.edu/discuss/topic/409187/\n\nInstructions:\nArrow Keys or WASD to move.\nAvoid falling into space.\nTouch a wall to begin running on it.\nPlay in fullscreen.\n\nIf it lags, try playing on Forkphorus:\nhttps://forkphorus.github.io/#398255333\n\nRun.\nDo not slow down.\nDo not fall off.\nDo not give up.\n

@Stage\n\nwhen flag clicked\nforever\n    play sound [River v] until done\n    play sound [Vexento - Happy Robot v] until done\nend\n\n@PLAYER \n\ndefine Run Engine\nchange [y v] by (-0.5)\nif <<key (left arrow v) pressed?> or <<(x position) > (mouse x)> and <mouse down?>>> then\n    change [x v] by (-0.9)\nend\nif <<key (right arrow v) pressed?> or <<(mouse x) > (x position)> and <mouse down?>>> then\n    change [x v] by (0.9)\nend\nset [x v] to ((x) * (0.9))\nchange x by (x)\nif <<touching color (#58ff00)?> or <touching color (#ce9418)?>> then\n    change y by (1)\n    if <<touching color (#58ff00)?> or <touching color (#ce9418)?>> then\n        change y by (1)\n        if <<touching color (#58ff00)?> or <touching color (#ce9418)?>> then\n            change y by (1)\n            if <<touching color (#58ff00)?> or <touching color (#ce9418)?>> then\n                change y by (1)\n                if <<touching color (#58ff00)?> or <touching color (#ce9418)?>> then\n                    change y by (1)\n                    if <<touching color (#58ff00)?> or <touching color (#ce9418)?>> then\n                        change y by (1)\n                        if <<touching color (#58ff00)?> or <touching color (#ce9418)?>> then\n                            change y by (-6)\n                            change x by ((x) * (-1))\n                            if <<key (up arrow v) pressed?> or <<(mouse y) > (y position)> and <mouse down?>>> then\n                                set [y v] to [9]\n                                if <(x) > [0]> then\n                                    set [x v] to [-10]\n                                else\n                                    set [x v] to [10]\n                                end\n                            else\n                                set [x v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\nchange y by (y)\nif <<touching color (#58ff00)?> or <touching color (#ce9418)?>> then\n    change y by ((y) * (-1))\n    set [y v] to [0]\nend\nchange y by (-0.5)\nif <<<<touching color (#58ff00)?> or <touching color (#ce9418)?>> and <key (up arrow v) pressed?>> or <<<touching color (#58ff00)?> or <touching color (#ce9418)?>> and <<(mouse y) > (y position)> and <mouse down?>>>> then\n    set [y v] to [9.5]\nend\nchange y by (0.5)\nif <touching color (#ff0000)?> then\n    repeat (20)\n        change [ghost v] effect by (5)\n    end\n    go to x: (X Spawn) y: (Y Spawn)\n    repeat (20)\n        change [ghost v] effect by (-5)\n    end\n    set [x v] to [0]\n    set [y v] to [0]\nend\nif <(x position) > [233]> then\n    go to x: (X Spawn) y: (Y Spawn)\n    broadcast (NextLevel v)\n    set [x v] to [0]\n    set [y v] to [0]\nend\n\nwhen flag clicked\nset [y spawn v] to [-20]\nset [x spawn v] to [-218]\ngo to x: (X Spawn) y: (Y Spawn)\nswitch costume to (player v)\nswitch backdrop to (cavesbackround v)\nshow\nset size to (50) %\nset [x v] to [0]\nset [y v] to [0]\n\ndefine Run block\nRun Engine\n\nwhen flag clicked\nset [max players v] to [4]\nset [my player # v] to [0]\nbroadcast (setups v) and wait\nswitch backdrop to (joining v)\nbroadcast (join game v) and wait\nif <(My Player #) > [0]> then\nelse\nend\nbroadcast (begin v)\n\ndefine write (val) to encoded\nset [letter # v] to [1]\nrepeat (length of (val))\n    set [encodied v] to (join (encodied) (item # of (letter (letter #) of (val)) in [code v]))\n    change [letter # v] by (1)\nend\nset [encodied v] to (join (encodied) [00])\n\nwhen I receive [begin v]\nforever\n    Run block\n    if <(My Player #) > [0]> then\n        send cloud data\n    end\nend\n\ndefine set cloud # (player) to (value)\nif <(player) = [1]> then\n    set [☁ p1 v] to (value)\nelse\n    if <(player) = [2]> then\n        set [☁ p2 v] to (value)\n    else\n        if <(player) = [3]> then\n            set [☁ p3 v] to (value)\n        else\n            if <(player) = [4]> then\n                set [☁ p4 v] to (value)\n            else\n                if <(player) = [5]> then\n                    set [☁ p5 v] to (value)\n                else\n                    if <(player) = [6]> then\n                        set [☁ p6 v] to (value)\n                    else\n                        if <(player) = [7]> then\n                            set [☁ p7 v] to (value)\n                        else\n                            if <(player) = [8]> then\n                                set [☁ p8 v] to (value)\n                            else\n                                if <(player) = [9]> then\n                                    set [☁ p9 v] to (value)\n                                else\n                                    set [☁ p10 v] to (value)\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine send cloud data\nset [encodied v] to []\nwrite (username) to encoded\nwrite (round ((timer) * (10))) to encoded\nwrite (round (x position)) to encoded\nwrite (round (y position)) to encoded\nwrite (costume [number v]) to encoded\nwrite (Level) to encoded\nset cloud # (My Player #) to (encodied)\n\nwhen flag clicked\nset [connecting v] to [1]\n\nwhen flag clicked\nforever\n    set [timer v] to ((timer) + (1))\nend\n\nwhen [timer v] > (Timer)\nif <(My Player #) = [1]> then\n    set [☁ p1 v] to []\n    set [my player # v] to []\nelse\n    if <(My Player #) = [2]> then\n        set [☁ p2 v] to []\n        set [my player # v] to []\n    else\n        if <(My Player #) = [3]> then\n            set [☁ p3 v] to []\n            set [my player # v] to []\n        else\n            if <(My Player #) = [4]> then\n                set [☁ p4 v] to []\n                set [my player # v] to []\n            else\n                if <(My Player #) = [5]> then\n                    set [☁ p5 v] to []\n                    set [my player # v] to []\n                else\n                    if <(My Player #) = [6]> then\n                        set [☁ p6 v] to []\n                        set [my player # v] to []\n                    else\n                        if <(My Player #) = [7]> then\n                            set [☁ p7 v] to []\n                            set [my player # v] to []\n                        else\n                            if <(My Player #) = [8]> then\n                                set [☁ p8 v] to []\n                                set [my player # v] to []\n                            else\n                                if <(My Player #) = [9]> then\n                                    set [☁ p9 v] to []\n                                    set [my player # v] to []\n                                else\n                                    set [☁ p10 v] to []\n                                    set [my player # v] to []\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nreset timer\nset [timer v] to [0]\n\nwhen I receive [begin v]\nrepeat (60)\n    if <<<key (left arrow v) pressed?> or <<(x position) > (mouse x)> and <mouse down?>>> or <<<key (right arrow v) pressed?> or <<(mouse x) > (x position)> and <mouse down?>>> or <<<key (up arrow v) pressed?> or <<(mouse y) > (y position)> and <mouse down?>>> or <<<<touching (ground v)?> or <touching color (#00ff2c)?>> and <key (up arrow v) pressed?>> or <<<touching (ground v)?> or <touching color (#00ff2c)?>> and <<(mouse y) > (y position)> and <mouse down?>>>>>>> then\n        set [kickout v] to [0]\n    else\n        change [kickout v] by (1)\n    end\n    wait (1) seconds\nend\nif <(Kickout) = [60]> then\n    stop [all v]\nend\n\n@OPPONENTS\n\ndefine begin decode of (encode)\nset [encodied v] to (encode)\nset [letter # v] to [1]\n\ndefine value=read from encode\nset [value v] to []\nforever\n    set [idx v] to (join (letter (letter #) of (encodied)) (letter ((letter #) + (1)) of (encodied)))\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\ndefine setup players\nset [color v] effect to (90)\nset [offline v] to [100]\nhide\nset [player # v] to [1]\nrepeat ((MAX PLAYERS) - (1))\n    create clone of (_myself_ v)\n    change [player # v] by (1)\nend\n\nwhen I receive [begin v]\nforever\n    if <(My Player #) = (player #)> then\n        hide\n        set [offline v] to [100]\n    else\n        tick\n    end\nend\n\ndefine value=Cloud # (player)\nif <(player) = [1]> then\n    set [value v] to (☁ P1)\nelse\n    if <(player) = [2]> then\n        set [value v] to (☁ P2)\n    else\n        if <(player) = [3]> then\n            set [value v] to (☁ P3)\n        else\n            if <(player) = [4]> then\n                set [value v] to (☁ P4)\n            else\n                if <(player) = [5]> then\n                    set [value v] to (☁ P5)\n                else\n                    if <(player) = [6]> then\n                        set [value v] to (☁ P6)\n                    else\n                        if <(player) = [7]> then\n                            set [value v] to (☁ P7)\n                        else\n                            if <(player) = [8]> then\n                                set [value v] to (☁ P8)\n                            else\n                                if <(player) = [9]> then\n                                    set [value v] to (☁ P9)\n                                else\n                                    set [value v] to (☁ P10)\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [setups v]\nsetup players\n\ndefine tick\nvalue=Cloud # (player #)\nif <(join [A] (value)) = (last value)> then\n    change [offline v] by (1)\n    if <(offline) = [100]> then\n        hide\n    end\nelse\n    set [last value v] to (join [A] (value))\n    if <(offline) > [99]> then\n        show\n    end\n    set [offline v] to [0]\nend\nbegin decode of (value)\nvalue=read from encode\nsay (value)\nvalue=read from encode\nvalue=read from encode\nset x to (value)\nvalue=read from encode\nset y to (value)\nvalue=read from encode\nswitch costume to (value)\nvalue=read from encode\nif <(value) = (Level)> then\n    show\nelse\n    hide\nend\n\nwhen I receive [join game v]\nvalue=Cloud # (player #)\nset [last value v] to (join [A] (value))\nwait (3) seconds\nvalue=Cloud # (player #)\nif <(join [A] (value)) = (last value)> then\n    set [my player # v] to (player #)\nend\n\nwhen flag clicked\nset size to (50) %\n\n@CONNECTING\n\nwhen flag clicked\nforever\n    switch costume to (Connecting)\nend\n\nwhen I receive [begin v]\nhide\n\nwhen flag clicked\nshow\n\n@THUMBNAIL\n\nwhen I receive [stopsignpressed :\( v]\ngo to x: (0) y: (0)\ngo to [front v] layer\nshow\nset y to (350)\npoint in direction (90)\nswitch costume to (dot v)\nset size to (100) %\nswitch costume to (fingernail v)\nrepeat until <(round (y position)) = [5]>\n    change y by (((0) - (y position)) / (7))\nend\n\nwhen flag clicked\nset [ghost v] effect to (100)\n\nwhen [timer v] > (Timer)\nbroadcast (StopSignPressed :\( v)\n\n@(PEN)\n\ndefine Draw Line From (x) (y) To (x2) (y2) Size (size)\npen up\nset pen size to (size)\ngo to x: (x) y: (y)\npen down\ngo to x: (x2) y: (y2)\npen up\n\ndefine Level 1\nset pen color to (#59ff00)\nDraw Line From [0] [-175] To [0] [0] Size [15]\nDraw Line From [-235] [-150] To [235] [-150] Size [10]\nset pen color to (#ce9418)\nDraw Line From [-235] [-175] To [235] [-175] Size [40]\n\nwhen I receive [nextlevel v]\nset [level v] to ((Level) + (1))\n\ndefine Level 2\nset pen color to (#59ff00)\nDraw Line From [-235] [-150] To [235] [-150] Size [10]\nDraw Line From [70] [-175] To [70] [0] Size [15]\nDraw Line From [-100] [-175] To [-100] [0] Size [15]\nDraw Line From [-235] [-150] To [235] [-150] Size [10]\nset pen color to (#ff0000)\nDraw Line From [-90] [-140] To [60] [-140] Size [10]\nset pen color to (#ce9418)\nDraw Line From [-235] [-175] To [235] [-175] Size [40]\n\ndefine Level 3\nset pen color to (#59ff00)\nDraw Line From [-235] [-150] To [235] [-150] Size [10]\nDraw Line From [33] [-175] To [33] [0] Size [15]\nset pen color to (#ce9418)\nDraw Line From [-235] [-175] To [235] [-175] Size [40]\nset pen color to (#ff0000)\nDraw Line From [-60] [-140] To [20] [-140] Size [10]\nDraw Line From [46] [-140] To [235] [-140] Size [10]\nset pen color to (#58ff00)\nDraw Line From [200] [-20] To [150] [-20] Size [10]\n\ndefine Level 4\nset pen color to (#59ff00)\nDraw Line From [0] [-175] To [0] [0] Size [20]\nDraw Line From [-235] [-150] To [235] [-150] Size [10]\nset pen color to (#ce9418)\nDraw Line From [-235] [-175] To [235] [-175] Size [40]\nset pen color to (#58ff00)\nDraw Line From [0] [2] To [150] [2] Size [20]\nDraw Line From [150] [2] To [150] [130] Size [20]\nset pen color to (#ff0000)\nDraw Line From [138] [15] To [138] [134] Size [10]\nset pen color to (#58ff00)\nDraw Line From [-81] [73] To [-151] [73] Size [15]\nDraw Line From [10] [126] To [40] [126] Size [15]\nset pen color to (#ff0000)\nDraw Line From [10] [-140] To [235] [-140] Size [10]\n\ndefine Level 5\nset pen color to (#59ff00)\nDraw Line From [-235] [-150] To [235] [-150] Size [10]\nset pen color to (#ce9418)\nDraw Line From [-235] [-175] To [235] [-175] Size [40]\nset pen color to (#ff0000)\nDraw Line From [-100] [-140] To [235] [-140] Size [10]\nset pen color to (#59ff00)\nDraw Line From [-77] [-85] To [-60] [-85] Size [10]\nDraw Line From [0] [-50] To [-17] [-50] Size [10]\nDraw Line From [29] [-5] To [235] [-5] Size [10]\nset pen color to (#ff0000)\nDraw Line From [109] [3] To [190] [3] Size [10]\n\ndefine Level 6\nset pen color to (#59ff00)\nDraw Line From [159] [-175] To [159] [1] Size [15]\nDraw Line From [-235] [-150] To [235] [-150] Size [10]\nset pen color to (#ce9418)\nDraw Line From [-235] [-175] To [235] [-175] Size [40]\nset pen color to (#ff0000)\nDraw Line From [-60] [-140] To [20] [-140] Size [10]\nDraw Line From [64] [-140] To [150] [-140] Size [10]\nset pen color to (#59ff00)\n\ndefine Level 7\nset pen color to (#ff0000)\nDraw Line From [0] [-175] To [0] [0] Size [15]\nset pen color to (#59ff00)\nDraw Line From [-235] [-150] To [235] [-150] Size [10]\nset pen color to (#ce9418)\nDraw Line From [-235] [-175] To [235] [-175] Size [40]\nset pen color to (#59ff00)\nDraw Line From [-128] [-80] To [-100] [-80] Size [20]\n\ndefine Level 8 \nset pen color to (#59ff00)\nDraw Line From [-235] [-150] To [235] [-150] Size [10]\nset pen color to (#ce9418)\nDraw Line From [120] [-150] To [235] [-150] Size [40]\nDraw Line From [120] [-120] To [235] [-120] Size [40]\nDraw Line From [120] [-100] To [235] [-100] Size [40]\nDraw Line From [120] [-70] To [235] [-70] Size [40]\nDraw Line From [120] [-40] To [235] [-40] Size [40]\nDraw Line From [120] [-20] To [235] [-20] Size [40]\nset pen color to (#ce9418)\nDraw Line From [-235] [-175] To [235] [-175] Size [40]\nset pen color to (#59ff00)\nDraw Line From [-10] [4] To [-235] [4] Size [15]\nDraw Line From [100] [-147] To [100] [0] Size [15]\nDraw Line From [100] [4] To [235] [4] Size [15]\nset pen color to (#ff0000)\nDraw Line From [5] [-150] To [90] [-150] Size [10]\nDraw Line From [-235] [11] To [-100] [11] Size [10]\nDraw Line From [99] [11] To [235] [11] Size [10]\n\nwhen I receive [begin v]\nset [level v] to [1]\nforever\n    if <(Level) = [1]> then\n        erase all\n        Level 1\n    else\n        if <(Level) = [2]> then\n            erase all\n            Level 2\n        else\n            if <(Level) = [3]> then\n                erase all\n                Level 3\n            else\n                if <(Level) = [4]> then\n                    erase all\n                    Level 4\n                else\n                    if <(Level) = [5]> then\n                        erase all\n                        Level 5\n                    else\n                        if <(Level) = [6]> then\n                            erase all\n                            Level 6\n                        else\n                            if <(Level) = [7]> then\n                                erase all\n                                Level 7\n                            else\n                                if <(Level) = [8]> then\n                                    erase all\n                                    Level 8 \n                                else\n                                    if <(Level) = [9]> then\n                                        erase all\n                                        Level 9\n                                    else\n                                        if <(Level) = [10]> then\n                                            erase all\n                                            Level 10 END\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine Level 9\nset pen color to (#59ff00)\nDraw Line From [0] [-175] To [0] [0] Size [15]\nDraw Line From [-150] [175] To [-150] [0] Size [15]\nDraw Line From [150] [175] To [150] [0] Size [15]\nset pen color to (#59ff00)\nDraw Line From [-235] [-150] To [235] [-150] Size [10]\nset pen color to (#ce9418)\nDraw Line From [-235] [-175] To [235] [-175] Size [40]\nset pen color to (#59ff00)\nDraw Line From [-235] [150] To [235] [150] Size [10]\nset pen color to (#ce9418)\nDraw Line From [-235] [175] To [235] [175] Size [40]\nset pen color to (#ff0000)\nDraw Line From [7] [-142] To [150] [-142] Size [10]\n\ndefine Level 10 END\nset pen color to (#59ff00)\nDraw Line From [235] [-175] To [235] [170] Size [15]\nDraw Line From [-235] [-150] To [235] [-150] Size [10]\nset pen color to (#ce9418)\nDraw Line From [-235] [-175] To [235] [-175] Size [40]\n\n