ScratchLand | Multiplayer Platformer #Games

Instructions: PART 2 \nhttps://scratch.mit.edu/projects/671203495/

@Stage\n\ndefine Connect Sound Effect\nplay sound [Pop v] until done\nwait (0.01) seconds\nplay sound [Pop2 v] until done\nwait (0.01) seconds\nplay sound [Pop3 v] until done\nwait (0.01) seconds\nplay sound [Pop4 v] until done\nwait (0.01) seconds\nplay sound [Pop5 v] until done\nwait (0.01) seconds\nplay sound [Pop6 v] until done\nwait (0.01) seconds\nplay sound [Pop7 v] until done\nwait (0.01) seconds\nplay sound [Pop10 v] until done\nwait (0.01) seconds\n\ndefine Disconnect Sound Effect\nplay sound [Pop10 v] until done\nwait (0.01) seconds\nplay sound [Pop9 v] until done\nwait (0.01) seconds\nplay sound [Pop8 v] until done\nwait (0.01) seconds\nplay sound [Pop7 v] until done\nwait (0.01) seconds\nplay sound [Pop6 v] until done\nwait (0.01) seconds\nplay sound [Pop5 v] until done\nwait (0.01) seconds\nplay sound [Pop4 v] until done\nwait (0.01) seconds\nplay sound [Pop3 v] until done\nwait (0.01) seconds\nplay sound [Pop2 v] until done\nwait (0.01) seconds\nplay sound [Pop v] until done\nwait (0.01) seconds\n\nwhen I receive [connect v]\nConnect Sound Effect\n\nwhen I receive [begin v]\nDisconnect Sound Effect\n\nwhen flag clicked\nset [names v] to [1]\nforever\n    if <key (n v) pressed?> then\n        if <(NAMES) = [1]> then\n            set [names v] to [0]\n        else\n            set [names v] to [1]\n        end\n        wait until <not <key (n v) pressed?>>\n    end\nend\n\n@Assets\n\n@Player\n\nwhen flag clicked\nbroadcast (Setup opponents v) and wait\nset [max players v] to [10]\nset [my player # v] to [0]\nset [yvel v] to [0]\nset [xvel v] to [0]\nhide\nbroadcast (Setup v) and wait\nswitch backdrop to (connecting v)\nbroadcast (Connect v) and wait\ngo to x: (-155) y: (-60)\nif <(MY PLAYER #) > [0]> then\n    switch backdrop to (connected v)\nelse\n    switch backdrop to (full v)\n    wait (2.5) seconds\n    stop [all v]\nend\nwait (1.5) seconds\nswitch backdrop to (rectangle v)\nbroadcast (Begin v)\nshow\n\ndefine Encode (string)\nset [letter # v] to [1]\nrepeat (length of (string))\n    set [encoded v] to (join (encoded) (item # of (letter (letter #) of (string)) in [string code v]))\n    change [letter # v] by (1)\nend\nset [encoded v] to (join (encoded) [00])\n\ndefine Set Cloud (player #) To (val)\nif <(player #) = [1]> then\n    set [☁ p1 v] to (val)\nelse\n    if <(player #) = [2]> then\n        set [☁ p2 v] to (val)\n    else\n        if <(player #) = [3]> then\n            set [☁ p3 v] to (val)\n        else\n            if <(player #) = [4]> then\n                set [☁ p4 v] to (val)\n            else\n                if <(player #) = [5]> then\n                    set [☁ p5 v] to (val)\n                else\n                    if <(player #) = [6]> then\n                        set [☁ p6 v] to (val)\n                    else\n                        if <(player #) = [7]> then\n                            set [☁ p7 v] to (val)\n                        else\n                            if <(player #) = [8]> then\n                                set [☁ p8 v] to (val)\n                            else\n                                if <(player #) = [9]> then\n                                    set [☁ p9 v] to (val)\n                                else\n                                    if <(player #) = [10]> then\n                                        set [☁ p10 v] to (val)\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine Send Cloud Info\nset [encoded v] to []\nEncode (USER)\nEncode (round ((timer) * (10)))\nEncode (x position)\nEncode (y position)\nEncode (LEVEL)\nEncode (costume [number v])\nSet Cloud (MY PLAYER #) To (encoded)\n\ndefine Tick\nchange [xvel v] by (<<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<(mouse x) > (x position)> and <mouse down?>>> - <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<(mouse x) < (x position)> and <mouse down?>>>)\nchange x by (XVel)\nset [xvel v] to ((XVel) * (0.8))\nif <touching (blocks v)?> then\n    change x by ((-1) * (XVel))\n    set [xvel v] to [0]\nend\nchange y by (YVel)\nif <touching (blocks v)?> then\n    change y by ((YVel) * (-1))\n    set [yvel v] to [0]\n    if <touching (blocks v)?> then\n        change y by (1)\n        if <touching (blocks v)?> then\n            change y by (1)\n            if <touching (blocks v)?> then\n                change y by (1)\n                if <touching (blocks v)?> then\n                    change y by (1)\n                    if <touching (blocks v)?> then\n                        change y by (1)\n                        if <touching (blocks v)?> then\n                            change y by (1)\n                        end\n                    end\n                end\n            end\n        end\n    end\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<(mouse y) > (y position)> and <mouse down?>>> then\n        set [yvel v] to [11]\n    end\nend\nchange [yvel v] by (-0.9)\nif <touching (danger v)?> then\n    go to x: (-155) y: (-60)\nend\nif <touching color (#e2e2e2)?> then\n    go to x: (-155) y: (-60)\nend\nif <touching (portal v)?> then\n    go to x: (-155) y: (-60)\n    change [level v] by (1)\nend\n\nwhen I receive [begin v]\nforever\n    Send Cloud Info\n    Tick\nend\n\nwhen I receive [begin v]\nset [chat open v] to [0]\nforever\n    if <key (t v) pressed?> then\n        if <(CHAT OPEN) = [0]> then\n            set [chat open v] to [1]\n            ask [] and wait\n            set [user v] to (item (answer) of [chat v])\n            set [chat open v] to [0]\n            repeat until <(timer) > (length of (USER))>\n                say (USER)\n            end\n            say []\n        else\n            set [chat open v] to [0]\n        end\n    else\n        set [user v] to (username)\n    end\n    if <key (down arrow v) pressed?> then\n        switch costume to (crouch v)\n    else\n        switch costume to (player v)\n    end\nend\n\n@Opponents\n\ndefine Decode Initialization (string)\nset [encoded v] to (string)\nset [letter # v] to [1]\n\ndefine Get Info\nset [value v] to []\nforever\n    set [idx v] to (join (letter (letter #) of (encoded)) (letter ((letter #) + (1)) of (encoded)))\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 [string code v]))\nend\n\ndefine Setup\nhide\nset [offline v] to [100]\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        set [offline v] to [100]\n        hide\n    else\n        Tick\n    end\nend\n\ndefine Cloud Val (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                                    if <(player #) = [10]> then\n                                        set [value v] to (☁ P10)\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [setup v]\nSetup\n\ndefine Tick\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\nDecode Initialization (value)\nGet Info\nif <(NAMES) = [1]> then\n    say (value)\nelse\n    say []\nend\nGet Info\nGet Info\nset x to (value)\nGet Info\nset y to (value)\nGet Info\nif <(value) = (LEVEL)> then\n    set [ghost v] effect to (0)\nelse\n    set [ghost v] effect to (100)\n    say []\nend\nGet Info\nswitch costume to (value)\nCloud Val (Player #)\n\nwhen I receive [connect v]\nCloud Val (Player #)\nset [last value v] to (join [A] (value))\nwait (3) seconds\nCloud Val (Player #)\nif <(join [A] (value)) = (last value)> then\n    set [my player # v] to (Player #)\nend\n\nwhen flag clicked\nset [pp v] to [1]\n\n@Blocks\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nforever\n    switch costume to (LEVEL)\nend\n\nwhen I receive [begin v]\nshow\n\n@Danger\n\nwhen flag clicked\nhide\nset [level v] to [1]\ngo to x: (0) y: (0)\n\nwhen flag clicked\nforever\n    switch costume to (LEVEL)\nend\n\nwhen I receive [begin v]\nshow\n\n@Portal\n\nwhen flag clicked\nhide\nset [level v] to [1]\ngo to x: (0) y: (0)\n\nwhen flag clicked\nforever\n    switch costume to (LEVEL)\nend\n\nwhen I receive [begin v]\nshow\n\n@TN\n\nwhen flag clicked\nset [ghost v] effect to (100)\n\n@Chat\n\nwhen flag clicked\nforever\n    if <(CHAT OPEN) = [1]> then\n        show\n    else\n        hide\n    end\nend\n\n@Please???\n\nwhen flag clicked\nhide\nforever\n    wait (25) seconds\n    switch costume to (costume1 v)\n    go to x: (0) y: (50)\n    show\n    go to [front v] layer\n    repeat (9)\n        change y by (-6)\n    end\n    repeat (5)\n        change y by (3)\n    end\n    repeat (5)\n        change y by (-1)\n    end\n    wait (2) seconds\n    repeat (15)\n        change y by (7)\n    end\n    hide\nend\n\n