Glacier || Online Platformer

Instructions: Please give my snowboard physics a try (it's much better):\nhttps://scratch.mit.edu/projects/579879878/\n\n=== Glacier || Online Platformer ===\n\n***** Instructions *****\nArrows or WAD to move, avoid spikes and saws,\nget all three diamonds!\nSpace to parachute (once you buy it).\nT for safe chat.\nN to toggle names.\nL to toggle parallax (for lag).\n\n\n***** Credits *****\nCode: @bustertobes (me)\nTesting: @bustermal @bustertobes\nArt: @stratfordjames @bustertobes (me)\nSome text: cooltext.com\nInspiration: Other Scrolling Multiplayer Platformers,\nespecially Moonlight Valley by @stratfordjames\n@griffpatch for cloud multiplayer tutorials

@Stage\n\nwhen flag clicked\nforever\n    play sound [music1 v] until done\nend\n\nwhen flag clicked\nforever\n    if <(parallax) = [1]> then\n        switch backdrop to (backdrop1 v)\n    else\n        switch backdrop to (backdrop2 v)\n    end\nend\n\n@blank\n\n@Player\n\ndefine walk (directon) (speed)\nchange x by (speed)\nset [slope v] to [0]\nrepeat until <<(slope) = [8]> or <not <touching (level v)?>>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <(slope) = [8]> then\n    change x by ((0) - (speed))\n    change y by ((0) - (slope))\nend\nif <(speed) < [0]> then\n    change [frame v] by ((speed) / (-15))\nelse\n    change [frame v] by ((speed) / (15))\nend\n\ndefine scroll\nchange [scroll x v] by (x position)\nset x to (0)\nchange [scroll y v] by (y position)\nset y to (0)\n\ndefine touch ground <up?>\nchange [falling v] by (1)\nrepeat until <not <touching (level v)?>>\n    if <up?> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling v] to [0]\n    end\n    set [yspeed v] to [0]\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            if <(player) = [4]> then\n                set [☁ p1 v] to (value)\n            else\n                if <(player) = [5]> then\n                    set [☁ p5 v] to (value)\n                else\n                    if <(player) = [6]> then\n                        set [☁ p6 v] to (value)\n                    else\n                        if <(player) = [7]> then\n                            set [☁ p7 v] to (value)\n                        else\n                            set [☁ p8 v] to (value)\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\nchange [cloud timer v] by (1)\nadd (scroll X) to [buffer v]\nadd (scroll Y) to [buffer v]\nadd (costume [number v]) to [buffer v]\nif <(cloud timer) < [3]> then\n    stop [this script v]\nend\nset [cloud timer v] to [0]\nset [encoded v] to []\nwrite (username) to encoded\nwrite (global chat) to encoded\nwrite (round ((timer) * (10))) to encoded\nrepeat (length of [buffer v])\n    write (item (1) of [buffer v]) to encoded\n    delete (1) of [buffer v]\nend\nset cloud # (MY PLAYER #) to (encoded)\n\nwhen I receive [begin v]\nforever\n    if <(win screen open?) = [0]> then\n        player tick\n    end\n    Send Cloud Data\n    if <not <(global chat) = []>> then\n        say (global chat)\n    else\n        say []\n    end\nend\n\nwhen flag clicked\nhide\nset [max players v] to [8]\nset [my player # v] to [0]\ndelete all of [buffer v]\nset [global chat v] to []\nset [yspeed v] to [0]\nset [falling v] to [10]\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nset [crown? v] to [0]\nset [parachute? v] to [0]\nset [jump boost? v] to [0]\nset size to (100) %\nset rotation style [left-right v]\npoint in direction (90)\ngo to x: (0) y: (0)\nswitch costume to (normal v)\n\ndefine write (val) to encoded\nset [letter # v] to [1]\nrepeat (length of (val))\n    if <(item # of (letter (letter #) of (val)) in [code v]) = [0]> then\n        set [encoded v] to (join (encoded) (item # of [�] in [code v]))\n    else\n        set [encoded v] to (join (encoded) (item # of (letter (letter #) of (val)) in [code v]))\n    end\n    change [letter # v] by (1)\nend\nset [encoded v] to (join (encoded) [00])\n\ndefine player tick\nswitch costume to (normal v)\nchange [yspeed v] by (-1)\nchange y by (Yspeed)\ntouch ground <(Yspeed) > [0]>\nset [xspeed v] to ((Xspeed) * (0.7))\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    change [xspeed v] by (2)\nend\nif <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n    change [xspeed v] by (-2)\nend\nif <(Xspeed) > [0.5]> then\n    walk [90] (Xspeed)\nelse\n    if <(Xspeed) < [-0.5]> then\n        walk [-90] (Xspeed)\n    else\n        set [frame v] to [0]\n    end\nend\nif <<<key (up arrow v) pressed?> or <key (w v) pressed?>> and <(falling) < [1]>> then\n    set [yspeed v] to ((12) + (<(jump boost?) = [1]> * (2)))\nend\nif <<(scroll Y) < [-1000]> or <<touching (level death v)?> or <touching (saws v)?>>> then\n    set [scroll x v] to [0]\n    set [scroll y v] to [0]\n    go to x: (0) y: (-50)\n    set [yspeed v] to [0]\n    set [xspeed v] to [0]\n    broadcast (flash v)\nend\nscroll\nparachute/crown\n\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 [start v]\nbroadcast (setup - opponents v) and wait\nset [joining status v] to [joining]\nshow\nbroadcast (Join Game v) and wait\nif <(MY PLAYER #) > [0]> then\n    set [joining status v] to [joined]\nelse\n    set [joining status v] to [full]\n    set [ghost v] effect to (40)\nend\nbroadcast (begin v)\n\ndefine parachute/crown\nif <(crown?) = [1]> then\n    switch costume to (crown v)\nelse\n    switch costume to (normal v)\nend\nif <<key (space v) pressed?> and <<(parachute?) = [1]> and <(Yspeed) < [0]>>> then\n    set [yspeed v] to [-2]\n    if <(costume [name v]) = [crown]> then\n        switch costume to (parachute crown v)\n    else\n        switch costume to (parachute v)\n    end\nend\n\n@Opponents\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\ndelete all of [buffer v]\nset [names? v] to [1]\nset [offline v] to [100]\nhide\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            if <(player) = [4]> then\n                set [value v] to (☁ P4)\n            else\n                if <(player) = [5]> then\n                    set [value v] to (☁ P5)\n                else\n                    if <(player) = [6]> then\n                        set [value v] to (☁ P6)\n                    else\n                        if <(player) = [7]> then\n                            set [value v] to (☁ P7)\n                        else\n                            set [value v] to (☁ P8)\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [setup - opponents v]\nsetup players\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 <<(shop open?) = [0]> and <not <(names?) = [0]>>> then\n        say (join (player #) (join [: ] (value)))\n    else\n        say []\n    end\n    value = read from encoded\n    if <not <(value) = []>> then\n        say (value)\n    end\n    value = read from encoded\n    value = read from encoded\n    repeat until <(value) = []>\n        add (value) to [buffer v]\n        value = read from encoded\n    end\nend\nif <(length of [buffer v]) > [0]> then\n    set [x v] to ((item (1) of [buffer v]) - (scroll X))\n    delete (1) of [buffer v]\n    set [y v] to ((item (1) of [buffer v]) - (scroll Y))\n    delete (1) of [buffer v]\n    position ((x) + (Xspeed)) ((y) + (Yspeed))\n    switch costume to (item (1) of [buffer v])\n    delete (1) of [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\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    set [ghost v] effect to (0)\nelse\n    set [ghost v] effect to (100)\nend\nif <(win screen open?) = [1]> then\n    hide\nelse\n    show\nend\n\nwhen [n v] key pressed\nif <(player #) = (MAX PLAYERS)> then\n    if <(names?) = [0]> then\n        set [names? v] to [1]\n    else\n        set [names? v] to [0]\n    end\nend\n\n@level\n\ndefine Render at (x) (y) (switch costume?)\nset [my x v] to (x)\nset [my y v] to (y)\nif <(switch costume?) = [true]> then\n    switch costume to (join (x) (join [,] (y)))\nend\ncreate clone of (_myself_ v)\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    show\nelse\n    hide\nend\n\nwhen I start as a clone\nhide\nwait until <(menu?) = [1]>\nwait until <(menu?) = [0]>\nshow\nforever\n    position (((my x) * (480)) - (scroll X)) (((my y) * (360)) - (scroll Y))\nend\n\nwhen flag clicked\nhide\nrender\n\ndefine render\nRender at [0] [0] [true]\nRender at [1] [0] [true]\nRender at [2] [0] [true]\nRender at [2] [1] [true]\nRender at [3] [0] [true]\nRender at [4] [0] [true]\nRender at [-1] [0] [true]\nRender at [-2] [0] [true]\nRender at [-3] [0] [true]\nRender at [-4] [0] [true]\nRender at [-5] [0] [true]\nRender at [-6] [0] [true]\nRender at [-7] [0] [true]\nRender at [-7] [1] [true]\nRender at [6] [-1] [true]\nswitch costume to (solid ground v)\nRender at [-1] [-1] [false]\nRender at [-2] [-1] [false]\nRender at [-3] [-1] [false]\nRender at [0] [-1] [false]\nRender at [1] [-1] [false]\nRender at [2] [-1] [false]\nRender at [3] [-1] [false]\n\n@Glacier\n\nwhen flag clicked\nshow\nset [menu? v] to [1]\ngo to x: (0) y: (9999)\nset [yv v] to [-5]\nswitch costume to (cool text - glacier 373357298297417 v)\ncreate clone of (_myself_ v)\nset size to (100) %\nforever\n    point in direction ((([sin v] of ((timer) * (300)) ) * (5)) + (90))\n    if <(y position) < [60]> then\n        set [yv v] to [10]\n    end\n    change [yv v] by (-1)\n    change y by (yv)\nend\n\nwhen I start as a clone\ngo to x: (0) y: (9999)\nswitch costume to (cool text - play 373358351305431 v)\nset size to (70) %\nforever\n    point in direction ((([sin v] of ((timer) * (250)) ) * (5)) + (90))\n    if <(distance to [mouse-pointer v]) < [60]> then\n        set size to (80) %\n        if <mouse down?> then\n            broadcast (close menu v)\n        end\n    else\n        set size to (70) %\n    end\n    if <(y position) < [-60]> then\n        set [yv v] to [7]\n    end\n    change [yv v] by (-1)\n    change y by (yv)\nend\n\nwhen I receive [close menu v]\nstop [other scripts in sprite v]\nset [yv v] to [10]\nrepeat until <(y position) < [-180]>\n    change [yv v] by (-1)\n    change y by (yv)\nend\nhide\nif <[] = []> then\n    delete this clone\nend\nwait (.1) seconds\nbroadcast (start v)\nset [menu? v] to [0]\n\n@connecting\n\nwhen flag clicked\nshow\nset [joining status v] to [none]\nforever\n    switch costume to (joining status)\nend\n\nwhen I receive [begin v]\nwait (3) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\n@notifying thing\n\nwhen flag clicked\nhide\nforever\n    wait (pick random (20) to (60)) seconds\n    in and out\nend\n\ndefine in and out\nset [ghost v] effect to (100)\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nwait (4) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\n@parallax\n\ndefine Render at (x) (y) (scrolling)\nset [my x v] to (x)\nset [my y v] to (y)\nset [scrolling speed v] to (scrolling)\ncreate clone of (_myself_ v)\nnext costume\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    show\nelse\n    hide\nend\n\nwhen I start as a clone\nhide\nwait until <(menu?) = [0]>\nshow\nforever\n    position (((my x) * (480)) - ((scroll X) / (scrolling speed))) (((my y) * (360)) - ((scroll Y) / (scrolling speed)))\nend\n\nwhen flag clicked\nwait until <(menu?) = [1]>\nset [parallax v] to [1]\nrender all\n\nwait until <(menu?) = [1]>\nwait until <(menu?) = [0]>\n\ndefine render all\nhide\nswitch costume to (parallax v)\nset [is clone? v] to [1]\nRender at [0] [.4] [10]\nRender at [1] [.3] [10]\nRender at [2] [.2] [10]\nRender at [3] [.3] [10]\nRender at [-1] [.2] [10]\nRender at [-2] [.3] [10]\nnext costume\nRender at [0] [-.1] [5]\nRender at [1] [0] [5]\nRender at [2] [0] [5]\nRender at [3] [0] [5]\nRender at [-1] [0] [5]\nRender at [-2] [0] [5]\nRender at [-3] [0] [5]\nset [is clone? v] to [0]\n\nwhen [l v] key pressed\nif <(is clone?) = [0]> then\n    if <(parallax) = [1]> then\n        set [parallax v] to [0]\n        broadcast (delete parallax v)\n    else\n        set [parallax v] to [1]\n        render all\n    end\nend\n\nwhen I receive [delete parallax v]\nif <[] = []> then\n    delete this clone\nend\nset [is clone? v] to [0]\n\n@level death\n\ndefine Render at (x) (y) (switch costume?)\nset [my x v] to (x)\nset [my y v] to (y)\nif <(switch costume?) = [true]> then\n    switch costume to (join (x) (join [,] (y)))\nend\ncreate clone of (_myself_ v)\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    show\nelse\n    hide\nend\n\nwhen I start as a clone\nhide\nwait until <(menu?) = [1]>\nwait until <(menu?) = [0]>\nshow\nforever\n    position (((my x) * (480)) - (scroll X)) (((my y) * (360)) - (scroll Y))\nend\n\nwhen flag clicked\nhide\nrender\n\ndefine render\nRender at [-1] [0] [true]\nRender at [-2] [0] [true]\nRender at [-3] [0] [true]\nRender at [0] [0] [true]\nRender at [1] [0] [true]\nRender at [2] [0] [true]\nRender at [3] [1] [true]\nRender at [3] [0] [true]\n\n@chat\n\nwhen flag clicked\nhide\nset [chat open? v] to [0]\ngo to x: (-150) y: (0)\nforever\n    if <<(chat open?) = [1]> and <(MY PLAYER #) > [0]>> then\n        show\n        if <key (1 v) pressed?> then\n            set [which chat? v] to [1]\n            broadcast (new chat v)\n            set [chat open? v] to [0]\n        end\n        if <key (2 v) pressed?> then\n            set [which chat? v] to [2]\n            broadcast (new chat v)\n            set [chat open? v] to [0]\n        end\n        if <key (3 v) pressed?> then\n            set [which chat? v] to [3]\n            broadcast (new chat v)\n            set [chat open? v] to [0]\n        end\n        if <key (4 v) pressed?> then\n            set [which chat? v] to [4]\n            broadcast (new chat v)\n            set [chat open? v] to [0]\n        end\n        if <key (5 v) pressed?> then\n            set [which chat? v] to [5]\n            broadcast (new chat v)\n            set [chat open? v] to [0]\n        end\n        if <key (6 v) pressed?> then\n            set [which chat? v] to [6]\n            broadcast (new chat v)\n            set [chat open? v] to [0]\n        end\n        if <key (7 v) pressed?> then\n            set [which chat? v] to [7]\n            broadcast (new chat v)\n            set [chat open? v] to [0]\n        end\n        if <key (8 v) pressed?> then\n            set [which chat? v] to [8]\n            broadcast (new chat v)\n            set [chat open? v] to [0]\n        end\n        if <key (9 v) pressed?> then\n            set [which chat? v] to [9]\n            broadcast (new chat v)\n            set [chat open? v] to [0]\n        end\n        wait until <not <key (any v) pressed?>>\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <key (t v) pressed?> then\n        wait until <not <key (t v) pressed?>>\n        if <(chat open?) = [1]> then\n            set [chat open? v] to [0]\n        else\n            set [chat open? v] to [1]\n        end\n    end\nend\n\nwhen I receive [new chat v]\nset [global chat v] to (item (which chat?) of [chats v])\nwait (3) seconds\nset [global chat v] to []\n\n@diamonds\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    show\nelse\n    hide\nend\n\nwhen I start as a clone\nset [my x v] to (item (ID) of [diamond x v])\nset [my y v] to (item (ID) of [diamond y v])\nhide\nwait until <(menu?) = [1]>\nwait until <(menu?) = [0]>\nshow\nforever\n    position ((my x) - (scroll X)) ((my y) - (scroll Y))\n    if <touching (player v)?> then\n        set [v v] to [1]\n        repeat (20)\n            position ((my x) - (scroll X)) (((my y) - (scroll Y)) + ((v) * (1.5)))\n            change [ghost v] effect by (5)\n            change size by (v)\n            change [v v] by (1)\n        end\n        change [diamonds v] by (1)\n        delete this clone\n    end\nend\n\nwhen flag clicked\nhide\nset [diamonds v] to [0]\nset [id v] to [1]\nrepeat (length of [diamond x v])\n    create clone of (_myself_ v)\n    change [id v] by (1)\nend\n\n@flash\n\nwhen flag clicked\nhide\n\nwhen I receive [flash v]\nshow\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\nset [ghost v] effect to (0)\n\n@saws\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    show\nelse\n    hide\nend\n\nwhen I start as a clone\nset [my x v] to (item (ID) of [saw x v])\nset [my y v] to (item (ID) of [saw y v])\nhide\nwait until <(menu?) = [1]>\nwait until <(menu?) = [0]>\nshow\nforever\n    if <(item (ID) of [saw move? v]) = [1]> then\n        position (((my x) - (scroll X)) + (([sin v] of ((timer) * (230)) ) * (100))) ((my y) - (scroll Y))\n    else\n        position ((my x) - (scroll X)) ((my y) - (scroll Y))\n    end\n    turn right (10) degrees\nend\n\nwhen flag clicked\nhide\nset [id v] to [1]\nrepeat (length of [saw x v])\n    create clone of (_myself_ v)\n    change [id v] by (1)\nend\n\n@coins\n\nwhen flag clicked\nhide\nset [coins v] to [0]\nset [id v] to [1]\nwait until <(menu?) = [1]>\nrepeat (length of [coin x v])\n    create clone of (_myself_ v)\n    change [id v] by (1)\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    show\nelse\n    hide\nend\n\nwhen I start as a clone\nset [my x v] to (item (ID) of [coin x v])\nset [my y v] to (item (ID) of [coin y v])\nhide\nwait until <(menu?) = [0]>\nshow\nforever\n    position ((my x) - (scroll X)) ((my y) - (scroll Y))\n    if <touching (player v)?> then\n        set [v v] to [1]\n        repeat (10)\n            position ((my x) - (scroll X)) (((my y) - (scroll Y)) + (([sin v] of ((timer) * (5)) ) * (5)))\n            change [ghost v] effect by (10)\n            change size by ((0) - (v))\n            change [v v] by (3)\n        end\n        change [coins v] by (1)\n        delete this clone\n    end\nend\n\nwhen flag clicked\n\nif <(username) = [bustertobes]> then\n    wait until <(menu?) = [1]>\n    wait until <(menu?) = [0]>\n    forever\n        if <key (0 v) pressed?> then\n            add (scroll X) to [coin x v]\n            add (scroll Y) to [coin y v]\n            set [id v] to (length of [coin x v])\n            create clone of (_myself_ v)\n            wait until <not <key (0 v) pressed?>>\n        end\n    end\nend\n\nwhen [o v] key pressed\n\nif <(username) = [bustertobes]> then\n    delete all of [coin x v]\n    delete all of [coin y v]\nend\n\nwhen [p v] key pressed\n\nif <(username) = [bustertobes]> then\n    delete (length of [coin x v]) of [coin x v]\n    delete (length of [coin y v]) of [coin y v]\nend\n\n@thumbnail\n\nwhen flag clicked\nset [ghost v] effect to (100)\ngo to [front v] layer\n\n@coins display\n\nwhen flag clicked\nhide\nswitch costume to (coins v)\ngo to x: (-220) y: (160)\nwait until <(menu?) = [1]>\nwait until <(menu?) = [0]>\nshow\nclone\n\ndefine clone\nset [clone id v] to [1]\nrepeat (3)\n    create clone of (_myself_ v)\n    change [clone id v] by (1)\nend\nset [clone id v] to [0]\n\nwhen I start as a clone\nchange x by (((clone ID) * (15)) + (5))\nchange y by (-6)\nset size to (30) %\nset [brightness v] effect to (100)\ngo [forward v] (999) layers\nforever\n    switch costume to (join (letter (clone ID) of (coins)) [a])\n    if <(win screen open?) = [1]> then\n        hide\n    else\n        show\n    end\nend\n\n@shop\n\nwhen flag clicked\nset [shop open? v] to [0]\nsetup\nswitch costume to (button v)\nhide\ngo to x: (0) y: (0)\nwait until <(menu?) = [1]>\nwait until <(menu?) = [0]>\nshow\nforever\n    if <touching (mouse-pointer v)?> then\n        set [brightness v] effect to (0)\n        if <mouse down?> then\n            set [shop open? v] to [1]\n        end\n    else\n        set [brightness v] effect to (30)\n    end\n    if <(shop open?) = [0]> then\n        show\n    else\n        hide\n        set [chat open? v] to [0]\n    end\nend\n\ndefine setup\nset [id v] to [shop]\ncreate clone of (_myself_ v)\nset [id v] to [close]\ncreate clone of (_myself_ v)\nset [id v] to [crown]\ncreate clone of (_myself_ v)\nset [id v] to [jump boost]\ncreate clone of (_myself_ v)\nset [id v] to [parachute]\ncreate clone of (_myself_ v)\nset [id v] to [not enough]\ncreate clone of (_myself_ v)\nset [id v] to []\n\nwhen I start as a clone\nif <(id) = [shop]> then\n    switch costume to (shop v)\n    forever\n        if <(shop open?) = [1]> then\n            show\n        else\n            hide\n        end\n    end\nend\nif <(id) = [close]> then\n    switch costume to (close v)\n    forever\n        if <(shop open?) = [1]> then\n            show\n        else\n            hide\n        end\n        if <touching (mouse-pointer v)?> then\n            set [ghost v] effect to (40)\n            if <mouse down?> then\n                set [shop open? v] to [0]\n            end\n        else\n            set [ghost v] effect to (100)\n        end\n    end\nend\nif <(id) = [crown]> then\n    shop [10] [price 1] <[1] = [1]>\n    set [crown? v] to [1]\nend\nif <(id) = [jump boost]> then\n    shop [5] [price 2] <[] = [50]>\n    set [jump boost? v] to [1]\nend\nif <(id) = [parachute]> then\n    shop [7] [price 3] <[] = [50]>\n    set [parachute? v] to [1]\nend\nif <(id) = [not enough]> then\n    hide\n    go to [front v] layer\nend\n\nwhen I start as a clone\nif <<<(id) = [crown]> or <(id) = [jump boost]>> or <(id) = [parachute]>> then\n    forever\n        if <(shop open?) = [1]> then\n            show\n        else\n            hide\n        end\n    end\nend\n\ndefine shop (price) (costume) <locked?>\nswitch costume to (costume)\nforever\n    if <touching (mouse-pointer v)?> then\n        set [brightness v] effect to (10)\n        if <mouse down?> then\n            if <<not <locked?>> or <(has won?) = [1]>> then\n                if <not <(coins) < (price)>> then\n                    change [coins v] by ((0) - (price))\n                    set [ghost v] effect to (100)\n                    switch costume to (join [check ] (letter (7) of (costume [name v])))\n                    repeat (10)\n                        change [ghost v] effect by (-10)\n                    end\n                    stop [this script v]\n                else\n                    broadcast (not enough v)\n                    wait until <not <mouse down?>>\n                end\n            else\n                broadcast (locked v)\n                wait until <not <mouse down?>>\n            end\n        end\n    else\n        set [brightness v] effect to (0)\n    end\nend\n\nwhen I receive [not enough v]\nif <(id) = [not enough]> then\n    go to (mouse-pointer v)\n    switch costume to (not enough v)\n    set [ghost v] effect to (0)\n    show\n    wait (.2) seconds\n    repeat (20)\n        change [ghost v] effect by (5)\n    end\n    hide\nend\n\nwhen I receive [locked v]\nif <(id) = [not enough]> then\n    go to (mouse-pointer v)\n    switch costume to (locked v)\n    set [ghost v] effect to (0)\n    show\n    wait (.2) seconds\n    repeat (20)\n        change [ghost v] effect by (5)\n    end\n    hide\nend\n\n@win\n\nwhen flag clicked\nset [has won? v] to [0]\nhide\ngo to x: (0) y: (0)\nswitch costume to (win screen v)\nwait until <(menu?) = [1]>\nwait until <(menu?) = [0]>\nwait until <(diamonds) = [3]>\nset [ghost v] effect to (100)\nshow\nset [win screen open? v] to [1]\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nhide\ngo [forward v] (1) layers\nswitch costume to (continue00 v)\nwait (1) seconds\nset [ghost v] effect to (100)\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nforever\n    switch costume to (yes v)\n    if <<touching (mouse-pointer v)?> and <mouse down?>> then\n        broadcast (win fade v)\n        switch costume to (continue00 v)\n        set [has won? v] to [1]\n        stop [this script v]\n    end\n    switch costume to (no v)\n    if <<touching (mouse-pointer v)?> and <mouse down?>> then\n        switch costume to (continue00 v)\n        stop [all v]\n    end\n    switch costume to (continue00 v)\nend\n\nwhen I receive [win fade v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\nset [win screen open? v] to [0]\n\n