Kool platformer

Instructions: Controls: up arrow = jump, down arrow = squat, left arrow = left, right arrow = right. here are all versions so far:\nV1: basic game\nV2: soon!\n-----------------------------------WARNING---------------------------You cannot use coins for anything yet. It may be bad.

@Stage\n\n@My player\n\nwhen flag clicked\nset [time v] to [0]\nset [gravity v] to [-1]\nset [jump force v] to [17]\nset [acceleration v] to [2]\nset [resistance v] to [0.8]\nbroadcast (setup v) and wait\nreset and begin level\n\ndefine move-in steps (steps)\nchange [falling v] by (1)\nrepeat (steps)\n    set [last value v] to (x position)\n    change x by ((speed x) / (steps))\n    check touching solid\n    if <(touching) > [0]> then\n        set x to (last value)\n        set [speed x v] to [0]\n    end\n    set [last value v] to (y position)\n    change y by ((speed y) / (steps))\n    check touching solid\n    if <(touching) > [0]> then\n        set y to (last value)\n        if <(speed y) < [0]> then\n            set [falling v] to [0]\n        end\n        set [speed y v] to [0]\n    end\nend\n\nwhen I receive [lvl2 v]\ngo to x: (-150) y: (50)\n\nwhen I receive [lvl3 v]\ngo to x: (-150) y: (50)\n\ndefine check touching solid\nif <<touching (ground v)?> or <touching (door v)?>> then\n    set [touching v] to [1]\nelse\n    set [touching v] to [0]\nend\n\nwhen I receive [tick - player v]\nswitch backdrop to <touching (ground v)?>\ncontrols - up and down\ncontrols - left and right\nmove-in steps (([abs v] of (speed x) ) + ([abs v] of (speed y) ))\n\ndefine controls - up and down\ncontrols-up\ncontrols-down\n\ndefine controls - left and right\nif <key (left arrow v) pressed?> then\n    point in direction (-90)\n    change [speed x v] by ((0) - (ACCELERATION))\nend\nif <key (right arrow v) pressed?> then\n    point in direction (90)\n    change [speed x v] by (ACCELERATION)\nend\nset [speed x v] to ((speed x) * (RESISTANCE))\n\ndefine reset and begin level\nset [pixelate v] effect to (0)\nset [ghost v] effect to (0)\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [falling v] to [99]\nbegin lvl # [1] Go to x, y: [-150] [75]\npoint in direction (90)\n\nwhen I receive [game loop v]\nforever\n    broadcast (tick - first v)\n    broadcast (tick - player v)\n    broadcast (tick - last v)\nend\n\nwhen I receive [tick - last v]\nif <(x position) > [235]> then\n    begin lvl # ((LVL #) + (1)) Go to x, y: [-230] []\nend\nif <(x position) < [-235]> then\n    if <not <(LVL #) = [0]>> then\n        begin lvl # ((LVL #) + (-1)) Go to x, y: [235] []\n    else\n        begin lvl # ((LVL #) + (-1)) Go to x, y: [84] []\n    end\nend\nif <(y position) < [-190]> then\n    broadcast (lose life v)\nend\nif <<touching (danger v)?> or <touching (danger2 v)?>> then\n    broadcast (lose life v)\nend\n\ndefine begin lvl # (lvl #) Go to x, y: (x) (y)\nset [lvl # v] to (lvl #)\nset x to (x)\nset y to (y)\nbroadcast (Change lvl v)\nstop [other scripts in sprite v]\nwait (0) seconds\nfix collision in direction [0]\nbroadcast (game loop v)\n\ndefine fix collision in direction (dir)\nset [temp v] to (direction)\nset [distance v] to [1]\npoint in direction (dir)\nrepeat (64)\n    check touching solid\nend\nif <(touching) < [1]> then\n    point in direction (temp)\nend\nmove (distance) steps\nturn right (180) degrees\nchange [distance v] by (1)\npoint in direction (90)\n\nwhen I receive [tick - first v]\nswitch costume to (player v)\nset rotation style [left-right v]\n\nwhen I receive [game loop v]\nset [ghost v] effect to (0)\nforever\n    if <(time.stop) = [0]> then\n        wait (0.1) seconds\n        change [time v] by (0.1)\n    end\nend\n\nwhen I receive [lose life v]\nstop [other scripts in sprite v]\nrepeat (100)\n    change [pixelate v] effect by (1)\n    change [ghost v] effect by (1)\nend\nreset and begin level\n\ndefine animate run\nswitch costume to (player v)\nwait (0.3) seconds\nswitch costume to (player2 v)\nwait (0.3) seconds\nswitch costume to (player3 v)\nwait (0.3) seconds\nswitch costume to (player2 v)\nwait (0.3) seconds\nswitch costume to (player v)\n\nanimate run\n\nanimate run\n\nwhen I receive [fix collision v]\nask [which direction] and wait\nrepeat (30)\n    fix collision in direction (answer)\nend\n\nwhen flag clicked\nforever\n    if <not <(y position) < [129]>> then\n        broadcast (hide variables v)\n    else\n        broadcast (show variables v)\n    end\nend\n\nwait (3) seconds\n\nwhen I receive [stop v]\nstop [all v]\n\ndefine controls-down\nif <key (down arrow v) pressed?> then\n    switch costume to (player squat v)\nelse\n    switch costume to (player v)\nend\nchange [speed y v] by (GRAVITY)\n\ndefine controls-up\nif <key (up arrow v) pressed?> then\n    if <(falling) < [1]> then\n        set [speed y v] to (JUMP FORCE)\n    end\n    switch costume to (player jump v)\nelse\n    switch costume to (player v)\nend\n\nwhen I receive [change lvl v]\nif <(LVL #) = [14]> then\n    set [time.stop v] to [1]\nelse\n    set [time.stop v] to [0]\nend\n\nwhen flag clicked\nset [time.stop v] to [0]\nbroadcast (Cloud - Setup v) and wait\nforever\n    add (x position) to [my values to send v]\n    add (y position) to [my values to send v]\n    broadcast (Cloud - Tick v)\nend\n\n@ground\n\nwhen flag clicked\nswitch costume to (lvl1 v)\n\nwhen I receive [change lvl v]\nswitch costume to (join [lvl] (LVL #))\n\nwhen I receive [ex v]\nswitch costume to (lvl7ex v)\nset [lvl # v] to [7 EX]\n\n@text\n\nwhen flag clicked\nforever\n    switch costume to (join [lvl] (LVL #))\nend\n\n@danger\n\nwhen flag clicked\nswitch costume to (lvl1 v)\n\nwhen I receive [change lvl v]\nswitch costume to (blank v)\nswitch costume to (join [lvl] (LVL #))\nif <<<<(LVL #) = [5]> or <(LVL #) = [6]>> or <(LVL #) = [7]>> or <(LVL #) = [13]>> then\n    forever\n        set y to ((5) * ([sin v] of ((timer) * (360)) ))\n    end\nend\n\n@money\n\nwhen I receive [change lvl v]\nif <(LVL #) = (my lvl)> then\n    show\nelse\n    hide\nend\n\nwhen I start as a clone\nrepeat until <touching (my player v)?>\n    change y by ((0.5) * ([sin v] of (frame) ))\n    change [frame v] by (5)\nend\nset [my lvl v] to []\nstart sound [Collect v]\nif <(costume [number v]) = [1]> then\n    change [tokens v] by (1)\nelse\n    add [key1] to [collected v]\nend\nrepeat (20)\n    change y by (2)\n    change [ghost v] effect by (5)\nend\nhide\n\nwhen I receive [setup v]\ndelete all of [collected v]\nset [frame v] to [0]\nset [tokens v] to [0]\nhide\nplace [money] lvl [1] xy [20] [-59]\nplace [money] lvl [2] xy [0] [36]\nplace [money] lvl [3] xy [138] [-56]\nplace [money] lvl [4] xy [148] [-76]\nplace [money] lvl [5] xy [166] [-25]\nplace [money] lvl [6] xy [42] [0]\nplace [money] lvl [7] xy [-62] [-9]\nplace [money] lvl [8] xy [145] [-48]\nplace [money] lvl [9] xy [0] [0]\nplace [money] lvl [10] xy [-32] [-85]\nplace [money] lvl [11] xy [123] [-28]\nplace [money] lvl [12] xy [187] [-51]\nplace [money] lvl [13] xy [187] [-51]\n\ndefine place (costume name) lvl (lvl) xy (x) (y)\nset [my lvl v] to (lvl)\nswitch costume to (costume name)\ngo to x: (x) y: (y)\ncreate clone of (_myself_ v)\nset [my lvl v] to []\n\n@danger2\n\nwhen flag clicked\nswitch costume to (lvl1 v)\n\nwhen I receive [change lvl v]\nswitch costume to (blank v)\nswitch costume to (join [lvl] (LVL #))\n\n    forever\n        set y to ((5) * ([sin v] of ((timer) * (360)) ))\n    end\nend\n\nwhen flag clicked\nswitch costume to (lvl1 v)\n\n@dark\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    if <<<<<(LVL #) = [8]> or <(LVL #) = [9]>> or <(LVL #) = [10]>> or <(LVL #) = [11]>> or <(LVL #) = [12]>> then\n        show\n        switch costume to (join [lvl] (LVL #))\n    else\n        hide\n    end\nend\n\n@fix collision button\n\nwhen this sprite clicked\nbroadcast (fix collision v)\n\nwhen I receive [show variables v]\nshow variable [lvl # v]\nshow variable [tokens v]\nshow variable [time v]\nshow\n\nwhen I receive [hide variables v]\nhide variable [lvl # v]\nhide variable [tokens v]\nhide variable [time v]\nhide\n\n@door\n\nwhen flag clicked\ngo to [back v] layer\ngo to x: (4) y: (4)\nforever\n    if <(LVL #) = [1]> then\n        show\n        if <(door.open) = [0]> then\n            switch costume to (closed v)\n        else\n            glide (1) secs to x: (4) y: (125)\n            switch costume to (open v)\n        end\n    else\n        hide\n    end\nend\n\nwhen I receive [restart v]\ngo to x: (4) y: (4)\n\n@button\n\nwhen flag clicked\nbroadcast (restart v)\nforever\n    if <not <(LVL #) = [1]>> then\n        hide\n    else\n        show\n    end\nend\n\nwhen I receive [restart v]\nswitch costume to (not clicked v)\nset [door.open v] to [0]\nforever\n    if <<touching (my player v)?> and <(costume [number v]) = [1]>> then\n        if <(door.open) = [0]> then\n            change [door.open v] by (1)\n        else\n            change [door.open v] by (-1)\n        end\n        switch costume to (clicked v)\n    end\nend\n\nwhen I receive [lose life v]\nwait (3.4) seconds\nbroadcast (restart v)\n\n@skin button\n\nwhen this sprite clicked\nif <(costume [name v]) = [enter]> then\n    broadcast (stop v)\n    switch costume to (exit v)\nelse\n    broadcast (game loop v)\n    switch costume to (enter v)\nend\n\n@skin shop\n\nwhen I receive [game loop v]\nhide\n\nwhen I receive [stop v]\n\nshow\n\n@skins\n\nwhen this sprite clicked\nif <<<(costume [name v]) = (join [normal ] [select])> or <<[] = (join [demon ] [select])> or <[] = (join [purple ] [select])>>> or <<[] = (join [gradient ] [select])> or <<[] = (join [gradient demon ] [select])> or <[] = (join [me ] [select])>>>> then\n\n@portal\n\nwhen I receive [change lvl v]\nif <(LVL #) = [14]> then\n    show\n    switch costume to (lvl14 v)\nelse\n    hide\nend\n\nwhen flag clicked\nforever\n    if <touching (my player v)?> then\n        set [lvl # v] to [1]\n        broadcast (Change lvl v)\n        broadcast (game loop v)\n    end\nend\n\n@cloud player\n\ndefine Write Number (val) to encoded string\nset [val v] to (round (val))\nif <(val) < [0]> then\n    set [val v] to (join [0] ([abs v] of (val) ))\nend\nset [encoded string v] to (join (encoded string) (join (length of (val)) (val)))\n\nset [encoded idx v] to [1]\nval = READ NUMBER from "encoded string"\nval = READ NUMBER from "encoded string"\n\ndefine val = READ NUMBER from "encoded string"\nset [val v] to []\nrepeat (letter (encoded idx) of (encoded string))\n    change [encoded idx v] by (1)\n    set [val v] to (join (val) (letter (encoded idx) of (encoded string)))\nend\nchange [encoded idx v] by (1)\nif <(letter (1) of (val)) = [0]> then\n    set [val v] to ((0) - (val))\nend\n\nwhen I receive [cloud - setup v]\nhide\nset [cloud tick v] to [0]\ndelete all of [my values to send v]\ndelete all of [cloud values v]\ndelete all of [player uids v]\ndelete all of [player data v]\nadd (join [c ] (☁ CLOUD 1)) to [cloud values v]\nset [my player uid v] to (pick random (1) to (9999999))\nset [player # v] to []\n\nwhen I receive [cloud - tick v]\nchange [cloud tick v] by (1)\nProcess Cloud Item [1] value (join [c ] (☁ CLOUD 1))\nSend my Cloud Date after [4] ticks\n\ndefine Send my Cloud Date after (count) ticks\nif <((CLOUD TICK) mod (count)) > [0]> then\n    stop [this script v]\nend\nset [encoded string v] to []\nWrite Number (MY PLAYER UID) to encoded string\nrepeat (length of [my values to send v])\n    Write Number (item (1) of [my values to send v]) to encoded string\n    delete (1) of [collected v]\nend\nset [☁ cloud 1 v] to (encoded string)\n\ndefine Process Cloud Item (which?) value (new value)\nif <(new value) = (item (which?) of [cloud values v])> then\n    stop [this script v]\nend\nreplace item (which?) of [cloud values v] with (new value)\nset [encoded string v] to (new value)\nset [encoded idx v] to [2]\nval = READ NUMBER from "encoded string"\nif <<(val) < [1]> or <(val) = (MY PLAYER UID)>> then\n    stop [this script v]\nend\nset [player # v] to (item # of (val) in [cloud values v])\nif <(player #) = [0]> then\n    add (val) to [player uids v]\n    add [] to [player data v]\n    set [player # v] to (length of [player data v])\nend\nreplace item (player #) of [player data v] with (new value)\nset [player # v] to []\n\n