Platformer 1#

Instructions: Use arrow keys or W A S D keys. Get to the end of every level to win. This is my first Platformer. Please leave a Heart and star. No advertising unless you followed me. Lets make this hit 60 Hearts and Stars. \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nThere is a Easter Egg #BUT #I #AM #NOT #TELLING #YOU #IT #THOUGH

@Stage\n\nwhen I receive [next level v]\nswitch backdrop to (level 2 v)\n\nwhen flag clicked\nswitch backdrop to (level 1 v)\n\nwhen I receive [level 3 v]\nswitch backdrop to (level 3 v)\n\nwhen backdrop switches to [win v]\nswitch backdrop to (win v)\n\n@Player\n\nwhen flag clicked\nswitch costume to (costume1 v)\ngo to x: (-195) y: (-31)\nhide\n\nwhen I receive [next level v]\nerase all\ngo to x: (-192) y: (-33)\nforever\n    if <(x position) = [190]> then\n        broadcast (level 3 v)\n    end\n    if <touching color (#ff0000)?> then\n        go to x: (-200) y: (-46)\n    end\nend\n\nwhen I receive [level 3 v]\ngo to x: (-202) y: (-45)\nforever\n    if <touching (spike v)?> then\n        go to x: (-202) y: (-45)\n    end\n    if <touching (bird v)?> then\n        go to x: (-202) y: (-45)\n    end\n    if <touching color (#ff0000)?> then\n        go to x: (-202) y: (-45)\n    end\n    if <<(x position) = [-56]> or <(x position) < [-56]>> then\n        switch backdrop to (win v)\n    end\nend\n\nwhen backdrop switches to [win v]\nplay sound [Win v] until done\n\nwhen I receive [start! v]\nset [ghost v] effect to (0)\nshow\ngo to x: (-195) y: (-31)\nforever\n    if <(x position) = [197]> then\n        broadcast (Next Level v)\n    end\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        switch costume to (costume2 v)\n        move (-5) steps\n    end\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        switch costume to (costume1 v)\n        move (5) steps\n    end\nend\n\n@Spike\n\nwhen flag clicked\nhide\n\nwhen I receive [next level v]\nhide\n\nwhen I receive [level 3 v]\ngo to x: (-18) y: (60)\nshow\n\nwhen backdrop switches to [win v]\nhide\n\n@Bird\n\nwhen flag clicked\nhide\n\nwhen I receive [next level v]\nhide\n\nwhen I receive [level 3 v]\nshow\n\nwhen backdrop switches to [win v]\nhide\n\n@Start\n\nwhen I receive [start! v]\ngo to [back v] layer\nhide\n\nwhen flag clicked\nshow\n\nwhen [timer v] > (Timer)\n\ngo to [front v] layer\nshow\n\n@Play\n\nwhen flag clicked\ngo to [front v] layer\npoint in direction (90)\ngo to x: (-6) y: (-120)\nshow\nforever\n    if <touching (mouse-pointer v)?> then\n        set size to (150) %\n    else\n        set size to (100) %\n    end\nend\n\nwhen this sprite clicked\nhide\nbroadcast (START! v)\n\n@Easter Egg\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset size to (100) %\ngo to [front v] layer\nshow\n\nwhen I receive [start! v]\nhide\n\n@Earth\n\nwhen flag clicked\nset [timer v] to (timer)\ngo to [back v] layer\nhide\n\nwhen I receive [message1 v]\ngo to [front v] layer\nshow\n\nwhen I receive [start! v]\ngo to [back v] layer\nhide\n\nwhen [timer v] > (Timer)\nhide\n\n@Snow2\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nshow\ngo to x: (pick random (-233) to (233)) y: (180)\nglide (pick random (0.5) to (2)) secs to x: (x position) y: (-177)\ndelete this clone\n\nwhen I receive [start! v]\nshow\nrepeat until <not <(backdrop [number v]) = [4]>>\n    create clone of (_myself_ v)\nend\n\n@Snow3\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nshow\ngo to x: (pick random (-233) to (233)) y: (180)\nglide (pick random (0.5) to (2)) secs to x: (x position) y: (-177)\ndelete this clone\n\nwhen I receive [start! v]\nshow\nrepeat until \n    create clone of (_myself_ v)\nend\n\n@Cloud\n\ndefine Init\ndelete all of [@players v]\ndelete all of [@ids v]\ndelete all of [@playeroffset v]\ndelete all of [#checkactive v]\ndelete all of [#checkvalue v]\ndelete all of [#cloudlist v]\ndelete all of [clouddata v]\nadd (join [=] (☁ Cloud1)) to [clouddata v]\nadd (join [=] (☁ Cloud2)) to [clouddata v]\nadd (join [=] (☁ Cloud3)) to [clouddata v]\nadd (join [=] (☁ Cloud4)) to [clouddata v]\nadd (join [=] (☁ Cloud5)) to [clouddata v]\nadd (join [=] (☁ Cloud6)) to [clouddata v]\nadd (join [=] (☁ Cloud7)) to [clouddata v]\nadd (join [=] (☁ Cloud8)) to [clouddata v]\nset [@id v] to (([floor v] of ((days since 2000) * (100000000)) ) mod (1000))\n\ndefine Process Cloud (id) (var)\nif <(var) = (item (id) of [clouddata v])> then\n    stop [this script v]\nend\nreplace item (id) of [clouddata v] with (var)\nDecode (var)\nif <<(item (2) of [decoded v]) = (username)> and <(item (5) of [decoded v]) = (@ID)>> then\n    stop [this script v]\nend\nFind Player (item (2) of [decoded v]) (item (5) of [decoded v])\nif <(~i) = [0]> then\n    set [~i v] to (item # of [] in [@players v])\n    if <(~i) = [0]> then\n        New Player\n    else\n        replace item (~i) of [@players v] with (item (2) of [decoded v])\n        replace item (~i) of [@ids v] with (item (5) of [decoded v])\n    end\nend\nset [~j v] to [1]\nrepeat (length of [decoded v])\n    replace item ((((~i) - (1)) * (&MaxElements)) + (~j)) of [#cloudlist v] with (item (~j) of [decoded v])\n    change [~j v] by (1)\nend\n\ndefine Read Cloud\nProcess Cloud [1] (join [=] (☁ Cloud1))\nProcess Cloud [2] (join [=] (☁ Cloud2))\nProcess Cloud [3] (join [=] (☁ Cloud3))\nProcess Cloud [4] (join [=] (☁ Cloud4))\nProcess Cloud [5] (join [=] (☁ Cloud5))\nProcess Cloud [6] (join [=] (☁ Cloud6))\nProcess Cloud [7] (join [=] (☁ Cloud7))\nProcess Cloud [8] (join [=] (☁ Cloud8))\n\ndefine Decode (clouddata)\ndelete all of [decoded v]\nset [~temp v] to []\nset [~i v] to [2]\nrepeat (((length of (clouddata)) - (1)) / (2))\n    switch costume to (join (letter (~i) of (clouddata)) (letter ((~i) + (1)) of (clouddata)))\n    if <(costume [number v]) = [1]> then\n        add (~temp) to [decoded v]\n        set [~temp v] to []\n    else\n        set [~temp v] to (join (~temp) (costume [name v]))\n    end\n    change [~i v] by (2)\nend\n\ndefine Encode\nset [~temp v] to []\nset [~i v] to [1]\nrepeat (length of [#playerlist v])\n    set [~j v] to [1]\n    repeat (length of (item (~i) of [#playerlist v]))\n        switch costume to (letter (~j) of (item (~i) of [#playerlist v]))\n        if <(costume [number v]) < [10]> then\n            set [~temp v] to (join (~temp) (join [0] (costume [number v])))\n        else\n            set [~temp v] to (join (~temp) (costume [number v]))\n        end\n        change [~j v] by (1)\n    end\n    set [~temp v] to (join (~temp) [01])\n    change [~i v] by (1)\nend\n\ndefine SaveToCloud (playerid)\nSavePlayer\nEncode\nif <(playerid) < [6]> then\n    if <(playerid) < [3]> then\n        if <(playerid) = [1]> then\n            set [☁ cloud1 v] to (~temp)\n        else\n            set [☁ cloud2 v] to (~temp)\n        end\n    else\n        if <(playerid) = [3]> then\n            set [☁ cloud3 v] to (~temp)\n        else\n            if <(playerid) = [4]> then\n                set [☁ cloud4 v] to (~temp)\n            else\n                set [☁ cloud5 v] to (~temp)\n            end\n        end\n    end\nelse\n    if <(playerid) < [8]> then\n        if <(playerid) = [6]> then\n            set [☁ cloud6 v] to (~temp)\n        else\n            set [☁ cloud7 v] to (~temp)\n        end\n    else\n        if <(playerid) = [8]> then\n            set [☁ cloud8 v] to (~temp)\n        end\n    end\nend\n\nwhen I receive [update v]\nUpdatePlayersList [1]\nRead Cloud\nSaveToCloud (pick random (1) to (length of [clouddata v]))\nCountPlayers\nUpdatePlayersList [0]\n\ndefine CountPlayers\nset [#playersonline v] to [1]\nset [~i v] to [1]\nrepeat (length of [@players v])\n    if <(item (~i) of [#checkactive v]) = [1]> then\n        change [#playersonline v] by (1)\n    end\n    change [~i v] by (1)\nend\nif <(#PlayersOnline) > [1]> then\n    hide\nelse\n    if <(username) = []> then\n        switch costume to (log in v)\n    else\n        if <(☁ Online) = [0]> then\n            switch costume to (new v)\n        else\n            switch costume to (alone v)\n        end\n    end\n    show\nend\ngo to [front v] layer\nif <(☁ Online) < [0]> then\n    switch costume to (offline v)\n    show\n    stop [all v]\nend\nif <<not <(Version) = (☁ Online)>> and <(☁ Online) > [0]>> then\n    switch costume to (update v)\n    show\n    stop [all v]\nend\n\nwhen I receive [init v]\nInit\n\ndefine UpdatePlayersList (first)\nif <(first) = [1]> then\n    set [~c v] to [0]\n    repeat (length of [@players v])\n        if <not <<(item (((~c) * (&MaxElements)) + (2)) of [#cloudlist v]) = (username)> and <(item (((~c) * (&MaxElements)) + (5)) of [#cloudlist v]) = (@ID)>>> then\n            if <(item ((~c) + (1)) of [@playeroffset v]) = [0]> then\n                replace item ((~c) + (1)) of [#checkvalue v] with (item (((~c) * (&MaxElements)) + (1)) of [#cloudlist v])\n            end\n            replace item ((~c) + (1)) of [@playeroffset v] with ((item ((~c) + (1)) of [@playeroffset v]) + (1))\n        end\n        change [~c v] by (1)\n    end\nelse\n    set [~c v] to [0]\n    repeat (length of [@players v])\n        if <not <<(item (((~c) * (&MaxElements)) + (2)) of [#cloudlist v]) = (username)> and <(item (((~c) * (&MaxElements)) + (5)) of [#cloudlist v]) = (@ID)>>> then\n            if <<not <(item ((~c) + (1)) of [#checkvalue v]) = (item (((~c) * (&MaxElements)) + (1)) of [#cloudlist v])>> or <(item ((~c) + (1)) of [@playeroffset v]) > [99]>> then\n                if <<(item ((~c) + (1)) of [#checkvalue v]) = (item (((~c) * (&MaxElements)) + (1)) of [#cloudlist v])> or <(item (((~c) * (&MaxElements)) + (5)) of [#cloudlist v]) = [X]>> then\n                    replace item ((~c) + (1)) of [#checkactive v] with [0]\n                    replace item ((~c) + (1)) of [@players v] with []\n                    replace item ((~c) + (1)) of [@ids v] with []\n                else\n                    replace item ((~c) + (1)) of [#checkactive v] with [1]\n                end\n                replace item ((~c) + (1)) of [@playeroffset v] with [0]\n            end\n        end\n        change [~c v] by (1)\n    end\nend\n\ndefine EmptyCloud\nset [☁ cloud1 v] to []\nwait (0.1) seconds\nset [☁ cloud2 v] to []\nwait (0.1) seconds\nset [☁ cloud3 v] to []\nwait (0.1) seconds\nset [☁ cloud4 v] to []\nwait (0.1) seconds\nset [☁ cloud5 v] to []\nwait (0.1) seconds\nset [☁ cloud6 v] to []\nwait (0.1) seconds\nset [☁ cloud7 v] to []\nwait (0.1) seconds\nset [☁ cloud8 v] to []\n\nwhen flag clicked\nhide\nset [last v] to [1]\nset [version v] to [1]\nif <(username) = [username]> then\n    wait (0.1) seconds\n    set [☁ online v] to (Version)\nend\nif <(#PlayersOnline) > [0]> then\n    replace item (5) of [#playerlist v] with [X]\n    repeat (10)\n        SaveToCloud (pick random (1) to (length of [clouddata v]))\n    end\nend\nset [#playersonline v] to [0]\n\ndefine SavePlayer\ndelete all of [#playerlist v]\nadd (~Tick) to [#playerlist v]\nadd (username) to [#playerlist v]\nadd ((round ((Player X) * (10))) / (10)) to [#playerlist v]\nadd ((round ((Player Y) * (10))) / (10)) to [#playerlist v]\nadd (@ID) to [#playerlist v]\n\nset [&maxelements v] to [5]\n\nset [☁ online v] to [0]\n\ndefine New Player\nadd (item (2) of [decoded v]) to [@players v]\nadd (item (5) of [decoded v]) to [@ids v]\nadd [0] to [@playeroffset v]\nadd [0] to [#checkactive v]\nadd [0] to [#checkvalue v]\nrepeat (&MaxElements)\n    add [0] to [#cloudlist v]\nend\ncreate clone of (player v)\n\ndefine Find Player (name) (id)\nset [~i v] to [0]\nrepeat (length of [@players v])\n    change [~i v] by (1)\n    if <<(item (~i) of [@players v]) = (name)> and <(item (~i) of [@ids v]) = (id)>> then\n        stop [this script v]\n    end\nend\nset [~i v] to [0]\n\n