"Connected" A 2 Player Platformer

Instructions: For a contest.\nFull game: https://scratch.mit.edu/projects/216061061/\n\nMore cool stuff:\nhttps://scratch.mit.edu/projects/910042742/

@Stage\n\nwhen I receive [next section v]\nchange [section v] by (1)\nswitch backdrop to (Section)\n\nwhen flag clicked\nset [p1 cooldown v] to [0]\nset [p2 cooldown v] to [0]\nset [section v] to [1]\nswitch backdrop to (Section)\n\n@Player1\n\ndefine Physics+Moving\nif <key (d v) pressed?> then\n    change [xv v] by (1)\n    next costume\n    point in direction (90)\nend\nif <key (a v) pressed?> then\n    change [xv v] by (-1)\n    next costume\n    point in direction (-90)\nend\nset [xv v] to ((Xv) * (0.75))\nchange x by (Xv)\nif <touching color (#000000)?> then\n    change y by (1)\n    if <touching color (#000000)?> then\n        change y by (1)\n        if <touching color (#000000)?> then\n            change y by (1)\n            if <touching color (#000000)?> then\n                change y by (1)\n                if <touching color (#000000)?> then\n                    change y by (1)\n                    if <touching color (#000000)?> then\n                        change x by ((Xv) * (-1))\n                        change y by (-5)\n                        if <key (w v) pressed?> then\n                            if <(Xv) > [0]> then\n                                set [xv v] to [-1]\n                            else\n                                set [xv v] to [1]\n                            end\n                            set [yv v] to [5]\n                        else\n                            set [xv v] to [0]\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\nchange [yv v] by (-1)\nchange y by (Yv)\nif <touching color (#000000)?> then\n    change y by ((Yv) * (-1))\n    set [yv v] to [0]\nend\nchange y by (-1)\nif <touching color (#000000)?> then\n    if <key (w v) pressed?> then\n        set [yv v] to [10]\n    end\nend\nif <key (s v) pressed?> then\n    if <(P1 Cooldown) = [0]> then\n        broadcast (P1 Ability v)\n        point towards (player2 v)\n        move ((distance to [player2 v]) / (2)) steps\n    end\nend\nchange y by (1)\nif <(y position) < [-170]> then\n    Respawn at x: (Enter X) y: (Enter Y)\nend\nif <(x position) > [235]> then\n    Respawn at x: (-230) y: (y position)\n    broadcast (Next Section v)\n    set [enter x v] to (x position)\n    set [enter y v] to (y position)\nend\n\ndefine None\ngo to x: (x) y: (y)\nset [xv v] to [0]\nset [yv v] to [0]\n\nwhen flag clicked\nRespawn at x: (-230) y: (-160)\nset [enter x v] to (x position)\nset [enter y v] to (y position)\nset [xv v] to [0]\nset [yv v] to [0]\nforever\n    Physics+Moving\nend\n\nwhen I receive [p1 ability v]\nset [p1 cooldown v] to [10]\nrepeat (10)\n    wait (0.25) seconds\n    change [p1 cooldown v] by (-1)\nend\n\nwhen I receive [next section v]\nRespawn at x: (-230) y: (-160)\nset [enter x v] to (x position)\nset [enter y v] to (y position)\n\nwhen [r v] key pressed\nRespawn at x: (-230) y: (-160)\nset [xv v] to [0]\nset [yv v] to [0]\n\n@Player2\n\ndefine Physics+Moving\nif <key (right arrow v) pressed?> then\n    change [xv v] by (1)\n    next costume\n    point in direction (90)\nend\nif <key (left arrow v) pressed?> then\n    change [xv v] by (-1)\n    next costume\n    point in direction (-90)\nend\nset [xv v] to ((Xv) * (0.75))\nchange x by (Xv)\nif <touching color (#000000)?> then\n    change y by (-1)\n    if <touching color (#000000)?> then\n        change y by (-1)\n        if <touching color (#000000)?> then\n            change y by (-1)\n            if <touching color (#000000)?> then\n                change y by (-1)\n                if <touching color (#000000)?> then\n                    change y by (-1)\n                    if <touching color (#000000)?> then\n                        change x by ((Xv) * (-1))\n                        change y by (5)\n                        if <key (up arrow v) pressed?> then\n                            if <(Xv) > [0]> then\n                                set [xv v] to [-1]\n                            else\n                                set [xv v] to [1]\n                            end\n                            set [yv v] to [-5]\n                        else\n                            set [xv v] to [0]\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\nchange [yv v] by (1)\nchange y by (Yv)\nif <touching color (#000000)?> then\n    change y by ((Yv) * (-1))\n    set [yv v] to [0]\nend\nchange y by (1)\nif <touching color (#000000)?> then\n    if <key (up arrow v) pressed?> then\n        set [yv v] to [-10]\n    end\nend\nif <key (down arrow v) pressed?> then\n    if <(P2 Cooldown) = [0]> then\n        broadcast (P2 Ability v)\n        point towards (player1 v)\n        move ((distance to [player1 v]) / (2)) steps\n    end\nend\nchange y by (-1)\nif <(y position) > [170]> then\n    Respawn at x: (Enter X) y: (Enter Y)\nend\nif <(x position) > [235]> then\n    broadcast (Next Section v)\nend\n\ndefine None\ngo to x: (x) y: (y)\nset [xv v] to [0]\nset [yv v] to [0]\n\nwhen flag clicked\nRespawn at x: (-230) y: (160)\nset [enter x v] to (x position)\nset [enter y v] to (y position)\nset [xv v] to [0]\nset [yv v] to [0]\nforever\n    Physics+Moving\nend\n\nwhen I receive [p2 ability v]\nset [p2 cooldown v] to [10]\nrepeat (10)\n    wait (0.25) seconds\n    change [p2 cooldown v] by (-1)\nend\n\nwhen I receive [next section v]\nRespawn at x: (-230) y: (160)\nset [enter x v] to (x position)\nset [enter y v] to (y position)\n\nwhen [r v] key pressed\nRespawn at x: (-230) y: (160)\nset [xv v] to [0]\nset [yv v] to [0]\n\n@P1\n\nwhen flag clicked\nforever\n    go to (player1 v)\nend\n\n@P2\n\nwhen flag clicked\nforever\n    go to (player2 v)\nend\n\n@Connection\n\nwhen flag clicked\nerase all\nforever\n    erase all\n    set pen color to (#b2b2b2)\n    set pen size to (3)\n    pen up\n    go to (player1 v)\n    pen down\n    go to (player2 v)\nend\n\n@Thumbnail\n\nwhen flag clicked\nforever\n    go to x: (0) y: (0)\n    set [ghost v] effect to (100)\n    go to [front v] layer\nend\n\n