Mine - A Platformer ☁Multiplayer☁

Instructions: Arrow keys or WASD to move.

@Stage\n\nwhen flag clicked\nforever\n    if <(Level) = [14]> then\n        switch backdrop to (backdrop2 v)\n    else\n        switch backdrop to (backdrop1 v)\n    end\nend\n\n@Player\n\ndefine Wall\nif <touching (ground v)?> then\n    if <touching (ground v)?> then\n        change y by (1)\n        if <touching (ground v)?> then\n            change y by (1)\n            if <touching (ground v)?> then\n                change y by (1)\n                if <touching (ground v)?> then\n                    change y by (1)\n                    if <touching (ground v)?> then\n                        change x by (() - (xv))\n                        if <(xv) < [0]> then\n                            change x by (1)\n                        else\n                            change x by (-1)\n                        end\n                        change y by (-5)\n                    end\n                    if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                        Bounce\n                    else\n                        set [xv v] to [0]\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine Bounce\nif <(xv) < [0]> then\n    set [xv v] to [5]\nelse\n    set [xv v] to [-5]\nend\nset [yv v] to [10]\n\ndefine Ground\nif <touching (ground v)?> then\n    change y by (() - (yv))\n    set [yv v] to [0]\nend\nchange y by (-1)\nif <touching (ground v)?> then\n    if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n        set [yv v] to [12]\n    end\nend\nchange y by (1)\n\nwhen flag clicked\nhide\nset [max players v] to [4]\nset [my player # v] to [0]\nbroadcast (Setup - Other players v) and wait\nbroadcast (Connecting v)\nbroadcast (Join Game v) and wait\nif <(My Player #) > [0]> then\n    broadcast (Joined v)\n    wait (1) seconds\nelse\n    broadcast (Full v)\nend\nbroadcast (Begin v)\n\ndefine Write (val) to encoded\nset [letter # v] to [1]\nrepeat (length of (val))\n    set [encoded v] to (join (Encoded) (item # of (letter (Letter #) of (val)) in [code v]))\n    change [letter # v] by (1)\nend\nset [encoded v] to (join (Encoded) [00])\n\nwhen I receive [begin v]\nforever\n    if <(My Player #) > [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            set [☁ p4 v] to (value)\n        end\n    end\nend\n\nwhen I receive [begin v]\ngo to x: (-140) y: (-50)\npoint in direction (90)\nshow\nset [yv v] to [0]\nset [xv v] to [0]\nset [level v] to [1]\nforever\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        change [xv v] by (1)\n        point in direction (90)\n    end\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        change [xv v] by (-1)\n        point in direction (-90)\n    end\n    set [xv v] to ((xv) * (0.85))\n    change x by (xv)\n    Wall\n    change [yv v] by (-1)\n    change y by (yv)\n    Ground\n    if <<touching (spikes v)?> or <touching (spinning spikes v)?>> then\n        go to x: (-150) y: (-60)\n    end\n    if <<touching (trampoline v)?> or <touching (trampoline 2 v)?>> then\n        set [yv v] to [15]\n    end\n    if <touching (finish v)?> then\n        go to x: (-150) y: (-60)\n        change [level v] by (1)\n        broadcast (New Level v)\n    end\nend\n\ndefine Send Cloud Data\nset [encoded v] to []\nWrite (username) to encoded\nWrite (round ((timer) * (10))) to encoded\nWrite (x position) to encoded\nWrite (y position) to encoded\nWrite (direction) to encoded\nWrite (Level) to encoded\nSet cloud # (My Player #) to (Encoded)\n\n@Other players\n\ndefine Begin decode of (encoded)\nset [encoded v] to (encoded)\nset [letter # v] to [1]\n\ndefine Value = Read from encoded\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 [code v]))\nend\n\ndefine Setup Players\nset [color v] effect to (85)\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 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            set [value v] to (☁ P4)\n        end\n    end\nend\n\nwhen I receive [setup - other players v]\nSetup Players\n\ndefine Tick\nif <(join [A] (Value)) = (Last Vaule)> then\n    change [offline v] by (1)\n    if <(Offline) = [100]> then\n        hide\n    end\nelse\n    set [last vaule 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 encoded\nsay (join (Player #) (join [: ] (Value)))\nValue = Read from encoded\nValue = Read from encoded\nset x to (Value)\nValue = Read from encoded\nset y to (Value)\nValue = Read from encoded\npoint in direction (Value)\nValue = Read from encoded\nif <(Value) = (Level)> then\n    show\nelse\n    hide\nend\nValue = Cloud # (Player #)\n\nwhen I receive [join game v]\nValue = Cloud # (Player #)\nset [last vaule v] to (join [A] (Value))\nwait (3) seconds\nValue = Cloud # (Player #)\nif <(join [A] (Value)) = (Last Vaule)> then\n    set [my player # v] to (Player #)\nend\n\n@Ground\n\nwhen flag clicked\ngo to [back v] layer\nforever\n    switch costume to (Level)\n    go to x: (0) y: (0)\nend\n\n@Spikes\n\nwhen flag clicked\nforever\n    switch costume to (Level)\n    go to x: (0) y: (0)\nend\n\nwhen flag clicked\nwait (0) seconds\ngo to [back v] layer\n\n@Arrows\n\nwhen flag clicked\nhide\nforever\n    go to x: (0) y: (0)\n    go to [back v] layer\n    if <<(Level) = [4]> or <(Level) = [13]>> then\n        show\n        if <(Level) = [4]> then\n            switch costume to (level 4 v)\n        end\n        if <(Level) = [13]> then\n            switch costume to (level 13 v)\n        end\n    else\n        hide\n    end\nend\n\n@Finish\n\nwhen flag clicked\npoint in direction (90)\nshow\nforever\n    if <(Level) = [14]> then\n        hide\n    else\n        show\n        if <not <<(Level) = [9]> or <<(Level) = [12]> or <(Level) = [13]>>>> then\n            go to x: (140) y: (-82)\n        else\n            if <<(Level) = [9]> or <(Level) = [12]>> then\n                go to x: (140) y: (-50)\n            else\n                go to x: (180) y: (-82)\n            end\n        end\n        turn right (0.2) degrees\n    end\nend\n\n@Spinning Spikes\n\nwhen flag clicked\nforever\n    if <not <<(Level) = [6]> or <(Level) = [7]>>> then\n        hide\n    else\n        show\n        go to [back v] layer\n        if <(Level) = [6]> then\n            go to x: (0) y: (-120)\n        end\n        if <(Level) = [7]> then\n            go to x: (20) y: (70)\n        end\n        turn right (3) degrees\n    end\nend\n\n@Trampoline\n\nwhen flag clicked\nswitch costume to (costume1 v)\nforever\n    if <not <<(Level) = [6]> or <<(Level) = [7]> or <<(Level) = [8]> or <<(Level) = [9]> or <(Level) = [11]>>>>>> then\n        hide\n    else\n        show\n        if <(Level) = [6]> then\n            go to x: (-75) y: (-110)\n        end\n        if <(Level) = [7]> then\n            go to x: (-45) y: (75)\n        end\n        if <(Level) = [8]> then\n            go to x: (-6) y: (-75)\n        end\n        if <(Level) = [9]> then\n            go to x: (-110) y: (-110)\n        end\n        if <(Level) = [11]> then\n            go to x: (-65) y: (-110)\n        end\n    end\nend\n\nwhen I receive [new level v]\nswitch costume to (costume1 v)\n\nwhen flag clicked\nforever\n    if <touching (player v)?> then\n        switch costume to (costume1 v)\n        repeat (6)\n            next costume\n        end\n        switch costume to (costume1 v)\n        wait until <not <touching (player v)?>>\n    end\nend\n\n@Trampoline 2\n\nwhen flag clicked\nswitch costume to (costume1 v)\nforever\n    if <not <<(Level) = [9]> or <(Level) = [11]>>> then\n        hide\n    else\n        show\n        if <(Level) = [9]> then\n            go to x: (-65) y: (-14)\n        end\n        if <(Level) = [11]> then\n            go to x: (65) y: (-110)\n        end\n    end\nend\n\nwhen I receive [new level v]\nswitch costume to (costume1 v)\n\nwhen flag clicked\nforever\n    if <touching (player v)?> then\n        switch costume to (costume1 v)\n        repeat (6)\n            next costume\n        end\n        switch costume to (costume1 v)\n        wait until <not <touching (player v)?>>\n    end\nend\n\n@Like\n\nwhen flag clicked\npoint in direction (75)\nforever\n    if <(Level) = [14]> then\n        show\n        go to x: (0) y: (0)\n        repeat (2)\n            turn right (0.5) degrees\n        end\n        repeat (2)\n            turn right (1) degrees\n        end\n        repeat (2)\n            turn right (1.5) degrees\n        end\n        repeat (2)\n            turn right (2) degrees\n        end\n        repeat (2)\n            turn right (2.5) degrees\n        end\n        repeat (2)\n            turn right (2) degrees\n        end\n        repeat (2)\n            turn right (1.5) degrees\n        end\n        repeat (2)\n            turn right (1) degrees\n        end\n        repeat (2)\n            turn right (0.5) degrees\n        end\n        repeat (2)\n            turn right (-0.5) degrees\n        end\n        repeat (2)\n            turn right (-1) degrees\n        end\n        repeat (2)\n            turn right (-1.5) degrees\n        end\n        repeat (2)\n            turn right (-2) degrees\n        end\n        repeat (2)\n            turn right (-2.5) degrees\n        end\n        repeat (2)\n            turn right (-2) degrees\n        end\n        repeat (2)\n            turn right (-1.5) degrees\n        end\n        repeat (2)\n            turn right (-1) degrees\n        end\n        repeat (2)\n            turn right (-0.5) degrees\n        end\n    else\n        hide\n    end\nend\n\n@You Win\n\nwhen flag clicked\nforever\n    if <(Level) = [14]> then\n        show\n        go to x: (0) y: (100)\n    else\n        hide\n    end\nend\n\n@Cloud\n\nwhen flag clicked\nswitch costume to (blank v)\nset [ghost v] effect to (0)\n\nwhen I receive [connecting v]\ngo to [front v] layer\nswitch costume to (connection v)\nset [ghost v] effect to (0)\n\nwhen I receive [joined v]\ngo to [front v] layer\nswitch costume to (game on v)\nwait (0.5) seconds\nrepeat (40)\n    change [ghost v] effect by (2.5)\n    wait (0) seconds\nend\nswitch costume to (blank v)\n\nwhen I receive [full v]\ngo to [front v] layer\nswitch costume to (full v)\nset [ghost v] effect to (0)\nstop [all v]\n\n@Preview\n\nwhen flag clicked\nshow\ngo to x: (0) y: (0)\ngo to [front v] layer\nset [ghost v] effect to (0)\n\nwhen I receive [connection v]\nwait (0.1) seconds\ngo [backward v] (1) layers\n\nwhen I receive [joined v]\nwait (0.5) seconds\nrepeat (40)\n    change [ghost v] effect by (2.5)\n    wait (0) seconds\nend\nhide\n\n