Black day II A multiplayer platformer


@Stage\n\n@connecting\n\nif <(length of [cloud list v]) = [0]> then\n\n\ndefine connecttest (@slot)\nif <not <(item (((@PlayerSlot) * (8)) - (4)) of [cloud list v]) = (item (4) of [my list v])>> then\n    wait (1) seconds\n    delete all of [my list v]\n    add (x position) to [my list v]\n    add (y position) to [my list v]\n    add (pick random (999) to (99999)) to [my list v]\n    add (x2) to [my list v]\n    add [0] to [my list v]\n    add (chat.output) to [my list v]\n    add (chat.mode) to [my list v]\n    add [4] to [my list v]\n    broadcast (Tick v) and wait\n    broadcast (Get Data v) and wait\n    if <not <(item (((@PlayerSlot) * (8)) - (4)) of [cloud list v]) = (item (4) of [my list v])>> then\n        broadcast (failed v)\n    end\nend\n\nwhen I receive [initialise  v]\nswitch costume to (connecting v)\nshow\nclear graphic effects\ngo to x: (0) y: (0)\ngo to [front v] layer\nset [full? v] to [False]\nset [kick v] to [False]\nset [moved? v] to [800]\n\ndefine Get Player Slot\nset [@playerslot v] to [0]\nbroadcast (Get Data v) and wait\nset [moved? v] to [0]\ndelete all of [check v]\nif <(length of [cloud list v]) = [0]> then\n    set [@playerslot v] to [1]\nelse\n    repeat (10)\n        change [moved? v] by (1)\n        add (item (((Moved?) * (8)) - (5)) of [cloud list v]) to [check v]\n    end\n    wait (2) seconds\n    broadcast (Get Data v) and wait\n    set [moved? v] to [1]\n    repeat until <(item (((Moved?) * (8)) - (5)) of [cloud list v]) = (item (Moved?) of [check v])>\n        change [moved? v] by (1)\n    end\n    set [@playerslot v] to (Moved?)\n    delete all of [my list v]\n    add (x position) to [my list v]\n    add (y position) to [my list v]\n    add (pick random (999) to (99999)) to [my list v]\n    add (x2) to [my list v]\n    add [0] to [my list v]\n    add (chat.output) to [my list v]\n    add (chat.mode) to [my list v]\n    add [4] to [my list v]\n    broadcast (Tick v) and wait\n    broadcast (Get Data v) and wait\n    connecttest (@PlayerSlot)\nend\n\nwhen flag clicked\nset [started v] to [0]\n\nwhen I receive [start v]\nset [started v] to [1]\n\nwhen I receive [aw v]\nshow\ngo to [front v] layer\nswitch costume to (full2 v)\nstop [all v]\n\nwhen flag clicked\nforever\n    if <(Full?) = [True]> then\n        go to [front v] layer\n        switch costume to (full v)\n        show\n        stop [all v]\n    end\nend\n\nwhen I receive [failed v]\nshow\ngo to [front v] layer\nswitch costume to (failed v)\nstop [all v]\n\nwhen I receive [start teh game that loads bla v]\nbroadcast (Initialise  v) and wait\nGet Player Slot\nset [moved? v] to [600]\nif <not <(@PlayerSlot) > [0]>> then\n    set [full? v] to [True]\nelse\n    wait (1) seconds\n    set [started v] to [1]\n    broadcast (start v)\nend\nhide\nforever\n    broadcast (Tick v) and wait\nend\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\nstop all sounds\n\n@Players\n\ndefine Movement (id)\nset size to (60) %\nshow\nchange [y2 v] by (-1)\nif <(chat.output) > [0]> then\n    say (item ((chat.output) + ((chat.mode) * (9))) of [chat v])\nelse\n    think []\nend\nif <(x position) > [230]> then\n    if <(Level) = [7]> then\n        broadcast (win v)\n    end\n    change [level v] by (1)\n    go to x: (-200) y: (0)\n    set [x2 v] to [0]\n    set [y2 v] to [0]\nend\nif <<<(mouse x) < (x position)> and <mouse down?>> or <key (left arrow v) pressed?>> then\n    set [last.activity v] to (timer)\n    change [x2 v] by (-0.6)\n    switch costume to (2 v)\nelse\n    if <<<(x position) < (mouse x)> and <mouse down?>> or <key (right arrow v) pressed?>> then\n        set [last.activity v] to (timer)\n        change [x2 v] by (0.6)\n        switch costume to (1 v)\n    else\n        switch costume to (3 v)\n    end\nend\nset [x2 v] to ((x2) * (0.9))\nchange x by (x2)\nSave My Data\nif <touching (levels v)?> then\n    change y by (1)\nend\nif <touching (levels v)?> then\n    change y by (1)\nend\nif <touching (levels v)?> then\n    change y by (1)\nend\nif <touching (levels v)?> then\n    change y by (1)\nend\nif <touching (levels v)?> then\n    change y by (-4)\n    change x by ((x2) * (-1))\nend\nchange y by (y2)\nSave My Data\nif <touching (levels v)?> then\n    change y by ((0) - (y2))\n    set [y2 v] to [1]\nend\nchange y by (-1)\nif <<<<(y position) < (mouse y)> and <mouse down?>> or <key (up arrow v) pressed?>> and <touching (levels v)?>> then\n    set [last.activity v] to (timer)\n    set [y2 v] to [15]\nend\nchange y by (1)\nif <(y position) > [180]> then\n    set [y2 v] to [0]\nend\nif <touching (dangearous v)?> then\n    go to x: (-192) y: (0)\n    set [x2 v] to [0]\n    set [y2 v] to [0]\nend\nSave My Data\ngo to [front v] layer\n\nwhen I receive [initialise  v]\nhide\nset [username v] to (username)\nset [clone id v] to [0]\nrepeat (10)\n    change [clone id v] by (1)\n    create clone of (_myself_ v)\nend\n\ndefine (id)\nif <(item (id) of [active check v]) = [Off]> then\n    hide\nelse\n    if <(item (((id) * (8)) - (3)) of [cloud list v]) = (Level)> then\n        switch costume to ((item (((id) * (8)) - (0)) of [cloud list v]) + (4))\n        show\n        set size to (60) %\n        think (item (((id) * (8)) - (4)) of [cloud list v])\n        change x by (((x position) - (item (((id) * (8)) - (7)) of [cloud list v])) / (-2.5))\n        change y by (((y position) - (item (((id) * (8)) - (6)) of [cloud list v])) / (-2.5))\n        if <(item (((id) * (8)) - (2)) of [cloud list v]) > [0]> then\n            say (item ((item (((id) * (8)) - (2)) of [cloud list v]) + ((item (((id) * (8)) - (1)) of [cloud list v]) * (9))) of [chat v])\n        end\n    else\n        go to x: (item (((id) * (8)) - (7)) of [cloud list v]) y: (item (((id) * (8)) - (6)) of [cloud list v])\n        hide\n    end\nend\n\ndefine Save My Data\ndelete all of [my list v]\nadd (x position) to [my list v]\nadd (y position) to [my list v]\nadd (pick random (999) to (99999)) to [my list v]\nadd (username) to [my list v]\nadd (Level) to [my list v]\nadd (chat.output) to [my list v]\nadd (chat.mode) to [my list v]\nadd (costume [name v]) to [my list v]\n\ndefine Tick\nif <(Clone ID) = (@PlayerSlot)> then\n    Movement (Clone ID)\nelse\n    (Clone ID)\nend\n\nwhen I start as a clone\nwait until <(started) = [1]>\nif <not <(Clone ID) = (@PlayerSlot)>> then\n    go to x: (item (((Clone ID) * (8)) - (7)) of [cloud list v]) y: (item (((Clone ID) * (8)) - (6)) of [cloud list v])\nend\nif <(Clone ID) = (@PlayerSlot)> then\n    go to x: (-192) y: (0)\nend\nforever\n    Tick\nend\n\n\n\nwhen I receive [start v]\nshow variable [players v]\n\nwhen flag clicked\nhide variable [players v]\n\nwhen flag clicked\nset [chat v] to [0]\nset [chat1 v] to [1: Hi!]\nset [chat2 v] to [2: Hello!]\nset [chat3 v] to [3: How are you?]\nset [chat4 v] to [4: I'm fine, thanks!]\nset [chat5 v] to [5: I'm fine! What about you?]\nset [chat6 v] to [6: Not so good :\(]\nset [chat7 v] to [7: How to beat this level?]\nset [chat8 v] to [8: Come with me!]\nset [chat9 v] to [9: Wait for me!]\nset [chat10 v] to [A: Heyo!]\nset [chat11 v] to [B: OK]\ndelete all of [chat v]\nadd [Hi!] to [chat v]\nadd [Hello!] to [chat v]\nadd [How are you?] to [chat v]\nadd [I'm fine, thanks!] to [chat v]\nadd [I'm fine! What about you?] to [chat v]\nadd [Not so good :\(] to [chat v]\nadd [How to beat this level?] to [chat v]\nadd [Come with me!] to [chat v]\nadd [Wait for me!] to [chat v]\nadd [Heyo!] to [chat v]\nadd [OK] to [chat v]\n\nwhen [t v] key pressed\nif <(chat) = [1]> then\n    set [chat v] to [0]\nelse\n    set [chat v] to [1]\nend\n\nwhen I receive [start v]\nforever\n    if <(chat) = [1]> then\n        show variable [chat1 v]\n        show variable [chat2 v]\n        show variable [chat3 v]\n        show variable [chat4 v]\n        show variable [chat5 v]\n        show variable [chat6 v]\n        show variable [chat7 v]\n        show variable [chat8 v]\n        show variable [chat9 v]\n        show variable [chat10 v]\n        show variable [chat11 v]\n        if <key (1 v) pressed?> then\n            hide vars\n            set [chat.mode v] to [0]\n            set [chat.output v] to [1]\n            wait (2) seconds\n            set [chat.output v] to [0]\n        end\n        if <key (2 v) pressed?> then\n            hide vars\n            set [chat.mode v] to [0]\n            set [chat.output v] to [2]\n            wait (2) seconds\n            set [chat.output v] to [0]\n        end\n        if <key (3 v) pressed?> then\n            hide vars\n            set [chat.mode v] to [0]\n            set [chat.output v] to [3]\n            wait (2) seconds\n            set [chat.output v] to [0]\n        end\n        if <key (4 v) pressed?> then\n            hide vars\n            set [chat.mode v] to [0]\n            set [chat.output v] to [4]\n            wait (2) seconds\n            set [chat.output v] to [0]\n        end\n        if <key (5 v) pressed?> then\n            hide vars\n            set [chat.mode v] to [0]\n            set [chat.output v] to [5]\n            wait (2) seconds\n            set [chat.output v] to [0]\n        end\n        if <key (6 v) pressed?> then\n            hide vars\n            set [chat.mode v] to [0]\n            set [chat.output v] to [6]\n            wait (2) seconds\n            set [chat.output v] to [0]\n        end\n        if <key (7 v) pressed?> then\n            hide vars\n            set [chat.mode v] to [0]\n            set [chat.output v] to [7]\n            wait (2) seconds\n            set [chat.output v] to [0]\n        end\n        if <key (8 v) pressed?> then\n            hide vars\n            set [chat.mode v] to [0]\n            set [chat.output v] to [8]\n            wait (2) seconds\n            set [chat.output v] to [0]\n        end\n        if <key (9 v) pressed?> then\n            hide vars\n            set [chat.mode v] to [0]\n            set [chat.output v] to [9]\n            wait (2) seconds\n            set [chat.output v] to [0]\n        end\n        if <key (a v) pressed?> then\n            hide vars\n            set [chat.mode v] to [1]\n            set [chat.output v] to [1]\n            wait (2) seconds\n            set [chat.output v] to [0]\n        end\n        if <key (b v) pressed?> then\n            hide vars\n            set [chat.mode v] to [1]\n            set [chat.output v] to [2]\n            wait (2) seconds\n            set [chat.output v] to [0]\n        end\n    else\n        hide vars\n    end\nend\n\ndefine hide vars\nset [chat v] to [0]\nhide variable [chat1 v]\nhide variable [chat2 v]\nhide variable [chat3 v]\nhide variable [chat4 v]\nhide variable [chat5 v]\nhide variable [chat6 v]\nhide variable [chat7 v]\nhide variable [chat8 v]\nhide variable [chat9 v]\nhide variable [chat10 v]\nhide variable [chat11 v]\n\nwhen flag clicked\nset [chat.output v] to [0]\n\nwhen I receive [start v]\nwait (4) seconds\nforever\n    if <not <(item (((@PlayerSlot) * (8)) - (4)) of [cloud list v]) = (item (4) of [my list v])>> then\n        broadcast (aw v)\n        stop [all v]\n    end\nend\n\nwhen flag clicked\nset [last.activity v] to [1]\n\nwhen flag clicked\nset [chat.output v] to [0]\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\nstop all sounds\n\n@levels\n\nwhen I receive [start v]\nshow\ngo to [front v] layer\nforever\n    play sound [Vexento - Never Give Up v] until done\nend\n\nwhen I receive [start v]\nset [level v] to [1]\n\nwhen I receive [start v]\nforever\n    switch costume to (Level)\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\nstop all sounds\n\n@Cloud\n\ndefine Decode (data)\ndelete all of [cloud list v]\nset [output v] to []\nset [i v] to [0]\nrepeat ((length of (data)) / (2))\n    change [i v] by (2)\n    switch costume to (join (letter ((I) - (1)) of (data)) (letter (I) of (data)))\n    if <(costume [name v]) = [~]> then\n        add (Output) to [cloud list v]\n        set [output v] to []\n    else\n        set [output v] to (join (Output) (costume [name v]))\n    end\nend\n\ndefine Encode\nset [output v] to []\nset [n v] to [0]\nrepeat (length of [my list v])\n    set [i v] to [0]\n    change [n v] by (1)\n    repeat (length of (item (n) of [my list v]))\n        change [i v] by (1)\n        switch costume to (letter (I) of (item (n) of [my list v]))\n        if <(costume [number v]) < [10]> then\n            set [output v] to (join (Output) (join [0] (costume [number v])))\n        else\n            set [output v] to (join (Output) (costume [number v]))\n        end\n    end\n    set [output v] to (join (Output) [53])\nend\n\ndefine Update Players List (id)\nif <(id) = [1]> then\n    set [player list v] to [0]\n    delete all of [check v]\n    repeat (10)\n        change [player list v] by (1)\n        add (item (((Player List) * (8)) - (5)) of [cloud list v]) to [check v]\n    end\nelse\n    if <(id) = [2]> then\n        set [player list v] to [0]\n        repeat (10)\n            change [player list v] by (1)\n            if <not <(@PlayerSlot) = (Player List)>> then\n                if <(item (Player List) of [check v]) = (item (((Player List) * (8)) - (5)) of [cloud list v])> then\n                    replace item (Player List) of [active check v] with [Off]\n                else\n                    replace item (Player List) of [active check v] with [On]\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [initialise  v]\ndelete all of [active check v]\nrepeat (10)\n    add [off] to [active check v]\nend\n\nwhen I receive [start v]\nforever\n    Update Players List [1]\n    wait (0.3) seconds\n    Update Players List [2]\nend\n\nwhen I receive [get data v]\nDecode Data\n\ndefine Save Data (id)\nEncode\nif <(timer) < ((last.activity) + (60))> then\n    if <(id) = [1]> then\n        set [☁ p1 v] to (Output)\n    else\n        if <(id) = [2]> then\n            set [☁ p2 v] to (Output)\n        else\n            if <(id) = [3]> then\n                set [☁ p3 v] to (Output)\n            else\n                if <(id) = [4]> then\n                    set [☁ p4 v] to (Output)\n                else\n                    if <(id) = [5]> then\n                        set [☁ p5 v] to (Output)\n                    else\n                        if <(id) = [6]> then\n                            set [☁ p6 v] to (Output)\n                        else\n                            if <(id) = [7]> then\n                                set [☁ p7 v] to (Output)\n                            else\n                                if <(id) = [8]> then\n                                    set [☁ p8 v] to (Output)\n                                else\n                                    if <(id) = [9]> then\n                                        set [☁ p9 v] to (Output)\n                                    else\n                                        if <(id) = [10]> then\n                                            set [☁ p10 v] to (Output)\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [tick v]\nDecode Data\nSave Data (@PlayerSlot)\nDetermine Players\n\ndefine Decode Data\nDecode (join (☁ P1) (join (☁ P2) (join (☁ P3) (join (☁ P4) (join (☁ P5) (join (☁ P6) (join (☁ P7) (join (☁ P8) (join (☁ P9) (☁ P10))))))))))\n\ndefine Determine Players\nset [players v] to [1]\nset [i v] to [0]\nrepeat (10)\n    change [i v] by (1)\n    if <(item (I) of [active check v]) = [On]> then\n        change [players v] by (1)\n    end\nend\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\nstop all sounds\n\n@Sprite2\n\nwhen I receive [start v]\nstop [other scripts in sprite v]\nhide\n\nwhen I receive [start teh game that loads bla v]\nshow\nset size to (20) %\nforever\n    turn right (15) degrees\n    go to [front v] layer\n    change size by (((size) - (90)) / (-5))\nend\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\nstop all sounds\n\n@something\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nwait (1) seconds\nif <(Players) = [1]> then\n    go to x: (0) y: (100)\n    switch costume to (alone v)\n    show\n    repeat (100)\n        set y to ((y position) / (10))\n    end\n    hide\nend\n\nwhen I receive [start v]\nwait (2) seconds\nset [pp v] to (Players)\nforever\n    if <(pp) < (Players)> then\n        wait (2) seconds\n        if <(pp) < (Players)> then\n            broadcast (joined v)\n            go to x: (0) y: (100)\n            set [pp v] to (Players)\n            switch costume to (joined v)\n            show\n            repeat (100)\n                set y to ((y position) / (10))\n            end\n            hide\n        end\n    end\n    if <(Players) < (pp)> then\n        wait (2) seconds\n        if <(Players) < (pp)> then\n            broadcast (left v)\n            go to x: (0) y: (100)\n            set [pp v] to (Players)\n            switch costume to (left v)\n            show\n            repeat (100)\n                set y to ((y position) / (10))\n            end\n            hide\n        end\n    end\nend\n\nwhen I receive [start v]\nwait (1) seconds\nset voice to (tenor v)::tts\nspeak (username)::tts\nspeak [Your player ID is]::tts\nspeak (@PlayerSlot)::tts\n\nwhen I receive [joined v]\nspeak [A player has joined the game.]::tts\n\nwhen I receive [left v]\nspeak [A player has left the game.]::tts\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\nstop all sounds\n\n@Thumbnail n stuff\n\nwhen I receive [win v]\nswitch costume to (end v)\nshow\ngo to x: (0) y: (-100)\nset [time v] to (timer)\nforever\n    show variable [time v]\n    hide variable [players v]\n    go to [front v] layer\n    change y by ((y position) / (-10))\nend\n\nwhen flag clicked\nhide variable [time v]\n\nwhen flag clicked\nhide\nset [brightness v] effect to (100)\n\nwhen I receive [win v]\nrepeat (25)\n    change [brightness v] effect by (-4)\nend\n\nwhen I receive [win v]\nwait (0.1) seconds\nstart sound [YOU WON! v]\n\nwhen I receive [start v]\nreset timer\n\ngo to [front v] layer\n\n@Dangearous\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nshow\nforever\n    switch costume to (Level)\n    go to x: (0) y: (0)\nend\n\n@intro\n\nwhen flag clicked\npoint in direction (90)\nclear graphic effects\ngo to x: (0) y: (0)\nhide\nswitch costume to (back v)\ncreate clone of (_myself_ v)\nwait (.1) seconds\nswitch costume to (logo v)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nif <(costume [number v]) = [2]> then\n    go to x: (0) y: (0)\n    show\n    forever\n        repeat (10)\n            change [brightness v] effect by (1)\n        end\n        repeat (10)\n            change [brightness v] effect by (-1)\n        end\n    end\nend\n\nwhen I start as a clone\nif <(costume [number v]) = [1]> then\n    go to x: (0) y: (0)\n    set size to (200) %\n    show\n    set [ghost v] effect to (100)\n    repeat (20)\n        change size by (-5)\n        change [ghost v] effect by (-5)\n    end\n    forever\n        go to [front v] layer\n    end\nend\n\nwhen flag clicked\nplay sound [avengers v] until done\nstart sound [Crunch v]\nswitch costume to (block v)\ncreate clone of (_myself_ v)\nplay sound [Revenge v] until done\nwait (.5) seconds\nbroadcast (Start teh game that loads bla v)\n\nwhen I start as a clone\nif <(costume [number v]) = [3]> then\n    go to x: (0) y: (0)\n    show\nend\n\nwhen I start as a clone\nif <(costume [number v]) = [1]> then\n    wait (2) seconds\n    forever\n        repeat (10)\n            change y by (1)\n        end\n        repeat (10)\n            change y by (-1)\n        end\n    end\nend\n\nwhen I start as a clone\nif <(costume [number v]) = [3]> then\n    go to x: (0) y: (0)\n    show\n    forever\n        repeat (10)\n            change y by (1)\n        end\n        repeat (10)\n            change y by (-1)\n        end\n    end\nend\n\nwhen I start as a clone\nif <(costume [number v]) = [1]> then\n    wait (2) seconds\n    forever\n        repeat (10)\n            turn right (1) degrees\n        end\n        repeat (20)\n            turn left (1) degrees\n        end\n        repeat (10)\n            turn right (1) degrees\n        end\n    end\nend\n\nwhen I receive [start teh game that loads bla v]\ndelete this clone\n\n@Shadow\n\nwhen I receive [start v]\nshow\nforever\n    set [ghost v] effect to (80)\n    switch costume to (Level)\n    go to x: (0) y: (0)\nend\n\nwhen flag clicked\nhide\n\n@Sun\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\ngo to x: (243) y: (261)\nshow\n\n