Treasure Chest || A Scrolling Platformer

Instructions:                             ~ᴛʀᴇᴀꜱᴜʀᴇ ᴄʜᴇꜱᴛ~     \nᴡᴇʟᴄᴏᴍᴇ! ᴀʀᴇ ʏᴏᴜ ʀᴇᴀᴅʏ ᴛᴏ ᴊᴏɪɴ ᴀɴ ᴇxᴘʟᴏʀᴇʀ ᴏɴ ʜɪꜱ Qᴜᴇꜱᴛ ᴛᴏ ꜰɪɴᴅ ᴛʀᴇᴀꜱᴜʀᴇ? ᴛʜɪꜱ ɢᴀᴍᴇ ɪɴᴄʟᴜᴅᴇꜱ ᴇɴᴇᴍɪᴇꜱ, 5+ ᴄᴏꜱᴛᴜᴍᴇꜱ, ᴀɴᴅ 2 ʟᴇᴠᴇʟꜱ ᴏꜰ ꜰᴜɴ! (not going to make level 3 because it is taking up to much of my time...)\n                             ~ɪɴꜱᴛʀᴜᴄᴛɪᴏɴꜱ~\n- ᴍᴀɪɴ ɢᴏᴀʟ: ɢᴇᴛ ᴀʟʟ ᴛʜᴇ ᴛʀᴇᴀꜱᴜʀᴇ!\n- ʏᴏᴜ ᴍᴜꜱᴛ ᴄᴏʟʟᴇᴄᴛ ᴛʜᴇ ᴋᴇʏ ᴛᴏ ᴏᴘᴇɴ ᴛʜᴇ ᴛʀᴇᴀꜱᴜʀᴇ ᴄʜᴇꜱᴛ\n- ʙᴏᴘ ᴏɴ ᴀɴ ᴇɴᴇᴍɪᴇꜱ ʜᴇᴀᴅ ᴡʜᴇɴ ɪᴛ ɪꜱ ᴄᴜʀʟᴇᴅ ᴜᴘ\n- ᴀᴠᴏɪᴅ ꜱᴀᴡꜱ, ꜱᴘɪᴋᴇꜱ, ᴇɴᴇᴍɪᴇꜱ (ᴡʜᴇɴ ᴏɴ ʟᴏᴏᴋᴏᴜᴛ)\n- ʟᴀꜱᴛ ᴏꜰ ᴀʟʟ, ʜᴀᴠᴇ ꜰᴜɴ!\n\n\n\n:)

