Daylight 2 || Multiplayer platformer

Instructions: Welcome to Daylight 2\nMy first multiplayer platformer is now out\n-arrow keys. IT'S MOBILE FRIENDLY\n-avoid the spikes and the lava \n-try to beat it\n-enjoy!\nBtw , the monsters are still working on \n

@Stage\n\nwhen flag clicked\nforever\n    play sound [Alan Walker - Darkside \(feat v] until done\nend\n\n@Loading\n\nwhen flag clicked\nset size to (100) %\nhide\npoint in direction (90)\nclear graphic effects\ngo to x: (0) y: (-80)\nforever\n    go [forward v] (10) layers\nend\n\nwhen I receive [begin v]\nset [1 v] to [1]\n\nwhen I start as a clone\nset [ghost v] effect to (100)\nrepeat until <(1) = [1]>\n    show\n    repeat (20)\n        turn right (7.5) degrees\n        change [ghost v] effect by (-6)\n        change size by (1)\n    end\n    repeat (20)\n        turn right (7.5) degrees\n        change [ghost v] effect by (6)\n        change size by (-1)\n    end\nend\nforever\n    hide\nend\n\nwhen flag clicked\nrepeat (11)\n    create clone of (_myself_ v)\n    turn right (40) degrees\nend\n\nwhen flag clicked\nset [1 v] to [0]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nwhen flag clicked\nwait (3) seconds\nset [☁ p1 v] to [0]\n\n@Thumbnail\n\nwhen [timer v] > (0.01)\nswitch costume to (thumbnail v)\nset size to (105) %\nset [ghost v] effect to (100)\npoint in direction (90)\ngo to x: (0) y: (-400)\ngo to [front v] layer\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\n    change y by (((0) - (y position)) / (2))\nend\n\nwhen flag clicked\nhide\nswitch costume to (thumbnail v)\nset size to (105) %\nset [ghost v] effect to (100)\ngo to x: (-400) y: (0)\npoint in direction (90)\ngo to [front v] layer\nforever\n    reset timer\nend\n\nchange x by (10)\n\n@Enemies\n\nwhen I receive [restart v]\ndelete this clone\n\ndefine Clone (x) (y)\ngo to x: (x) y: (y)\nset rotation style [all around v]\nswitch costume to (costume1 v)\nset [ghost v] effect to (100)\nshow\npoint in direction (90)\nrepeat (10)\n    change [ghost v] effect by (-10)\n    turn right (5) degrees\nend\nswitch costume to (costume2 v)\ncreate clone of (_myself_ v)\nswitch costume to (costume1 v)\nrepeat (10)\n    change [ghost v] effect by (10)\n    turn right (5) degrees\nend\nhide\n\nwhen I receive [create clone v]\nhide\nClone Create\n\nwhen I start as a clone\nshow\nif <(costume [number v]) = [2]> then\n    set rotation style [left-right v]\n    clear graphic effects\n    set size to (16) %\n    show\n    go [forward v] (11) layers\n    set [enemyx v] to [0]\n    set [enemyy v] to [0]\n    forever\n        change [enemyy v] by (-1)\n        if <([x position v] of [player v]) < ((x position) - (10))> then\n            change [enemyx v] by (-0.4)\n            point in direction (-90)\n        end\n        if <((x position) - (-10)) < ([x position v] of [player v])> then\n            change [enemyx v] by (0.4)\n            point in direction (90)\n        end\n        set [enemyx v] to ((Enemyx) * (0.9))\n        change x by (Enemyx)\n        if <<touching (platform v)?> or <touching (locked v)?>> then\n            change y by (1)\n        end\n        if <<touching (platform v)?> or <touching (locked v)?>> then\n            change y by (1)\n        end\n        if <<touching (platform v)?> or <touching (locked v)?>> then\n            change y by (1)\n        end\n        if <<touching (platform v)?> or <touching (locked v)?>> then\n            change y by (1)\n        end\n        if <<touching (platform v)?> or <touching (locked v)?>> then\n            change y by (-4)\n            change x by ((Enemyx) * (-1))\n        end\n        change y by (Enemyy)\n        if <<touching (platform v)?> or <touching (locked v)?>> then\n            change y by ((Enemyy) - ((Enemyy) * (2)))\n            set [enemyy v] to [0]\n        end\n        change y by (-1)\n        if <<<((y position) - (-120)) < ([x position v] of [player v])> and <touching (platform v)?>> or <<((y position) - (-120)) < ([x position v] of [player v])> and <touching (locked v)?>>> then\n            set [enemyy v] to [14]\n        end\n        change y by (1)\n        switch costume to (costume3 v)\n        create clone of (_myself_ v)\n        switch costume to (costume2 v)\n        if <touching (player v)?> then\n            broadcast (Restart v)\n            broadcast (Create Clone v)\n        end\n        if <touching (lava v)?> then\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n        end\n        if <touching (water v)?> then\n            repeat (20)\n                change [ghost v] effect by (5)\n            end\n            hide\n        end\n    end\nelse\n    show\n    clear graphic effects\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\n    delete this clone\nend\n\nwhen flag clicked\nset [amount v] to [1]\nset [speed v] to [2]\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nforever\n    if <touching (tramps v)?> then\n        set [enemyy v] to [16]\n    end\nend\n\ndefine Clone Create\nif  then\n    delete this clone\nend\nif <<(Level) = [13]> or <<(Level) = [9]> or <(Level) = [10]>>> then\n    Clone [100] [0]\n    Clone [160] [200]\nend\n\nwhen flag clicked\nforever\n    if  then\n        delete this clone\n    end\nend\n\nwhen I receive [restart v]\nbroadcast (Create Clone v)\n\n@Connection Statements\n\nwhen flag clicked\ngo [forward v] (99) layers\nforever\n    switch costume to (Connecting)\nend\n\nwhen I receive [begin v]\nhide\n\nwhen flag clicked\nshow\n\n@Danger\n\nwhen flag clicked\nset [☁ p1 v] to [0]\nset [layers v] to [100000]\nswitch costume to (1 v)\n\nwhen I receive [next level v]\nbroadcast (Restart v)\nchange [level v] by (1)\nnext costume\n\n@Platform\n\nwhen flag clicked\nhide\ngo to [front v] layer\nswitch costume to (1 v)\nwait until <(Level) = [9]>\nbroadcast (Create Clone v)\nwait until <(Level) = [10]>\nbroadcast (Create Clone v)\nwait until <(Level) = [13]>\nbroadcast (Create Clone v)\n\nwhen I receive [next level v]\nif <(costume [number v]) < [17]> then\n    next costume\nelse\n    switch costume to (17 v)\nend\n\nwhen I receive [begin v]\nshow\n\n@Other players\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 <(Players :) = (player #)> then\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) = ([costume # v] of [platform v])> 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 [players : v] to (player #)\nend\n\nwhen flag clicked\nset size to (70) %\n\nset [level v] to [9]\n\n@player\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 (platform v)?> or <touching color (#00ff2c)?>> and <key (up arrow v) pressed?>> or <<<touching (platform 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\ndefine Run Engine\nchange [yv v] by (-0.5)\nif <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<(x position) > (mouse x)> and <mouse down?>>> then\n    change [xv v] by (-0.7)\n    switch costume to (1 v)\nend\nif <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<(mouse x) > (x position)> and <mouse down?>>> then\n    change [xv v] by (0.7)\n    switch costume to (2 v)\nend\nset [xv v] to ((XV) * (0.9))\nchange x by (XV)\nif <<touching (platform v)?> or <touching (locked v)?>> then\n    change y by (2)\n    if <<touching (platform v)?> or <touching (locked v)?>> then\n        change y by (2)\n        if <<touching (platform v)?> or <touching (locked v)?>> then\n            change y by (2)\n            if <<touching (platform v)?> or <touching (locked v)?>> then\n                change y by (2)\n                if <<touching (platform v)?> or <touching (locked v)?>> then\n                    change y by (2)\n                    if <<touching (platform v)?> or <touching (locked v)?>> then\n                        change y by (2)\n                        if <<touching (platform v)?> or <touching (locked v)?>> then\n                            change x by ((XV) * (-2))\n                            change y by (-5)\n                            if <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<mouse down?> and <(mouse y) > ((y position) + (10))>>>> then\n                                if <(XV) > [0]> then\n                                    set [xv v] to [-8]\n                                else\n                                    set [xv v] to [8]\n                                end\n                                set [yv v] to [9]\n                            else\n                                set [xv v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\nchange y by (YV)\nif <<touching (platform v)?> or <touching (locked v)?>> then\n    change y by ((YV) * (-1))\n    set [yv v] to [0]\nend\nchange y by (-0.5)\nif <<<<touching (platform v)?> or <touching (locked v)?>> and <<key (up arrow v) pressed?> or <key (w v) pressed?>>> or <<<touching (platform v)?> or <touching (locked v)?>> and <<(mouse y) > (y position)> and <mouse down?>>>> then\n    switch costume to (4 v)\n    set [yv v] to [9.5]\nend\nchange y by (0.5)\nif <touching (tramps - xv v)?> then\n    set [xv v] to [15]\n    set [yv v] to [7]\nend\nif <<touching (tramps - yv v)?> and <(Level) = [9]>> then\n    set [yv v] to [14]\nelse\n    if <<touching (tramps - yv v)?> and <not <(Level) = [9]>>> then\n        set [yv v] to [12]\n    end\nend\nif <<<<touching (danger v)?> or <touching (saws v)?>> or <touching (lava v)?>> or <touching (enemies v)?>> then\n    broadcast (Restart v)\n    go to x: (X Spawn) y: (Y Spawn)\n    repeat (20)\n        change [ghost v] effect by (5)\n    end\n    repeat (20)\n        change [ghost v] effect by (-5)\n    end\n    set [xv v] to [0]\n    set [yv v] to [0]\nend\nif <(x position) > [233]> then\n    broadcast (Restart v)\n    go to x: (X Spawn) y: (Y Spawn)\n    broadcast (Next Level v)\n    change [level v] by (1)\n    set [xv v] to [0]\n    set [yv v] to [0]\nend\n\nwhen flag clicked\nset [y spawn v] to [-60]\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 (70) %\nset [xv v] to [0]\nset [yv v] to [0]\n\ndefine Run block\nRun Engine\n\nwhen flag clicked\nset [max players v] to [4]\nset [players : v] to [0]\nbroadcast (setups v) and wait\nswitch backdrop to (joining v)\nbroadcast (join game v) and wait\nif <(Players :) > [0]> then\n    set [☁ p1 v] to [2]\nelse\n    set [☁ p1 v] to [3]\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 <(Players :) > [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 ([costume # v] of [platform v]) to encoded\nset cloud # (Players :) to (encodied)\n\nwhen flag clicked\nset [connecting v] to [1]\n\nwhen flag clicked\nforever\n    if <not <<<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 (platform v)?> or <touching color (#00ff2c)?>> and <key (up arrow v) pressed?>> or <<<touching (platform v)?> or <touching color (#00ff2c)?>> and <<(mouse y) > (y position)> and <mouse down?>>>>>>>> then\n        switch costume to (3 v)\n    end\nend\n\nwhen flag clicked\nforever\n    set [timer v] to ((timer) + (1))\nend\n\nwhen [timer v] > (Timer)\nif <(Players :) = [1]> then\n    set [☁ p1 v] to []\n    set [players : v] to []\nelse\n    if <(Players :) = [2]> then\n        set [☁ p2 v] to []\n        set [players : v] to []\n    else\n        if <(Players :) = [3]> then\n            set [☁ p3 v] to []\n            set [players : v] to []\n        else\n            if <(Players :) = [4]> then\n                set [☁ p4 v] to []\n                set [players : v] to []\n            else\n                if <(Players :) = [5]> then\n                    set [☁ p5 v] to []\n                    set [players : v] to []\n                else\n                    if <(Players :) = [6]> then\n                        set [☁ p6 v] to []\n                        set [players : v] to []\n                    else\n                        if <(Players :) = [7]> then\n                            set [☁ p7 v] to []\n                            set [players : v] to []\n                        else\n                            if <(Players :) = [8]> then\n                                set [☁ p8 v] to []\n                                set [players : v] to []\n                            else\n                                if <(Players :) = [9]> then\n                                    set [☁ p9 v] to []\n                                    set [players : v] to []\n                                else\n                                    set [☁ p10 v] to []\n                                    set [players : 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\ndefine Player Script\ngo to x: (-206) y: (-95)\nshow\n\nwhen flag clicked\nhide\n\nwhen I receive [begin v]\nshow\n\nwhen I receive [1 v]\nhide\nwait (1.2) seconds\nshow\ngo to x: (X Spawn) y: (Y Spawn)\n\nwhen I receive [restart v]\ngo to x: (X Spawn) y: (Y Spawn)\n\n@...\n\nwhen flag clicked\nhide\nwait (.01) seconds\ngo to x: (0) y: (0)\nforever\n    if <touching (mouse-pointer v)?> then\n        go to x: (0) y: (0)\n        set [brightness v] effect to (20)\n    else\n        go to x: (0) y: (0)\n        set [brightness v] effect to (0)\n    end\nend\n\nwhen this sprite clicked\nbroadcast (1 v)\nwait (.1) seconds\nbroadcast (Next Level v)\nwait (.1) seconds\nbroadcast (Restart v)\n\nwhen I receive [end v]\nhide\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\n\nwhen flag clicked\nswitch costume to (costume2 v)\n\nwhen flag clicked\nwait (3) seconds\nshow\n\nwhen flag clicked\nforever\n    go to [front v] layer\nend\n\nwhen this sprite clicked\n\nwhen flag clicked\nrepeat until <(Level) = [14]>\n    show\nend\nwait until <(Level) = [14]>\nforever\n    hide\nend\n\n