The Journey - MMO Platformer

Instructions: ------------------The Journey - MMO Platformer--------------\nTravel across the plains with the ARROW KEYS, with an infinite number of players! Please leave feedback.\nInspiration: @KIKOKO_ , @griffpatch .\n@Dexterific17 loved! @Lucasliu9595 loved and faved!\n1.5k views!

@Stage\n\n@Manager\n\nwhen flag clicked\nhide\nbroadcast (start v)\nforever\n    broadcast (tick v)\n    broadcast (cloud tick v)\nend\n\n@Cloud\n\ndefine read string\nset [read v] to []\nforever\n    set [letter v] to (join (letter (i) of (encoded)) (letter ((i) + (1)) of (encoded)))\n    change [i v] by (2)\n    if <(letter) = [00]> then\n        stop [this script v]\n    end\n    set [read v] to (join (read) (item (letter) of [code v]))\nend\n\ndefine begin decoding (str)\nset [encoded v] to (str)\nset [i v] to [1]\n\ndefine read number\nif <(letter ((i) + (1)) of (encoded)) = [0]> then\n    set [read v] to [-]\nelse\n    set [read v] to (letter ((i) + (1)) of (encoded))\nend\nrepeat ((letter (i) of (encoded)) - (1))\n    set [read v] to (join (read) (letter ((i) + (2)) of (encoded)))\n    change [i v] by (1)\nend\nchange [i v] by (2)\n\ndefine encode string (str)\nset [i v] to [1]\nrepeat (length of (str))\n    set [encoded v] to (join (encoded) (item # of (letter (i) of (str)) in [code v]))\n    change [i v] by (1)\nend\nset [encoded v] to (join (encoded) [00])\n\ndefine encode number (num)\nif <(num) < [0]> then\n    set [encoded v] to (join (encoded) (join (length of (num)) (join [0] ([abs v] of (num) ))))\nelse\n    set [encoded v] to (join (encoded) (join (length of (num)) (num)))\nend\n\ndefine initialize cloud data\nset [tick v] to [0]\ndelete all of [buffer v]\ndelete all of [active players v]\ndelete all of [cloud data v]\ndelete all of [pdata v]\nadd (☁ CLOUD1) to [cloud data v]\nadd (☁ CLOUD2) to [cloud data v]\nadd (☁ CLOUD3) to [cloud data v]\nadd (☁ CLOUD4) to [cloud data v]\nadd (☁ CLOUD5) to [cloud data v]\nadd (☁ CLOUD6) to [cloud data v]\nadd (☁ CLOUD7) to [cloud data v]\nadd (☁ CLOUD8) to [cloud data v]\nadd (☁ CLOUD9) to [cloud data v]\n\nwhen I receive [cloud tick v]\ncloud data\n\ndefine cloud data\nchange [tick v] by (1)\nif <((TICK) mod (20)) = [0]> then\n    set [encoded v] to []\n    encode string (username)\n    set [c v] to [1]\n    repeat (40)\n        encode number (item (c) of [buffer v])\n        change [c v] by (1)\n    end\n    encode number (pick random (1) to (99))\n    delete all of [buffer v]\n    set [my var v] to (pick random (1) to (9))\n    if <(my var) = [1]> then\n        set [☁ cloud1 v] to (encoded)\n    else\n        if <(my var) = [2]> then\n            set [☁ cloud2 v] to (encoded)\n        else\n            if <(my var) = [3]> then\n                set [☁ cloud3 v] to (encoded)\n            else\n                if <(my var) = [4]> then\n                    set [☁ cloud4 v] to (encoded)\n                else\n                    if <(my var) = [5]> then\n                        set [☁ cloud5 v] to (encoded)\n                    else\n                        if <(my var) = [6]> then\n                            set [☁ cloud6 v] to (encoded)\n                        else\n                            if <(my var) = [7]> then\n                                set [☁ cloud7 v] to (encoded)\n                            else\n                                if <(my var) = [8]> then\n                                    set [☁ cloud8 v] to (encoded)\n                                else\n                                    set [☁ cloud9 v] to (encoded)\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\nprocess cloud (☁ CLOUD1) [1]\nprocess cloud (☁ CLOUD2) [2]\nprocess cloud (☁ CLOUD3) [3]\nprocess cloud (☁ CLOUD4) [4]\nprocess cloud (☁ CLOUD5) [5]\nprocess cloud (☁ CLOUD6) [6]\nprocess cloud (☁ CLOUD7) [7]\nprocess cloud (☁ CLOUD8) [8]\nprocess cloud (☁ CLOUD9) [9]\n\ndefine process cloud (var) (id)\nif <(join [A] (var)) = (join [A] (item (id) of [cloud data v]))> then\n    stop [this script v]\nend\nreplace item (id) of [cloud data v] with (var)\nbegin decoding (var)\nread string\nset [new clone? v] to [0]\nif <(username) = (read)> then\n    stop [this script v]\nend\nif <not <[active players v] contains (read)?>> then\n    if <[active players v] contains []?> then\n        replace item (item # of [] in [active players v]) of [active players v] with (read)\n    else\n        add (read) to [active players v]\n        set [new clone? v] to [1]\n    end\nend\nset [update v] to [1]\nset [pid v] to (item # of (read) in [active players v])\nupdate list\nrepeat (41)\n    read number\n    update list\nend\nif <(new clone?) = [1]> then\n    create clone of (cloud players v)\nend\n\ndefine update list\nif <(new clone?) = [1]> then\n    add (read) to [pdata v]\nelse\n    replace item ((((pid) - (1)) * (42)) + (update)) of [pdata v] with (read)\nend\nchange [update v] by (1)\n\nwhen I receive [start v]\ninitialize cloud data\n\n@Cloud Players\n\nwhen I start as a clone\nshow\ndelete all of [buffer v]\nset [data v] to (length of [active players v])\nset [b v] to [1]\nset [timeout v] to [0]\nmove data starting at ((((data) - (1)) * (42)) + (2)) to my buffer\n\nwhen I receive [tick v]\ntick\n\ndefine move data starting at (num) to my buffer\nset [last buffer v] to (buffer)\ndelete all of [buffer v]\nset [i v] to (num)\nrepeat (41)\n    add (item (i) of [pdata v]) to [buffer v]\n    change [i v] by (1)\nend\n\ndefine tick\ngo to x: ((item (b) of [buffer v]) - (CAM X)) y: ((item ((b) + (1)) of [buffer v]) - (CAM Y))\nchange [b v] by (2)\nif <(b) > [40]> then\n    set [b v] to [1]\n    move data starting at ((((data) - (1)) * (42)) + (2)) to my buffer\nend\nif <(last buffer) = (buffer)> then\n    change [timeout v] by (1)\nelse\n    set [timeout v] to [0]\nend\nif <(timeout) > [50]> then\n    set [i v] to [1]\n    repeat (42)\n        replace item ((((data) - (1)) * (42)) + (i)) of [pdata v] with []\n        change [i v] by (1)\n    end\n    replace item (data) of [active players v] with []\n    set [timeout v] to [0]\nelse\n    say (item (data) of [active players v])\nend\nif <(item (data) of [active players v]) = []> then\n    hide\nelse\n    show\n    if <<(item (data) of [active players v]) = [homewins]> or <(item (data) of [active players v]) = [homewins_test]>> then\n        switch costume to (costume2 v)\n    else\n        if <(item (data) of [active players v]) = [epic_dude_34]> then\n            switch costume to (costume3 v)\n        else\n            switch costume to (costume1 v)\n        end\n    end\nend\n\n@Thumbnail\n\nwhen I receive [tick v]\ngo to [front v] layer\nset [ghost v] effect to (100)\n\n@Player\n\ndefine tick\nchange [yv v] by (-1)\nchange y by (yv)\nif <touching (level v)?> then\n    if <(yv) < [0]> then\n        repeat until <not <touching (level v)?>>\n            change y by (1)\n        end\n    else\n        repeat until <not <touching (level v)?>>\n            change y by (-1)\n        end\n    end\n    set [yv v] to [0]\nend\nset [xv v] to ((xv) * (0.88))\nchange x by (xv)\nchange y by (-1)\nif <touching color (#3142ff)?> then\n    broadcast (show v)\n    set [cx v] to (PX)\n    set [cy v] to (PY)\nend\nif <touching color (#de00ff)?> then\n    set [yv v] to [20]\nend\nif <<key (up arrow v) pressed?> and <touching (level v)?>> then\n    set [yv v] to [14]\nend\nchange y by (1)\nif <not <touching (level v)?>> then\n    if <key (right arrow v) pressed?> then\n        point in direction (90)\n        change [xv v] by (0.7)\n    end\n    if <key (left arrow v) pressed?> then\n        point in direction (-90)\n        change [xv v] by (-0.7)\n    end\nend\nrepeat until <not <touching (level v)?>>\n    change x by ((xv) * (-1))\n    if <key (up arrow v) pressed?> then\n        set [yv v] to [14]\n        set [xv v] to ((direction) * ((7) / (-90)))\n    end\nend\nchange y by (-1)\nif <<<touching (spikes v)?> or <(PY) < [-200]>> or <touching (saw v)?>> then\n    if <(CX) > [-100]> then\n        set [cam x v] to (CX)\n        set [cam y v] to (CY)\n        set [px v] to (CX)\n        set [py v] to (CY)\n        set [yv v] to [0]\n        set [xv v] to [0]\n        go to x: (0) y: (0)\n    else\n        start me\n    end\nend\nadd (round (PX)) to [buffer v]\nadd (round (PY)) to [buffer v]\nscroll\n\nwhen I receive [tick v]\ntick\n\ndefine start me\nset [cx v] to [-200]\nset [cy v] to [0]\nset [cam x v] to [0]\nset [cam y v] to [0]\nset [px v] to [0]\nset [py v] to [0]\nset [yv v] to [0]\nset [xv v] to [0]\ngo to x: (-200) y: (0)\npoint in direction (90)\nif <(username) = [epic_dude_34]> then\n    switch costume to (2 v)\n    if <<(username) = [homewins]> or <(username) = [homewins_test]>> then\n        switch costume to (3 v)\n    else\n        switch costume to (1 v)\n    end\nend\nscroll\n\ndefine scroll\nchange [px v] by (round ((x position) - ((PX) - (CAM X))))\nchange [py v] by (round ((y position) - ((PY) - (CAM Y))))\nif <<(PX) > [0]> and <[4850] > (PX)>> then\n    change [cam x v] by (round (((PX) - (CAM X)) / (10)))\nend\nchange [cam y v] by (round (((PY) - (CAM Y)) / (10)))\ngo to x: ((PX) - (CAM X)) y: ((PY) - (CAM Y))\nbroadcast (position v)\n\nwhen flag clicked\nstart me\n\n@Level\n\nwhen I receive [position v]\nswitch costume to (big v)\ngo to x: ((sx) - (CAM X)) y: ((sy) - (CAM Y))\nswitch costume to (cost)\n\ndefine clone (sx) (sy) (cost)\nshow\nset [cost v] to (cost)\nset [sx v] to (sx)\nset [sy v] to (sy)\ncreate clone of (_myself_ v)\nhide\n\nwhen I receive [start v]\nclone [0] [0] [1]\nclone [480] [0] [2]\nclone [960] [0] [3]\nclone [1440] [0] [4]\nclone [1920] [0] [5]\nclone [2400] [0] [6]\nclone [2880] [0] [7]\nclone [3360] [0] [8]\nclone [3840] [0] [9]\nclone [4320] [0] [10]\nclone [4800] [0] [11]\n\n@Spikes\n\nwhen I receive [start v]\nclone [0] [0] [1]\nclone [480] [0] [2]\nclone [960] [0] [3]\nclone [1440] [0] [4]\nclone [1920] [0] [5]\nclone [2400] [0] [6]\nclone [3360] [0] [8]\nclone [3840] [0] [9]\nclone [4320] [0] [10]\n\ndefine clone (sx) (sy) (cost)\nshow\nset [cost v] to (cost)\nset [sx v] to (sx)\nset [sy v] to (sy)\ncreate clone of (_myself_ v)\nhide\n\nwhen I receive [position v]\nswitch costume to (big v)\ngo to x: ((sx) - (CAM X)) y: ((sy) - (CAM Y))\nswitch costume to (cost)\n\n@Scenery\n\nwhen I receive [start v]\nclone [0] [0] [1]\nclone [480] [0] [2]\nclone [960] [0] [3]\nclone [1440] [0] [4]\nclone [1920] [0] [5]\nclone [2400] [0] [6]\nclone [2880] [0] [7]\nclone [3360] [0] [8]\nclone [3840] [0] [9]\nclone [4320] [0] [10]\nclone [4800] [0] [11]\n\ndefine clone (sx) (sy) (cost)\nshow\nset [cost v] to (cost)\nset [sx v] to (sx)\nset [sy v] to (sy)\ncreate clone of (_myself_ v)\nhide\n\nwhen I receive [position v]\ngo to [back v] layer\ngo [forward v] (1) layers\nswitch costume to (big v)\ngo to x: (((sx) - (CAM X)) * (1)) y: (((sy) - (CAM Y)) * (1))\nswitch costume to (cost)\n\n@BG\n\nwhen I receive [tick v]\ngo to [back v] layer\ngo to x: (0) y: ((PY) / (-10))\n\n@Flag indicator\n\nwhen I receive [position v]\ngo to x: ((PX) - (CAM X)) y: ((((PY) - (CAM Y)) + (([sin v] of ((timer) * (500)) ) * (5))) + (30))\n\nwhen I receive [show v]\nshow\nwait (1) seconds\nhide\n\nwhen I receive [start v]\nhide\n\n@Trampoline\n\nwhen I receive [start v]\nclone [1440] [0] [1]\n\ndefine clone (sx) (sy) (cost)\nshow\nset [cost v] to (cost)\nset [sx v] to (sx)\nset [sy v] to (sy)\ncreate clone of (_myself_ v)\nhide\n\nwhen I receive [position v]\ngo [forward v] (12) layers\nswitch costume to (big v)\ngo to x: (((sx) - (CAM X)) * (1)) y: (((sy) - (CAM Y)) * (1))\nswitch costume to (cost)\n\n@Saw\n\nwhen I receive [start v]\nhide\nclone [920] [-140] [0.6] [1000]\nclone [2800] [-140] [3] [2900]\nclone [2950] [-140] [2] [3000]\n\ndefine clone (x1) (y1) (speed) (x2)\nset [x v] to (x1)\nset [x1 v] to (x1)\nset [y1 v] to (y1)\nset [speed v] to (speed)\nset [x2 v] to (x2)\nshow\ncreate clone of (_myself_ v)\nhide\n\nwhen I receive [position v]\ngo to [back v] layer\ngo [forward v] (10) layers\ngo to x: ((x) - (CAM X)) y: ((y1) - (CAM Y))\nchange [x v] by (speed)\nif <<(x) > (x2)> or <(x1) > (x)>> then\n    set [speed v] to ((speed) * (-1))\nend\nturn right ((speed) * (3)) degrees\n\n