Pretzel Park platformer

Instructions: help pretzel kid collect the pretzels !\n\narrow keys to move :)\n\n"m" to mute/unmute music\n"s" to turn on/off sound effects (default is off)\n"0" (zero) to mute both

@Stage\n\nwhen [any v] key pressed\nif <key (m v) pressed?> then\n    if <(volume) = [0]> then\n        set volume to (volume) %\n    else\n        set volume to (0) %\n    end\nend\nif <key (0 v) pressed?> then\n    set volume to (0) %\nend\nif <key (1 v) pressed?> then\n    change volume by (-10)\nend\nif <key (2 v) pressed?> then\n    change volume by (10)\nend\nif <key (z v) pressed?> then\n    set volume to (10) %\nend\nif <key (x v) pressed?> then\n    set volume to (100) %\nend\nif <not <(volume) = [0]>> then\n    set [volume v] to (volume)\nend\n\nwhen flag clicked\nset [music? v] to [on]\nset [volume v] to (volume)\nforever\n    play sound [OK_POP_KO v] until done\nend\n\n@lavender bg\n\ndefine set size to (zoom amount)\nset [costume name v] to (costume [name v])\nswitch costume to (dot v)\nset size to (zoom amount) %\nswitch costume to (costume name)\n\nset size to [300]\n\nwhen flag clicked\nset size to (zoom)\ngo to [back v] layer\nforever\n    go to x: (((scroll - x) * (-0.5)) + (328)) y: ((scroll - y) * (-1))\nend\n\n@ground\n\ndefine set size to (zoom amount)\nset [costume name v] to (costume [name v])\nswitch costume to (dot v)\nset size to (zoom amount) %\nswitch costume to (costume name)\n\nwhen flag clicked\nset [level v] to [1]\nset [ghost v] effect to (100)\nshow\nswitch costume to (tile 1 v)\nset [clone id v] to (costume [name v])\ncreate clone of (_myself_ v)\nswitch costume to (tile 2 v)\nset size to (zoom)\nforever\n    go to x: (((scroll - x) * (-1)) + ((445) * ((zoom) / (100)))) y: ((scroll - y) * (-1))\nend\n\nwhen I start as a clone\nset size to (zoom)\nforever\n    go to x: ((scroll - x) * (-1)) y: ((scroll - y) * (-1))\nend\n\nset [zoom v] to [400]\n\n@character\n\ndefine set costume\nif <(falling?) < [3]> then\n    if <(frame) = [0]> then\n        switch costume to (standing 1 v)\n    else\n        switch costume to ([floor v] of ((5) + ((frame) mod (8))) )\n    end\nelse\n    if <(speed - y) > [0]> then\n        switch costume to (jumping placeholder 2 v)\n    else\n        switch costume to (falling placeholder 1 v)\n    end\nend\n\ndefine scroll (direction) (speed)\npoint in direction (direction)\nchange [scroll - x v] by (speed)\nset [slope v] to [0]\nrepeat until <<(slope) = [8]> or <not <touching (ground v)?>>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <(slope) = [8]> then\n    change x by ((speed) * (-1))\n    change y by ((slope) * (-1))\nend\nchange [frame v] by (0.5)\n\ndefine walk (direction) (speed)\npoint in direction (direction)\nchange x by (speed)\nset [slope v] to [0]\nrepeat until <<(slope) = [8]> or <not <touching (ground v)?>>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <(slope) = [8]> then\n    change x by ((speed) * (-1))\n    change y by ((slope) * (-1))\nend\nchange [frame v] by (0.5)\n\ndefine touching ground\nchange [falling? v] by (1)\nrepeat until <not <touching (ground v)?>>\n    change y by (1)\n    set [falling? v] to [0]\n    set [speed - y v] to [0]\nend\n\nwhen flag clicked\nset [change costume every v] to [10]\nset [speed - y v] to [-6]\nset [frame v] to [0]\nset rotation style [left-right v]\ngo to x: (-100) y: (10)\npoint in direction (90)\ngo to [front v] layer\nforever\n    switch costume to (box3 v)\n    change [speed - y v] by (-1.5)\n    change y by (speed - y)\n    touching ground\n    if <key (left arrow v) pressed?> then\n        change [scroll x amount v] by (.04)\n        if <<(x position) < [-75]> and <(scroll - x) > ((start - x) + (8))>> then\n            scroll [-90] ((scroll x amount) * (-1))\n        else\n            walk [-90] ((scroll x amount) * (-1))\n        end\n    else\n        if <key (right arrow v) pressed?> then\n            change [scroll x amount v] by (.04)\n            if <<(x position) > [75]> and <(scroll - x) < ((2082) + (-8))>> then\n                scroll [90] (scroll x amount)\n            else\n                walk [90] (scroll x amount)\n            end\n        else\n            set [frame v] to [0]\n            set [scroll x amount v] to [6]\n        end\n    end\n    if <<<key (up arrow v) pressed?> or <key (space v) pressed?>> and <(falling?) < [3]>> then\n        set [speed - y v] to [18]\n    end\n    if <(y position) < [-180]> then\n        repeat until <touching (ground v)?>\n            if <(y position) < [-100]> then\n                change y by (10)\n            end\n            change [scroll - y v] by (-8)\n            touching ground\n            switch costume to (falling placeholder 1 v)\n        end\n        scroll to nearest level\n    end\n    set [color v] effect to (color)\n    set costume\n    change [frame v] by ((1) / (change costume every))\n    if <(level) = [pretzel]> then\n        if <(scroll - y) < (item (2) of [level heights v])> then\n            point in direction (-90)\n            glide (.5) secs to x: ([x position v] of [giant pretzel v]) y: (([y position v] of [giant pretzel v]) + (45))\n            repeat until <not <(scroll - y) < (item (2) of [level heights v])>>\n                change [scroll - y v] by (8)\n            end\n            set [level v] to [2]\n        else\n            point in direction (90)\n            glide (.5) secs to x: ([x position v] of [giant pretzel2 v]) y: (([y position v] of [giant pretzel2 v]) + (45))\n            repeat until <not <(scroll - y) < (item (3) of [level heights v])>>\n                change [scroll - y v] by (8)\n            end\n            set [level v] to [3]\n        end\n    end\nend\n\ndefine scroll to nearest level\nif <(scroll - y) > (item (3) of [level heights v])> then\n    repeat until <not <(scroll - y) > (item (3) of [level heights v])>>\n        change [scroll - y v] by (-8)\n    end\n    set [scroll - y v] to (item (3) of [level heights v])\n    set [level v] to [3]\nelse\n    if <(scroll - y) > (item (2) of [level heights v])> then\n        repeat until <not <(scroll - y) > (item (2) of [level heights v])>>\n            change [scroll - y v] by (-8)\n        end\n        set [scroll - y v] to (item (2) of [level heights v])\n        set [level v] to [2]\n    else\n        if <(scroll - y) > (item (1) of [level heights v])> then\n            repeat until <not <(scroll - y) > (item (1) of [level heights v])>>\n                change [scroll - y v] by (-8)\n            end\n            set [scroll - y v] to (item (1) of [level heights v])\n            set [level v] to [1]\n        else\n            repeat until <not <(scroll - y) < (item (1) of [level heights v])>>\n                change [scroll - y v] by (8)\n            end\n            set [scroll - y v] to (item (1) of [level heights v])\n            set [level v] to [1]\n        end\n    end\nend\n\nwhen I receive [cover v]\ngo to x: (178) y: (-85)\npoint in direction (-90)\nswitch costume to (jumping placeholder 2 v)\nset [color v] effect to (175)\n\ngo to x: (186) y: (-80)\n\n@visible ground\n\ndefine set size to (zoom amount)\nset [costume name v] to (costume [name v])\nswitch costume to (dot v)\nset size to (zoom amount) %\nswitch costume to (costume name)\n\nwhen flag clicked\nswitch costume to (park with trees3 v)\nset size to (zoom)\nset [scroll - x v] to (start - x)\nset [scroll - y v] to [-190]\nforever\n    go to x: ((scroll - x) * (-1)) y: ((scroll - y) * (-1))\nend\n\n@visible ground 2\n\ndefine set size to (zoom amount)\nset [costume name v] to (costume [name v])\nswitch costume to (dot v)\nset size to (zoom amount) %\nswitch costume to (costume name)\n\nwhen flag clicked\nset size to (zoom)\nset [scroll - x v] to (start - x)\nset [scroll - y v] to [-190]\nforever\n    go to x: (((scroll - x) * (-1)) + ((445) * ((zoom) / (100)))) y: ((scroll - y) * (-1))\nend\n\nset [zoom v] to [400]\n\n@pretzel sketch\n\nwhen I start as a clone\nwait (.2) seconds\nforever\n    wait until <<([abs v] of (x position) ) < [240]> and <([abs v] of (y position) ) < [178]>>\n    repeat (10)\n        change [ghost v] effect by (-10)\n    end\n    wait until <not <<([abs v] of (x position) ) < [240]> and <([abs v] of (y position) ) < [178]>>>\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\nend\n\nwhen I start as a clone\nforever\n    go to x: (((scroll - x) - (pretzel - x)) * (-1)) y: (((scroll - y) - (pretzel - y)) * (-1))\n    if <touching (character v)?> then\n        change [pretzels v] by (1)\n        if <(sound fx) = [on]> then\n            change [pitch v] by (10)\n            if <(pitch) = [20]> then\n                set [pitch v] to [-100]\n            end\n            set [pitch v] effect to (pitch)\n            play sound [Coin2 v] until done\n        end\n        repeat (10)\n            change [ghost v] effect by (10)\n            set x to (((scroll - x) - (pretzel - x)) * (-1))\n            change y by (1)\n        end\n        delete this clone\n    end\nend\n\nstart sound [Coin2 v]\n\nset [pitch v] effect to (pitch)\nplay sound [Magic Spell2 v] until done\n\nwhen flag clicked\nset [pretzels v] to [0]\nset [sound fx v] to [off]\nset [pitch v] to [-100]\nswitch costume to (pretzel v)\nset [ghost v] effect to (100)\nshow\nrepeat (20)\n    set size to (pick random (20) to (50)) %\n    set [pretzel - x v] to (pick random (-600) to (622))\n    set [pretzel - y v] to (pick random (-220) to (-90))\n    create clone of (_myself_ v)\nend\nrepeat (30)\n    set size to (pick random (20) to (50)) %\n    set [pretzel - x v] to (pick random (622) to (1992))\n    set [pretzel - y v] to (pick random (-240) to (-90))\n    create clone of (_myself_ v)\nend\nrepeat (20)\n    set size to (pick random (20) to (50)) %\n    set [pretzel - x v] to (pick random (-600) to (622))\n    set [pretzel - y v] to (pick random (100) to (340))\n    create clone of (_myself_ v)\nend\nrepeat (20)\n    set size to (pick random (20) to (50)) %\n    set [pretzel - x v] to (pick random (622) to (1992))\n    set [pretzel - y v] to (pick random (100) to (250))\n    create clone of (_myself_ v)\nend\nrepeat (10)\n    switch costume to (pretzel v)\n    repeat (pick random (0) to (2))\n        next costume\n    end\n    set size to (pick random (20) to (50)) %\n    set [pretzel - x v] to (pick random (-650) to (-200))\n    set [pretzel - y v] to (pick random (420) to (690))\n    create clone of (_myself_ v)\nend\nrepeat (30)\n    switch costume to (pretzel v)\n    repeat (pick random (0) to (2))\n        next costume\n    end\n    set size to (pick random (20) to (50)) %\n    set [pretzel - x v] to (pick random (-600) to (200))\n    set [pretzel - y v] to (pick random (400) to (690))\n    create clone of (_myself_ v)\nend\nrepeat (20)\n    switch costume to (pretzel v)\n    repeat (pick random (0) to (5))\n        next costume\n    end\n    set size to (pick random (20) to (50)) %\n    set [pretzel - x v] to (pick random (200) to (622))\n    set [pretzel - y v] to (pick random (450) to (690))\n    create clone of (_myself_ v)\nend\nrepeat (30)\n    switch costume to (white chocolate pretzel 4 v)\n    repeat (pick random (0) to (1))\n        next costume\n    end\n    set size to (pick random (20) to (50)) %\n    set [pretzel - x v] to (pick random (622) to (1992))\n    set [pretzel - y v] to (pick random (470) to (690))\n    create clone of (_myself_ v)\nend\ngo to x: (240) y: (-180)\nhide\n\nshow\n\nshow\n\nset [pitch v] effect to (((size) * (-2)) - (50))\nplay sound [Magic Spell2 v] until done\n\nwhen [any v] key pressed\nif <key (s v) pressed?> then\n    if <(sound fx) = [off]> then\n        set [sound fx v] to [on]\n    else\n        set [sound fx v] to [off]\n    end\n    wait (.1) seconds\n    show variable [sound fx v]\n    wait (.8) seconds\n    hide variable [sound fx v]\nend\nif <key (0 v) pressed?> then\n    set volume to (0) %\nend\nif <key (1 v) pressed?> then\n    change volume by (-10)\nend\nif <key (2 v) pressed?> then\n    change volume by (10)\nend\nif <key (z v) pressed?> then\n    set volume to (10) %\nend\nif <key (x v) pressed?> then\n    set volume to (100) %\nend\nif <not <(volume) = [0]>> then\n    set [volume v] to (volume)\nend\n\nwhen I receive [cover v]\nhide\n\n@giant pretzel\n\nwhen flag clicked\nset [level v] to [1]\nswitch costume to (pretzel v)\nshow\nset size to (100) %\nset [pretzel - x v] to [2131]\nset y to (-46)\nforever\n    go to x: (((scroll - x) - (pretzel - x)) * (-1)) y: (y position)\n    if <<touching (character v)?> and <(level) = [1]>> then\n        set [level v] to [pretzel]\n        wait until <<not <(level) = [pretzel]>> and <not <touching (character v)?>>>\n    end\nend\n\nset [pretzel - y v] to [-236]\n\nset [ghost v] effect to (100)\n\nwhen I start as a clone\n\nforever\n    go to x: (((scroll - x) - (pretzel - x)) * (-1)) y: (y position)\n    if <<touching (character v)?> and <(level) = [1]>> then\n        set [level v] to [pretzel]\n        wait until <<not <(level) = [pretzel]>> and <not <touching (character v)?>>>\n    end\nend\n\nhide\n\n@giant pretzel2\n\nwhen flag clicked\nset [level v] to [1]\nswitch costume to (pretzel v)\nshow\nset size to (100) %\nset [pretzel - x v] to [-800]\nset [pretzel - y v] to [170]\nforever\n    go to x: (((scroll - x) - (pretzel - x)) * (-1)) y: (((scroll - y) - (pretzel - y)) * (-1))\n    if <<touching (character v)?> and <(level) = [2]>> then\n        set [level v] to [pretzel]\n        wait until <<not <(level) = [pretzel]>> and <not <touching (character v)?>>>\n    end\nend\n\nhide\n\n@cover\n\nwhen flag clicked\nswitch costume to (blocker3 v)\nclear graphic effects\nshow\ngo to x: (0) y: (0)\n\nwhen this sprite clicked\nif <<(mouse x) > [20]> and <(mouse y) < [-120]>> then\n    broadcast (start v)\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\n    hide\nend\n\nwhen I receive [cover v]\nswitch costume to (blocker5 v)\nshow\n\n@selector\n\nwhen flag clicked\ngo to x: (98) y: (9)\npoint in direction (0)\nshow\ngo to [front v] layer\nset [color v] to [0]\nset [length of time v] to [0.5]\nforever\n    if <<mouse down?> and <touching (mouse-pointer v)?>> then\n        broadcast (set color v)\n        repeat until <not <mouse down?>>\n            point towards (mouse-pointer v)\n            point in direction (round (direction))\n            go to x: (98) y: (9)\n            set [color v] effect to (color)\n            set color (with start at [0] °)\n        end\n    end\nend\n\ndefine set color (with start at (degrees) °)\nif <(degrees) = [0]> then\n    if <(round (((direction) * (200)) / (360))) < [0]> then\n        set [color v] to ((200) + (round (((direction) * (200)) / (360))))\n    else\n        set [color v] to (round (((direction) * (200)) / (360)))\n    end\nend\n\nwhen flag clicked\nthink [Drag to select color.] for (2) seconds\n\nwhen I receive [start v]\nhide\n\n@end\n\nwhen flag clicked\nhide\nset [pretzel - x v] to [1852]\nset [pretzel - y v] to [621]\nwait (1) seconds\nshow\nforever\n    go to x: (((scroll - x) - (pretzel - x)) * (-1)) y: (((scroll - y) - (pretzel - y)) * (-1))\n    if <<touching (character v)?> and <(level) = [3]>> then\n        broadcast (you win! v)\n        forever\n            go to x: (((scroll - x) - (pretzel - x)) * (-1)) y: (((scroll - y) - (pretzel - y)) * (-1))\n            set [pretzel - y v] to ((621) + (([sin v] of (pretzel) ) * (20)))\n            change [pretzel v] by (3)\n        end\n    end\nend\n\nwhen this sprite clicked\nbroadcast (you win! v)\n\n@you win\n\nwhen flag clicked\nset [pretzel v] to [0]\nhide\n\nwhen I receive [you win! v]\ngo to x: (0) y: (320)\nswitch costume to (you win3 v)\nset [ghost v] effect to (100)\ngo to [front v] layer\nshow\nrepeat (20)\n    change [ghost v] effect by (-5)\n    change y by (-5)\nend\nset [y amount v] to [-5]\nrepeat (44)\n    change [y amount v] by (0.1)\n    change y by (y amount)\nend\nwait (1) seconds\nrepeat (40)\n    change [y amount v] by (-0.1)\n    change y by (y amount)\nend\nrepeat (20)\n    change [y amount v] by (-0.1)\n    change y by (y amount)\n    change [ghost v] effect by (5)\nend\n\nwhen I receive [cover v]\nhide\n\n@pretzel bits\n\nwhen I receive [you win! v]\nwait (1) seconds\nrepeat (40)\n    wait (.1) seconds\n    switch costume to (pick random (3) to (16))\n    point in direction (pick random (-160) to (160))\n    go to (end v)\n    create clone of (_myself_ v)\nend\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nset [ghost v] effect to (100)\nshow\nset [pretzel bit v] to (pick random (10) to (20))\nrepeat (10)\n    change [ghost v] effect by (-10)\n    move (5) steps\n    change y by (pretzel bit)\n    change [pretzel bit v] by (-1)\nend\nset [frame v] to [0]\nrepeat until <<(frame) = [30]> or <(y position) < [-80]>>\n    move (5) steps\n    change y by (pretzel bit)\n    change [pretzel bit v] by (-1)\n    change [frame v] by (1)\nend\nrepeat (10)\n    move (5) steps\n    change y by (pretzel bit)\n    change [pretzel bit v] by (-1)\n    change [ghost v] effect by (10)\nend\nhide\ndelete this clone\n\n@cover text\n\nwhen flag clicked\nhide\n\nbroadcast (cover v)\nswitch costume to (costume4 v)\nshow\n\n