☁ Spring - Mobile friendly multiplayer platformer ☁
@Stage\n\nwhen flag clicked\nswitch backdrop to (connect.. v)\n\nwhen I receive [start game v]\nswitch backdrop to (backdrop1 v)\n\nwhen I receive [start game v]\nforever\n    play sound [Happy Upbeat Acoustic - AShamaluevMusic v] until done\nend\n\n@Blank\n\n@Level\n\nwhen flag clicked\nhide\n\nwhen I receive [start game v]\nSetup Level\n\ndefine Setup Level\ngo to x: (0) y: (0)\nswitch costume to (level 1 v)\nclear graphic effects\nshow\n\nwhen I receive [loop v]\nforever\n    switch costume to (_Level)\nend\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    go [backward v] (2) layers\nend\n\nwhen flag clicked\nswitch costume to (level 1 v)\n\n@Asset Pack\n\nwhen flag clicked\ngo to x: (0) y: (0)\nforever\n    go to x: ((mouse x) * (0.02)) y: ((mouse y) * (0.02))\nend\n\ngo to x: (0) y: (0)\n\n@Danger\n\nwhen flag clicked\nhide\n\nwhen I receive [start game v]\nSetup Level\n\ndefine Setup Level\ngo to x: (0) y: (0)\nswitch costume to (level 1 v)\nclear graphic effects\nshow\n\nwhen I receive [loop v]\nforever\n    switch costume to (_Level)\nend\n\n@Player\n\nwhen flag clicked\nhide\n\nwhen I receive [start game v]\nSetup Game\nSetup Player\nforever\n    Main Game\n    ☁ Send Cloud Data\nend\n\ndefine Setup Player\nset [player x v] to [0]\nset [player y v] to [0]\ngo to x: (-200) y: (-20)\nshow\n\ndefine Main Game\nPlatformer Physics\nbroadcast (Loop v)\n\nwhen flag clicked\nset [max players v] to [8]\nset [my player # v] to [0]\ndelete all of [player buffer v]\nbroadcast (Setup-Other Players v) and wait\nbroadcast (Joining-Finding a Slot! v)\nbroadcast (Join Game v) and wait\nif <(MY PLAYER #) > [0]> then\n    broadcast (Game Joined!! v)\nelse\n    broadcast (Game Full! =\( v)\nend\nwait (2) seconds\nbroadcast (Start Game v)\n\ndefine Write (data) to encoded\nset [letter # v] to [1]\nrepeat (length of (data))\n    set [encoded v] to (join (encoded) (item # of (letter (letter #) of (data)) in [☁ cloud data v]))\n    change [letter # v] by (1)\nend\nset [encoded v] to (join (encoded) [00])\n\ndefine Set Cloud # (player) to (value)\nif <(player) = [1]> then\n    set [☁ player 1 v] to (value)\nelse\n    if <(player) = [2]> then\n        set [☁ player 2 v] to (value)\n    else\n        if <(player) = [3]> then\n            set [☁ player 3 v] to (value)\n        else\n            if <(player) = [4]> then\n                set [☁ player 4 v] to (value)\n            else\n                if <(player) = [5]> then\n                    set [☁ player 5 v] to (value)\n                else\n                    if <(player) = [6]> then\n                        set [☁ player 6 v] to (value)\n                    else\n                        if <(player) = [7]> then\n                            set [☁ player 7 v] to (value)\n                        else\n                            if <(player) = [8]> then\n                                set [☁ player 8 v] to (value)\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine ☁ Send Cloud Data\nif <(MY PLAYER #) < [1]> then\n    stop [this script v]\nend\nadd (x position) to [player buffer v]\nadd (y position) to [player buffer v]\nchange [cloud timer v] by (1)\nif <(cloud timer) < [3]> then\n    stop [this script v]\nend\nset [cloud timer v] to [0]\nset [encoded v] to []\nWrite (item (Chat # \(Word\)) of [☁ cloud chat v]) to encoded\nWrite (round ((timer) * (10))) to encoded\nWrite (_Level) to encoded\nrepeat (length of [player buffer v])\n    Write (item (1) of [player buffer v]) to encoded\n    delete (1) of [player buffer v]\nend\nSet Cloud # (MY PLAYER #) to (encoded)\n\ndefine Platformer Physics\nchange y by (-2)\nif <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(mouse x) > (x position)>>> then\n    change [player x v] by (1)\nend\nif <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(mouse x) < (x position)>>> then\n    change [player x v] by (-1)\nend\nchange y by (2)\nchange x by (Player x)\nif <touching (level v)?> then\n    change x by ((Player x) * (-1))\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>> then\n        if <(Player x) > [0]> then\n            set [player x v] to [-10]\n        else\n            set [player x v] to [10]\n        end\n        set [player y v] to [10]\n    else\n        set [player x v] to [0]\n    end\nelse\n    set [player x v] to ((Player x) * (0.85))\nend\nchange y by (Player Y)\nif <touching (level v)?> then\n    change y by ((Player Y) * (-1))\n    set [player y v] to [0]\n    change y by (-1)\n    if <<<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>> and <(Jumping?) = [Yes]>> then\n        set [player y v] to [10]\n        set [jumping? v] to [No]\n    end\n    change y by (1)\nelse\n    change [player y v] by (-1)\n    set [jumping? v] to [Yes]\nend\nchange y by (-2)\nSpecial Collisions\nchange y by (2)\n\ndefine Setup Game\nset [_level v] to [1]\ndelete all of [☁ cloud chat v]\nadd [Hello] to [☁ cloud chat v]\nadd [Bye] to [☁ cloud chat v]\nadd [Follow me] to [☁ cloud chat v]\nadd [Lag :\(] to [☁ cloud chat v]\nadd [Great Game!] to [☁ cloud chat v]\nadd [Yes] to [☁ cloud chat v]\nadd [No] to [☁ cloud chat v]\nadd [Which way?] to [☁ cloud chat v]\nadd [Thanks!] to [☁ cloud chat v]\nadd (username) to [☁ cloud chat v]\n\nwhen I receive [start game v]\nset [chat open? v] to [0]\nforever\n    if <(Chat open?) = [1]> then\n        if <key (t v) pressed?> then\n            set [chat open? v] to [0]\n            wait until <not <key (t v) pressed?>>\n        end\n    else\n        if <key (t v) pressed?> then\n            set [chat open? v] to [1]\n            wait until <not <key (t v) pressed?>>\n        end\n    end\nend\n\nwhen I receive [start game v]\nforever\n    if <(Chat open?) = [1]> then\n        if <key (1 v) pressed?> then\n            set [chat # \(word\) v] to [1]\n            say (item (Chat # \(Word\)) of [☁ cloud chat v])\n            wait (2) seconds\n            say []\n            set [chat # \(word\) v] to [10]\n        end\n        if <key (2 v) pressed?> then\n            set [chat # \(word\) v] to [2]\n            say (item (Chat # \(Word\)) of [☁ cloud chat v])\n            wait (2) seconds\n            say []\n            set [chat # \(word\) v] to [10]\n        end\n        if <key (3 v) pressed?> then\n            set [chat # \(word\) v] to [3]\n            say (item (Chat # \(Word\)) of [☁ cloud chat v])\n            wait (2) seconds\n            say []\n            set [chat # \(word\) v] to [10]\n        end\n        if <key (4 v) pressed?> then\n            set [chat # \(word\) v] to [4]\n            say (item (Chat # \(Word\)) of [☁ cloud chat v])\n            wait (2) seconds\n            say []\n            set [chat # \(word\) v] to [10]\n        end\n        if <key (5 v) pressed?> then\n            set [chat # \(word\) v] to [5]\n            say (item (Chat # \(Word\)) of [☁ cloud chat v])\n            wait (2) seconds\n            say []\n            set [chat # \(word\) v] to [10]\n        end\n        if <key (6 v) pressed?> then\n            set [chat # \(word\) v] to [6]\n            say (item (Chat # \(Word\)) of [☁ cloud chat v])\n            wait (2) seconds\n            say []\n            set [chat # \(word\) v] to [10]\n        end\n        if <key (7 v) pressed?> then\n            set [chat # \(word\) v] to [7]\n            say (item (Chat # \(Word\)) of [☁ cloud chat v])\n            wait (2) seconds\n            say []\n            set [chat # \(word\) v] to [10]\n        end\n        if <key (8 v) pressed?> then\n            set [chat # \(word\) v] to [8]\n            say (item (Chat # \(Word\)) of [☁ cloud chat v])\n            wait (2) seconds\n            say []\n            set [chat # \(word\) v] to [10]\n        end\n        if <key (9 v) pressed?> then\n            set [chat # \(word\) v] to [9]\n            say (item (Chat # \(Word\)) of [☁ cloud chat v])\n            wait (2) seconds\n            say []\n            set [chat # \(word\) v] to [10]\n        end\n    end\nend\n\ndefine Special Collisions\nif <(x position) > [235]> then\n    change [_level v] by (1)\n    Setup Player\nend\nif <touching (danger v)?> then\n    Setup Player\nend\nif <touching (end of the world v)?> then\n    Setup Player\nend\nif <touching (spinning spike v)?> then\n    Setup Player\nend\nif <touching (spinning spike2 v)?> then\n    Setup Player\nend\nif <touching (spinning spike3 v)?> then\n    Setup Player\nend\nif <touching (spinning spike4 v)?> then\n    Setup Player\nend\nif <touching (spinning spike5 v)?> then\n    Setup Player\nend\nif <touching (spinning spike6 v)?> then\n    Setup Player\nend\n\nwhen I receive [game joined!! v]\nsay (username)\n\n@Other Players\n\nwhen I receive [setup-other players v]\nset [max players v] to [8]\nSetup 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 [☁ cloud data v]))\nend\n\ndefine Setup Players\ndelete all of [other players buffer v]\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 [start game 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 (☁ Player 1)\nelse\n    if <(player) = [2]> then\n        set [value v] to (☁ Player 2)\n    else\n        if <(player) = [3]> then\n            set [value v] to (☁ Player 3)\n        else\n            if <(player) = [4]> then\n                set [value v] to (☁ Player 4)\n            else\n                if <(player) = [5]> then\n                    set [value v] to (☁ Player 5)\n                else\n                    if <(player) = [6]> then\n                        set [value v] to (☁ Player 6)\n                    else\n                        if <(player) = [7]> then\n                            set [value v] to (☁ Player 7)\n                        else\n                            if <(player) = [8]> then\n                                set [value v] to (☁ Player 8)\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\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]\n    Begin decode of (value)\n    Value = Read from encoded\n    if <(Names? On/Off) = [1]> then\n        say (join (Player #) (join [: ] (value)))\n    else\n        say []\n    end\n    Value = Read from encoded\n    Value = Read from encoded\n    if <(value) = (_Level)> then\n        set [ghost v] effect to (0)\n    else\n        set [ghost v] effect to (100)\n        say []\n    end\n    Value = Read from encoded\n    repeat until <(value) = []>\n        add (value) to [other players buffer v]\n        Value = Read from encoded\n    end\nend\nif <(length of [other players buffer v]) > [0]> then\n    set x to (item (1) of [other players buffer v])\n    delete (1) of [other players buffer v]\n    set y to (item (1) of [other players buffer v])\n    delete (1) of [other players buffer v]\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 [my player # v] to (Player #)\nend\n\nwhen I receive [start game v]\nset [names? on/off v] to [1]\nforever\n    if <key (n v) pressed?> then\n        if <(Names? On/Off) = [1]> then\n            wait until <not <key (n v) pressed?>>\n            set [names? on/off v] to [0]\n        else\n            wait until <not <key (n v) pressed?>>\n            set [names? on/off v] to [1]\n        end\n    end\nend\n\n@Chat\n\nwhen I receive [start game v]\nforever\n    if <(Chat open?) = [1]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nhide\n\n@Art\n\nwhen flag clicked\nhide\nwait (5.1) seconds\nshow\ngo to [front v] layer\nforever\n    if <(_Level) = [1]> then\n        switch costume to (costume1 v)\n    end\n    if <(_Level) = [2]> then\n        switch costume to (costume0 v)\n    end\n    if <(_Level) = [5]> then\n        switch costume to (costume2 v)\n    end\n    if <(_Level) = [6]> then\n        switch costume to (costume3 v)\n    end\n    if <(_Level) = [7]> then\n        switch costume to (costume0 v)\n    end\n    if <(_Level) = [4]> then\n        switch costume to (costume4 v)\n    end\n    if <(_Level) = [5]> then\n        switch costume to (costume2 v)\n    end\n    if <(_Level) = [14]> then\n        switch costume to (costume5 v)\n    end\n    if <(_Level) = [15]> then\n        switch costume to (costume0 v)\n    end\nend\n\nwhen I receive [start the art v]\n\nwhen flag clicked\nforever\n    go to [front v] layer\nend\n\n@Connect...2\n\nwhen I receive [joining-finding a slot! v]\ngo to x: (0) y: (0)\nswitch costume to (connecting... v)\ngo to [front v] layer\nshow\n\nwhen flag clicked\nhide\ngo to x: (0) y: (0)\n\nwhen I receive [game full! =\( v]\ngo to x: (0) y: (0)\nswitch costume to (cloud full! v)\ngo to [front v] layer\nshow\nstart sound [Disconnect v]\nwait (2) seconds\nhide\n\nwhen I receive [game joined!! v]\nswitch costume to (connected! v)\ngo to [front v] layer\nshow\nstart sound [Connect v]\nwait (2) seconds\nhide\n\n@Loading\n\nwhen flag clicked\nset [ghost v] effect to (100)\ngo to x: (0) y: (-80)\nhide\n\nwhen I receive [joining-finding a slot! v]\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\ngo to [front v] layer\nforever\n    turn right (15) degrees\nend\n\nwhen I receive [game joined!! v]\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nhide\nstop [other scripts in sprite v]\nstop [this script v]\n\nwhen I receive [game full! =\( v]\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nhide\nstop [other scripts in sprite v]\nstop [this script v]\n\n@Chat warning\n\nwait (5) seconds\n\nwhen flag clicked\nhide\nwait (5.1) seconds\nswitch costume to (1 v)\nset [ghost v] effect to (30)\nshow\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    go [forward v] (1000) layers\nend\n\nhide\n\n@End Of the world\n\nwhen flag clicked\nhide\nwait (5.1) seconds\nshow\n\nwhen flag clicked\ngo to [front v] layer\ngo [backward v] (10) layers\ngo to [back v] layer\n\n@lf_UI\n\nwhen flag clicked\nswitch costume to (costume3 v)\ngo to x: (0) y: (50)\nhide\nset [ghost v] effect to (100)\nwait (pick random (11) to (16)) seconds\nforever\n    if <<(Stared?) = [1]> and <(Loved?) = [1]>> then\n        stop [this script v]\n    end\n    show\n    repeat until <(y position) < [0.2]>\n        change [ghost v] effect by (-10)\n        change y by (((0) - (y position)) / (7))\n    end\n    wait (4) seconds\n    repeat until <(y position) > [50]>\n        change [ghost v] effect by (10)\n        change y by (((y position) + (5)) / (5))\n    end\n    hide\n    wait (pick random (20) to (40)) seconds\nend\n\nwhen I receive [alert v]\nstop [other scripts in sprite v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nshow\nswitch costume to (costume2 v)\ngo to x: (0) y: (50)\nrepeat until <(y position) < [0.2]>\n    change [ghost v] effect by (-10)\n    change y by (((0) - (y position)) / (7))\nend\nwait (4) seconds\nrepeat until <(y position) > [50]>\n    change [ghost v] effect by (10)\n    change y by (((y position) + (5)) / (5))\nend\nhide\n\n@Clouds\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\npoint in direction (pick random (-90) to (90))\ngo to [back v] layer\ngo to x: (315) y: (pick random (5) to (170))\nswitch costume to (pick random (1) to (7))\nset [ghost v] effect to (50)\nshow\nrepeat until <(x position) < [-280]>\n    change x by (-1)\nend\ndelete this clone\n\nwhen I receive [start game v]\nhide\ncreate clone of (_myself_ v)\nforever\n    wait (pick random (5) to (7)) seconds\n    create clone of (_myself_ v)\nend\n\n@Thumbnail\n\nwhen flag clicked\nhide\nforever\n    set [thumbnail timer v] to (timer)\nend\n\nwhen [timer v] > (Thumbnail Timer)\ngo to x: (0) y: (0)\ngo to [front v] layer\nshow\n\nshow\nswitch costume to (costume2 v)\ngo to [front v] layer\nclear graphic effects\ngo to x: (0) y: (0)\n\n@spinning spike\n\nwhen flag clicked\nhide\n\nwhen I receive [joining-finding a slot! v]\nhide\nwait (5.1) seconds\nforever\n    if <(_Level) = [3]> then\n        go to x: (154) y: (-40)\n        show\n        set [d v] to [0]\n        point in direction (d)\n        forever\n            change [d v] by (10)\n            point in direction (d)\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <not <(_Level) = [3]>> then\n        hide\n    end\nend\n\n\n\nshow\n\n@spinning spike2\n\nwhen flag clicked\nhide\n\nwhen I receive [joining-finding a slot! v]\nhide\nwait (5.1) seconds\nforever\n    if <(_Level) = [6]> then\n        go to x: (47) y: (-125)\n        show\n        set [d v] to [0]\n        point in direction (d)\n        forever\n            change [d v] by (10)\n            point in direction (d)\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <not <(_Level) = [6]>> then\n        hide\n    end\nend\n\n\n\n@Sun variable\n\nwhen flag clicked\nhide\nwait (5.1) seconds\nshow\ngo to [back v] layer\nswitch costume to (costume2 v)\ncreate clone of (_myself_ v)\nswitch costume to (costume1 v)\nwait (2) seconds\nswitch costume to (costume2 v)\ncreate clone of (_myself_ v)\nswitch costume to (costume1 v)\nwait (2) seconds\nswitch costume to (costume2 v)\ncreate clone of (_myself_ v)\nswitch costume to (costume1 v)\n\nwhen I start as a clone\ngo to [back v] layer\nset [ghost v] effect to (50)\nforever\n    repeat (100)\n        switch costume to (costume3 v)\n        change size by (1)\n        switch costume to (costume2 v)\n    end\n    repeat (100)\n        switch costume to (costume3 v)\n        change size by (-1)\n        switch costume to (costume2 v)\n    end\nend\n\n@Particle variable\n\nwhen flag clicked\nwait (5.1) seconds\nhide\nforever\n    create clone of (_myself_ v)\n    wait (pick random (0.01) to (0.05)) seconds\nend\n\nwhen I start as a clone\ngo to x: (230) y: (pick random (230) to (-230))\nset [brightness v] effect to (pick random (-5) to (5))\nset [ghost v] effect to (pick random (50) to (75))\nshow\nrepeat until <(x position) < [-230]>\n    go to [back v] layer\n    move (-7.5) steps\nend\ndelete this clone\n\nwhen I receive [start v]\n\nwhen I receive [cave time! v]\n\nhide\n\ndelete this clone\n\ngo to [front v] layer\n\n@Credits\n\n@spinning spike3\n\nwhen flag clicked\nhide\n\nwhen I receive [joining-finding a slot! v]\nhide\nwait (5.1) seconds\nforever\n    if <(_Level) = [7]> then\n        go to x: (-153) y: (-127)\n        show\n        set [d v] to [0]\n        point in direction (d)\n        forever\n            change [d v] by (10)\n            point in direction (d)\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <not <(_Level) = [7]>> then\n        hide\n    end\nend\n\n\n\nshow\n\n@spinning spike4\n\nwhen flag clicked\nhide\n\nwhen I receive [joining-finding a slot! v]\nhide\nwait (5.1) seconds\nforever\n    if <(_Level) = [7]> then\n        go to x: (-35) y: (-127)\n        show\n        set [d v] to [0]\n        point in direction (d)\n        forever\n            change [d v] by (10)\n            point in direction (d)\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <not <(_Level) = [7]>> then\n        hide\n    end\nend\n\n\n\nshow\n\n@spinning spike5\n\nwhen flag clicked\nhide\n\nwhen I receive [joining-finding a slot! v]\nhide\nwait (5.1) seconds\nforever\n    if <(_Level) = [9]> then\n        go to x: (-158) y: (-109)\n        show\n        set [d v] to [0]\n        point in direction (d)\n        forever\n            change [d v] by (10)\n            point in direction (d)\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <not <(_Level) = [8]>> then\n        hide\n    end\nend\n\n\n\nshow\n\n@spinning spike6\n\nwhen flag clicked\nhide\n\nwhen I receive [joining-finding a slot! v]\nhide\nwait (5.1) seconds\nforever\n    if <(_Level) = [10]> then\n        show\n        go to x: (-4) y: (-57)\n        show\n        set [d v] to [0]\n        point in direction (d)\n        forever\n            change [d v] by (10)\n            point in direction (d)\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <not <(_Level) = [10]>> then\n        hide\n    end\nend\n\n\n\nforever\n\n