@Stage\n\nwhen [m v] key pressed\nset [mouse v] to (join ((mouse x) + (SCROLL X)) (join [, ] ((mouse y) + (SCROLL Y))))\n\nwhen I receive [new music v]\nforever\n    play sound [Pokki_DJ_-_Springtime v] until done\nend\n\nwhen flag clicked\nstart sound [Undertale OST 023 - Shop v]\n\nwhen I receive [start v]\nstop all sounds\nbroadcast (new music v)\n\n@blank\n\n@player\n\nwhen I receive [green flag v]\nhide\ngo to [back v] layer\n\nwhen I receive [play game v]\nset [level v] to [1]\nforever\n    broadcast (reset v) and wait\n    broadcast (Setup v) and wait\n    Game On\n    repeat until <(EXIT) > []>\n        Tick\n        broadcast (Tick v) and wait\n    end\n    if <(EXIT) = [win]> then\n        Game win\n    else\n        Game-Die\n    end\nend\n\ndefine Tick\nif <<key (left arrow v) pressed?> or <<key (a v) pressed?> or <<mouse down?> and <(mouse x) < (x position)>>>> then\n    change [sx v] by (-2)\n    point in direction (-90)\nend\nif <<key (right arrow v) pressed?> or <<key (d v) pressed?> or <<mouse down?> and <(mouse x) > (x position)>>>> then\n    change [sx v] by (2)\n    point in direction (90)\nend\nset [sx v] to ((sx) * (0.8))\nif <([abs v] of (sx) ) > [0.9]> then\n    Change Player X by (round (sx))\nend\nif <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<mouse down?> and <(mouse y) > (x position)>>>> then\n    if <(in air) < [4]> then\n        start sound [Jump v]\n        set [sy v] to [16]\n    end\nend\nif <(sy) > [-15]> then\n    change [sy v] by (-2)\nend\nChange Player Y by (sy)\nTest_die\nchange [scroll x v] by (round (((player x) - (SCROLL X)) / (9)))\nif <(SCROLL X) < [0]> then\n    set [scroll x v] to [0]\nend\nchange [scroll y v] by (round (((player y) - (SCROLL Y)) / (10)))\nif <(SCROLL Y) < [0]> then\n    set [scroll y v] to [0]\nend\nposition\nif <(player y) < [-180]> then\n    set [exit v] to [die]\nend\n\ndefine Change Player Y by (sy)\nchange [player y v] by (sy)\nchange [in air v] by (1)\nposition\nrepeat until <not <<touching (platforms v)?> or <touching (moving platfom v)?>>>\n    if <(sy) > [0]> then\n        change [player y v] by (-1)\n    else\n        change [player y v] by (1)\n        set [in air v] to [1]\n    end\n    position\n    set [sy v] to [0]\nend\n\ndefine Game On\nset rotation style [left-right v]\npoint in direction (90)\nset [player x v] to (Spawn X)\nset [player y v] to (Spawn Y)\nset [scroll y v] to (Spawn Y)\nset [scroll x v] to (Spawn X)\nset [checkpoint v] to [0]\nset [sy v] to [0]\nset [sx v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nset size to (100) %\nset [ghost v] effect to (0)\nshow\n\ndefine Change Player X by (sx)\nchange [player x v] by (sx)\nposition\nif <<touching (platforms v)?> or <touching (moving platfom v)?>> then\n    repeat (20)\n        change [player y v] by (1)\n        position\n        if <not <<touching (platforms v)?> or <touching (moving platfom v)?>>> then\n            stop [this script v]\n        end\n    end\n    change [player y v] by (-14)\n    if <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<(mouse y) > (x position)> and <mouse down?>>>> then\n        if <(sx) > [0]> then\n            set [sx v] to [-16]\n        else\n            set [sx v] to [16]\n        end\n        set [in air v] to [0]\n    else\n        set [sx v] to [0]\n    end\n    repeat until <not <<touching (platforms v)?> or <touching (moving platfom v)?>>>\n        if <(sx) > [0]> then\n            change [player x v] by (-1)\n        else\n            change [player x v] by (1)\n        end\n        position\n    end\nend\n\ndefine Game-Die\nbroadcast (die v)\nset [exit v] to []\nrepeat (4)\n    hide\n    wait (0.1) seconds\n    show\nend\nhide\nwait (0.5) seconds\n\ndefine Test_die\nif <<touching (spikes v)?> or <touching (saw v)?>> then\n    start sound [Crunch v]\n    set [exit v] to [die]\nend\n\ndefine Game win\nchange [level v] by (1)\nbroadcast (YEET v)\n\ndefine position\ngo to x: ((player x) - (SCROLL X)) y: ((player y) - (SCROLL Y))\n\nwhen flag clicked\nset [spawn x v] to [-200]\nset [spawn y v] to [0]\n\nwhen flag clicked\nhide\ngo to [back v] layer\n\nwhen I receive [start v]\nshow\nbroadcast (Green Flag v) and wait\nbroadcast (play game v) and wait\n\nwhen I receive [start v]\nswitch costume to (cn)\n\n@platforms\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((platform x) - (SCROLL X)) ((platform y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [platform y v] to [0]\nset [platform x v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level  1 1 v)\n    Clone at x [0] y: [0]\n    Clone at x [360] y: [0]\n    Clone at x [360] y: [0]\n    Clone at x [360] y: [0]\n    Clone at x [155] y: [0]\n    Clone at x [205] y: [0]\n    Clone at x [245] y: [0]\n    Clone at x [245] y: [0]\n    Clone at x [35] y: [0]\n    Clone at x [35] y: [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2 1 v)\n        Clone at x [0] y: [0]\n        Clone at x [200] y: [0]\n        Clone at x [270] y: [0]\n        Clone at x [400] y: [0]\n        Clone at x [440] y: [0]\n        Clone at x [440] y: [0]\n        Clone at x [400] y: [0]\n        Clone at x [450] y: [0]\n        Clone at x [480] y: [0]\n        Clone at x [400] y: [0]\n        Clone at x [390] y: [0]\n        Clone at x [280] y: [0]\n        Clone at x [227] y: [10]\n        Clone at x [210] y: [0]\n        Clone at x [210] y: [0]\n        Clone at x [210] y: [0]\n        Clone at x [210] y: [0]\n        Clone at x [210] y: [0]\n        Clone at x [210] y: [0]\n        Clone at x [140] y: [-10]\n        Clone at x [800] y: [-10]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (level 3 1 v)\n            Clone at x [0] y: [0]\n        end\n    end\nend\nset [platform x v] to [-99999]\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y: (y)\nchange [platform x v] by (x)\nchange [platform y v] by (y)\ncreate clone of (_myself_ v)\nnext costume\n\n@collectibles\n\nwhen I receive [play game v]\nhide\n\nwhen I receive [tick v]\nposition ((collectibles x) - (SCROLL X)) ((collectibles y) - (SCROLL Y))\nchange movement of coin\nif <touching (player v)?> then\n    start sound [Collect v]\n    if <<touching (player v)?> and <(costume [name v]) = [key]>> then\n        change [collectibles v] by (1)\n        broadcast (OPEN PORTAL v)\n    end\n    delete this clone\nend\n\nwhen I receive [setup v]\nhide\nset [collectibles max v] to [0]\nset [collectibles v] to [0]\nset [y speed v] to [0]\nset [collectibles y v] to [0]\nset [collectibles x v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (money!!! v)\n    Clone at x [-14] y: [-12]\n    Clone at x [350] y: [100]\n    Clone at x [646] y: [-52]\n    Clone at x [710] y: [-52]\n    Clone at x [780] y: [-52]\n    Clone at x [840] y: [-52]\n    Clone at x [1199] y: [-23]\n    Clone at x [1403] y: [159]\n    Clone at x [1832] y: [-52]\n    Clone key at x: [1698] y: [-5]\nelse\n    if <(LEVEL) = [2]> then\n        Clone at x [114] y: [98]\n        Clone at x [339] y: [98]\n        Clone at x [736] y: [204]\n        Clone at x [1010] y: [527]\n        Clone at x [1775] y: [111]\n        Clone at x [1864] y: [111]\n        Clone at x [2519] y: [-48]\n        Clone at x [3076] y: [132]\n        Clone at x [2704] y: [-58]\n        Clone at x [3275] y: [248]\n        Clone at x [3475] y: [349]\n        Clone at x [3997] y: [464]\n        Clone at x [4646] y: [203]\n        Clone at x [5439] y: [-69]\n        Clone key at x: [6382] y: [-41]\n    end\nend\nset [collectibles x v] to [-99999]\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y: (y)\nswitch costume to (money!!! v)\nset [collectibles x v] to (x)\nset [collectibles y v] to (y)\ncreate clone of (_myself_ v)\n\ndefine Clone key at x: (x) y: (y)\nswitch costume to (key v)\nset [collectibles x v] to (x)\nset [collectibles y v] to (y)\ncreate clone of (_myself_ v)\nchange [collectibles max v] by (1)\n\ndefine change movement of coin\nchange [y speed v] by (5)\nchange y by (([sin v] of (y speed) ) * (9))\n\nwhen flag clicked\nset [collectibles max v] to [0]\nset [collectibles v] to [0]\nhide\n\nwhen I receive [tick v]\nif <(collectibles) = (collectibles max)> then\n    broadcast (OPEN PORTAL v)\nend\n\n@enemies\n\nwhen I receive [tick v]\nposition ((enemy x) - (SCROLL X)) ((enemy y) - (SCROLL Y))\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\ndefine Clone at x (x) y: (y)\nset [enemy x v] to (x)\nset [enemy y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen I receive [setup v]\nhide\nset [enemy y v] to [0]\nset [enemy x v] to [0]\nif <(LEVEL) = [1]> then\n    Clone at x [794] y: [-84]\n    Clone at x [1423] y: [90]\n    Clone at x [2011] y: [-88]\n    Clone at x [1902] y: [-88]\nelse\n    if <(LEVEL) = [2]> then\n        Clone at x [341] y: [32]\n        Clone at x [3079] y: [61]\n        Clone at x [3276] y: [192]\n        Clone at x [3478] y: [293]\n        Clone at x [4002] y: [391]\n        Clone at x [6613] y: [-99]\n        Clone at x [6683] y: [-99]\n    else\n        Clone at x [99999] y: []\n    end\nend\nset [enemy x v] to [-99999]\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I start as a clone\nswitch costume to (enemy down v)\nforever\n    switch costume to (enemy down v)\n    wait (pick random (0.7) to (1.2)) seconds\n    repeat until <(costume [number v]) = [6]>\n        next costume\n    end\n    wait (pick random (1) to (2)) seconds\n    repeat until <(costume [number v]) = [9]>\n        next costume\n    end\nend\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nif <<<touching (player v)?> and <<(costume [number v]) = [2]> or <(costume [number v]) = [1]>>> and <([y position v] of [player v]) > (y position)>> then\n    start sound [Squish Pop v]\n    switch costume to (squish v)\n    set [death enemy x v] to (x position)\n    set [death enemy y v] to (y position)\n    broadcast (enemy death animation v)\n    delete this clone\nelse\n    if <touching (player v)?> then\n        start sound [Crunch v]\n        set [exit v] to [die]\n    end\nend\n\n@Chest\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((treasure x) - (SCROLL X)) ((treasure y) - (SCROLL Y))\nif <<(costume [name v]) = [treasure on]> and <touching (player v)?>> then\n    set [exit v] to [win]\n    set [spawn x v] to [-200]\n    set [spawn y v] to [0]\nend\n\nwhen I receive [setup v]\ngo to [back v] layer\nset rotation style [left-right v]\nhide\nset [treasure y v] to [0]\nset [treasure x v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (treasure off v)\n    point in direction (-90)\n    Clone at x [1640] y: [-81]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (treasure off v)\n        point in direction (90)\n        Clone at x [6774] y: [-95]\n    else\n        Clone at x [-99999] y: [0]\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y: (y)\nset [treasure x v] to (x)\nset [treasure y v] to (y)\n\nwhen I receive [open portal v]\nswitch costume to (treasure on v)\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nforever\n    if <<(costume [name v]) = [treasure on]> and <touching (player v)?>> then\n        repeat (1)\n            play sound [High Whoosh v] until done\n        end\n    end\nend\n\n@Moving Platfom\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((Moving Platform x) - (SCROLL X)) ((Moving Platform y) - (SCROLL Y))\nchange x by (([sin v] of (x speed) ) * (100))\nchange [x speed v] by (2)\nset [mp clone 2 x v] to (x position)\nset [mp clone 2 y v] to (y position)\n\nwhen I receive [setup v]\nset [x speed v] to [0]\nhide\npoint in direction (90)\nset [moving platform y v] to [0]\nset [moving platform x v] to [0]\nif <(LEVEL) = [1]> then\n    set [clone id v] to [1]\n    Clone at x [-99999] y: [0]\nelse\n    if <(LEVEL) = [2]> then\n        set [clone id v] to [2]\n        Clone at x [6250] y: [-117]\n    end\nend\nset [moving platform x v] to [10000]\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y: (y)\nset [moving platform x v] to (x)\nset [moving platform y v] to (y)\ncreate clone of (_myself_ v)\n\n@spikes\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((danger x) - (SCROLL X)) ((danger y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [danger y v] to [0]\nset [danger x v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (costume1 v)\n    Clone at x [0] y: [0]\n    Clone at x [400] y: [400]\n    Clone at x [583] y: [-62]\n    Clone at x [1197] y: [-87]\n    Clone at x [2122] y: [200]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (costume6 v)\n        Clone at x [42] y: [-56]\n        Clone at x [621] y: [1]\n        Clone at x [788] y: [115]\n        Clone at x [1523] y: [86]\n        Clone at x [2163] y: [155]\n        Clone at x [4449] y: [268]\n        Clone at x [5067] y: [81]\n    end\nend\nset [danger x v] to [10000]\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y: (y)\nset [danger x v] to (x)\nset [danger y v] to (y)\ncreate clone of (_myself_ v)\nnext costume\n\nwhen flag clicked\nhide\n\nswitch costume to (level 3 1 v)\n\n@Saw\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((saw x) - (SCROLL X)) ((saw y) - (SCROLL Y))\nturn right (([sin v] of (spin speed) ) * (8)) degrees\nchange [spin speed v] by (1)\n\nwhen I receive [setup v]\nhide\nset [saw y v] to [0]\nset [saw x v] to [0]\nif <(LEVEL) = [1]> then\n    Clone at x [436] y: [-97]\nelse\n    if <(LEVEL) = [2]> then\n        Clone at x [2522] y: [-137]\n        Clone at x [2704] y: [-137]\n        Clone at x [5784] y: [-117]\n    end\nend\nset [saw x v] to [10000]\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y: (y)\nset [saw x v] to (x)\nset [saw y v] to (y)\ncreate clone of (_myself_ v)\n\n@checkpoint\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((checkpoint x) - (SCROLL X)) ((checkpoint y) - (SCROLL Y))\nif <touching (player v)?> then\n    set [spawn x v] to (([x position v] of [player v]) + (SCROLL X))\n    set [spawn y v] to (([y position v] of [player v]) + (SCROLL Y))\n    set [checkpoint v] to [1]\n    switch costume to (on v)\nend\n\nswitch costume to (off v)\n\nwhen I receive [setup v]\nhide\nset [checkpoint x v] to [0]\nset [checkpoint y v] to [0]\nset size to (50) %\ngo to [front v] layer\nif <(LEVEL) = [1]> then\n    Clone at x [1309] y: [-56]\nelse\n    if <(LEVEL) = [2]> then\n        Clone at x [2381] y: [-85]\n        Clone at x [2897] y: [-85]\n        Clone at x [5452] y: [-80]\n    else\n        Clone at x [-99999] y: [0]\n    end\nend\n\ndefine position (x) (y)\ngo [backward v] (99) layers\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    go to [front v] layer\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y: (y)\nswitch costume to (off v)\nset [checkpoint x v] to (x)\nset [checkpoint y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen I receive [yeet v]\nwait (1) seconds\nset [checkpoint v] to [0]\n\nwhen flag clicked\nhide\n\nwhen I receive [die v]\nif <(checkpoint) = [1]> then\n    switch costume to (on v)\nend\n\n@art\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((art x) - (SCROLL X)) ((art y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\ngo to [back v] layer\nset [art y v] to [0]\nset [art x v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level  1 1 v)\n    Clone at x [0] y: [0]\n    Clone at x [360] y: [0]\n    Clone at x [360] y: [0]\n    Clone at x [360] y: [0]\n    Clone at x [155] y: [0]\n    Clone at x [205] y: [0]\n    Clone at x [245] y: [0]\n    Clone at x [245] y: [0]\n    Clone at x [35] y: [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2 1 v)\n        Clone at x [0] y: [0]\n        Clone at x [200] y: [0]\n        Clone at x [270] y: [0]\n        Clone at x [400] y: [0]\n        Clone at x [440] y: [0]\n        Clone at x [440] y: [0]\n        Clone at x [400] y: [0]\n        Clone at x [450] y: [0]\n        Clone at x [480] y: [0]\n        Clone at x [400] y: [0]\n        Clone at x [390] y: [0]\n        Clone at x [280] y: [0]\n        Clone at x [227] y: [10]\n        Clone at x [210] y: [0]\n        Clone at x [210] y: [0]\n        Clone at x [210] y: [0]\n        Clone at x [210] y: [0]\n        Clone at x [210] y: [0]\n        Clone at x [210] y: [0]\n        Clone at x [140] y: [-10]\n        Clone at x [800] y: [-10]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (level 3 1 v)\n            Clone at x [0] y: [0]\n        end\n    end\nend\nset [art x v] to [-99999]\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y: (y)\nchange [art x v] by (x)\nchange [art y v] by (y)\ncreate clone of (_myself_ v)\nnext costume\n\n@enemy death stuff\n\nwhen flag clicked\nset size to (80) %\n\nwhen I start as a clone\nshow\ngo to [front v] layer\ndeath animation (pick random (-10) to (10))\n\ndefine death animation (x)\nset [-1 v] to [1]\nclear graphic effects\nforever\n    switch costume to (pick random (1) to (2))\n    change x by ((x) * (-1))\n    change y by (y)\n    change [y v] by (-2)\n    if <touching (_edge_ v)?> then\n        if <(-1) = [1]> then\n            set [-1 v] to [-1]\n        else\n            set [-1 v] to [1]\n        end\n    end\n    if <(y position) < [-170]> then\n        delete this clone\n    end\nend\n\nwhen I receive [enemy death animation v]\ngo to x: (Death enemy X) y: ((Death Enemy Y) - (10))\nchange y by (-20)\nif <touching (_edge_ v)?> then\n    set [y v] to [20]\nelse\n    set [y v] to [5]\nend\ngo to x: (Death enemy X) y: ((Death Enemy Y) - (10))\nrepeat (5)\n    create clone of (_myself_ v)\nend\n\n@next level black thing\n\nwhen flag clicked\ngo to x: (0) y: (0)\nshow\nset [ghost v] effect to (100)\n\nwhen I receive [yeet v]\ngo to [front v] layer\nset [ghost v] effect to (0)\nrepeat (20)\n    change [ghost v] effect by (5)\nend\n\n@keys fall\n\nwhen flag clicked\nset size to (80) %\n\nwhen I start as a clone\nshow\ngo to [front v] layer\ndeath animation (pick random (-10) to (10))\n\ndefine death animation (x)\nset [-1 v] to [1]\nclear graphic effects\nforever\n    change x by ((x) * (-1))\n    change y by (y)\n    change [y v] by (-2)\n    if <touching (_edge_ v)?> then\n        if <(-1) = [1]> then\n            set [-1 v] to [-1]\n        else\n            set [-1 v] to [1]\n        end\n    end\n    if <(y position) < [-170]> then\n        delete this clone\n    end\nend\n\nwhen I receive [die v]\ngo to (player v)\nchange y by (-20)\nif <touching (_edge_ v)?> then\n    set [y v] to [20]\nelse\n    set [y v] to [5]\nend\ngo to (player v)\nrepeat (5)\n    create clone of (_myself_ v)\nend\n\n@title text\n\nwhen flag clicked\nset [ghost v] effect to (6)\nset [menu show? v] to [yes]\nset size to (48) %\ngo to x: (0) y: (-100)\npoint in direction (90)\nset [spin v] to [0]\nrepeat until <(menu show?) = [no]>\n    change y by ([sin v] of (spin) )\n    change [spin v] by (3)\nend\n\nwhen flag clicked\nshow\nrepeat until <(menu show?) = [no]>\n    if <touching (mouse-pointer v)?> then\n        repeat until <not <touching (mouse-pointer v)?>>\n            change size by (((size) + (-120)) / (-5))\n        end\n    else\n        repeat until <touching (mouse-pointer v)?>\n            change size by (((size) + (-110)) / (-5))\n        end\n    end\nend\n\nwhen I receive [start v]\nhide\n\n@home screen costume picker\n\nwhen flag clicked\ngo to x: (0) y: (45)\nset [spin v] to [0]\npoint in direction (75)\nforever\n    repeat until <(menu show?) = [no]>\n        turn right ([sin v] of (spin) ) degrees\n        change [spin v] by (6)\n    end\nend\n\nwhen flag clicked\nset size to (175) %\nshow\nforever\n    repeat until <(menu show?) = [no]>\n        switch costume to (cn)\n    end\nend\n\nwhen I receive [start v]\nhide\n\nwhen flag clicked\nrepeat (5)\n    set [cn v] to [1]\nend\n\n@arrow left\n\nwhen flag clicked\ngo to x: (-49) y: (40)\npoint in direction (75)\nset [spin v] to [0]\npoint in direction (75)\nforever\n    repeat until <(menu show?) = [no]>\n        turn right (([sin v] of (spin) ) * (1)) degrees\n        change [spin v] by (6)\n    end\nend\n\nwhen flag clicked\nset [kay stop sound for left v] to [no]\nforever\n    repeat until <(menu show?) = [no]>\n        if <<touching (mouse-pointer v)?> and <mouse down?>> then\n            change [cn v] by (-1)\n            wait (0.2) seconds\n        end\n    end\nend\n\nwhen flag clicked\nshow\nforever\n    repeat until <(menu show?) = [no]>\n        if <touching (mouse-pointer v)?> then\n            repeat until <not <touching (mouse-pointer v)?>>\n                change size by (((size) + (-135)) / (-5))\n            end\n        else\n            repeat until <touching (mouse-pointer v)?>\n                change size by (((size) + (-110)) / (-5))\n            end\n        end\n    end\nend\n\nwhen I receive [start v]\nhide\n\nwhen flag clicked\nforever\n    repeat until <(menu show?) = [no]>\n        if <touching (mouse-pointer v)?> then\n            repeat until <(kay stop sound for left) = [yeah]>\n                play sound [Tick v] until done\n                set [kay stop sound for left v] to [yeah]\n            end\n        else\n            set [kay stop sound for left v] to [no]\n        end\n    end\nend\n\n@arrow right\n\nwhen flag clicked\ngo to x: (40) y: (40)\npoint in direction (75)\nset [spin v] to [0]\npoint in direction (75)\nforever\n    repeat until <(menu show?) = [no]>\n        turn right (([sin v] of (spin) ) * (1)) degrees\n        change [spin v] by (6)\n    end\nend\n\nwhen flag clicked\nset [kay stop for right v] to [no]\nforever\n    repeat until <(menu show?) = [no]>\n        if <<touching (mouse-pointer v)?> and <mouse down?>> then\n            change [cn v] by (1)\n            wait (0.2) seconds\n        end\n    end\nend\n\nwhen flag clicked\nshow\nforever\n    repeat until <(menu show?) = [no]>\n        if <touching (mouse-pointer v)?> then\n            repeat until <not <touching (mouse-pointer v)?>>\n                change size by (((size) + (-135)) / (-5))\n            end\n        else\n            repeat until <touching (mouse-pointer v)?>\n                change size by (((size) + (-110)) / (-5))\n            end\n        end\n    end\nend\n\nwhen I receive [start v]\nhide\n\nwhen flag clicked\nforever\n    repeat until <(menu show?) = [no]>\n        if <touching (mouse-pointer v)?> then\n            repeat until <(kay stop for right) = [yeah]>\n                play sound [Tick v] until done\n                set [kay stop for right v] to [yeah]\n            end\n        else\n            set [kay stop for right v] to [no]\n        end\n    end\nend\n\n@menu background move\n\nwhen flag clicked\nshow\ncreate clone of (_myself_ v)\nset [xp2 v] to [0]\nset [yp2 v] to [0]\ngo to x: (xp2) y: (yp2)\n\nwhen flag clicked\ngo to x: (0) y: (0)\ngo to [back v] layer\n\nwhen flag clicked\nswitch costume to (costume1 v)\nrepeat until <(menu show?) = [no]>\n    change [xp2 v] by (-4)\n    go to x: (xp2) y: (yp2)\n    if <(xp2) < [-480]> then\n        set [xp2 v] to [480]\n    end\nend\n\nwhen I start as a clone\ngo to [back v] layer\nswitch costume to (costume2 v)\nrepeat until <(menu show?) = [no]>\n    change [xp1 v] by (-4)\n    go to x: (xp1) y: (yp1)\n    if <(xp1) < [-480]> then\n        set [xp1 v] to [480]\n    end\nend\n\nwhen flag clicked\nset [xp1 v] to [480]\nset [yp1 v] to [0]\ngo to x: (xp2) y: (yp2)\n\nwhen I receive [start v]\nhide\n\n@start button\n\nwhen flag clicked\nset size to (85) %\nforever\n    repeat until <(menu show?) = [no]>\n        if <touching (mouse-pointer v)?> then\n            repeat until <not <touching (mouse-pointer v)?>>\n                change size by (((size) + (-130)) / (-5))\n            end\n        else\n            repeat until <touching (mouse-pointer v)?>\n                change size by (((size) + (-110)) / (-5))\n            end\n        end\n    end\nend\n\nwhen flag clicked\nshow\nset size to (85) %\nforever\n    repeat until <(menu show?) = [no]>\n        if <<mouse down?> and <touching (mouse-pointer v)?>> then\n            repeat (10)\n                change [ghost v] effect by (10)\n                change size by ((size) / (-10))\n            end\n            broadcast (start v)\n        end\n    end\nend\n\nwhen I receive [start v]\nhide\nset [menu show? v] to [no]\n\nwhen flag clicked\nset [kay stop sound v] to [no]\nset size to (85) %\nforever\n    repeat until <(menu show?) = [no]>\n        point in direction ((([cos v] of ((timer) * (100)) ) * (7)) + (90))\n    end\nend\n\nstart sound [Tick v]\n\nwhen flag clicked\nset size to (85) %\nrepeat until <(menu show?) = [no]>\n    if <touching (mouse-pointer v)?> then\n        repeat until <(kay stop sound) = [yeah]>\n            play sound [Tick v] until done\n            set [kay stop sound v] to [yeah]\n        end\n    else\n        set [kay stop sound v] to [no]\n    end\nend\n\n@back light\n\nwhen flag clicked\nset size to (130) %\nshow\ngo to [back v] layer\ngo to x: (0) y: (40)\nswitch costume to (costume7 v)\npoint in direction (90)\nrepeat until <(menu show?) = [no]>\n    turn left (2) degrees\nend\n\nwhen I receive [start v]\nhide\n\n@white intro\n\nwhen I receive [start v]\nrepeat (2)\n    change [ghost v] effect by (-50)\nend\nwait (1) seconds\nrepeat (25)\n    change [ghost v] effect by (4)\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\ngo to [front v] layer\nshow\nset [ghost v] effect to (100)\n\n@fog \n\nwhen flag clicked\nshow\nset [ghost v] effect to (85)\ngo to x: (0) y: (0)\n\nwhen flag clicked\nrepeat until <(menu show?) = [no]>\n    go to [back v] layer\nend\n\nwhen I receive [tick v]\ngo to [back v] layer\n\n@lighting\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\n\nwhen I receive [tick v]\nshow\nset [ghost v] effect to (50)\n\n@thumbnail\n\nwhen flag clicked\nshow\nset [ghost v] effect to (100)\nforever\n    go to [front v] layer\nend\n\n