STARS - A Scrolling Platformer!

Instructions:                           ⭐ w ⭐ STARS!! =]\n                       @DuckGoose9254 2020\n=========================================\nArrow keys or WASD to move!\nSpace to move faster!\nCollect all 6 stars\n\nPlease no advertising.\n=========================================\nUpdates will come soon!

@Stage\n\nwhen [m v] key pressed\nif <([abs v] of (mouse x) ) < [240]> then\n    show variable [mouse v]\n    set [mouse v] to (join ((mouse x) + (SX)) (join [,] ((mouse y) + (SY))))\nelse\n    hide variable [mouse v]\nend\n\nwhen flag clicked\nhide variable [mouse v]\nforever\n    play sound [Fossil Falls \(8-Bit\) - Super Mario Odyssey \[OST\] v] until done\nend\n\n@Player\n\ndefine Platformer\ngo to [front v] layer\nswitch costume to (hit box v)\nset rotation style [don't rotate v]\nset [xv v] to (((XV) + ((<<key (right arrow v) pressed?> or <key (d v) pressed?>> * (Run Speed)) + (<<key (left arrow v) pressed?> or <key (a v) pressed?>> * ((Run Speed) * (-1))))) * (0.9))\nchange x by (round (XV))\nif <touching (level v)?> then\n    set [slope v] to [0]\n    repeat until <<(Slope) < [-8]> or <not <touching (level v)?>>>\n        change y by (1)\n        change [slope v] by (-1)\n    end\n    if <touching (level v)?> then\n        change y by (Slope)\n    end\n    if <touching (level v)?> then\n        repeat ([ceiling v] of ([abs v] of (XV) ) )\n            change x by (((([abs v] of (XV) ) / (XV)) * <touching (level v)?>) * (-1))\n        end\n        set [xv v] to [0]\n    end\nend\nchange [yv v] by (-2)\nchange y by (YV)\nif <touching (level v)?> then\n    repeat ([ceiling v] of ([abs v] of (YV) ) )\n        change y by (((([abs v] of (YV) ) / (YV)) * <touching (level v)?>) * (-1))\n    end\n    set [yv v] to ((0) + ((25) * <<(([abs v] of (YV) ) / (YV)) = [-1]> and <<key (up arrow v) pressed?> or <key (w v) pressed?>>>))\nend\nset rotation style [left-right v]\nswitch costume to (Idol Animation)\nif <<touching (level v)?> and <(YV) = [0]>> then\n    if <<key (down arrow v) pressed?> or <key (s v) pressed?>> then\n        switch costume to (Sleep Animation)\n    end\nend\nif <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<key (left arrow v) pressed?> or <key (a v) pressed?>>> then\n    switch costume to (Walk)\nend\npoint in direction ((<(XV) > [0]> * (90)) + (<(XV) < [0]> * (-90)))\nchange [sx v] by ((x position) * (-1))\nchange [sy v] by ((y position) * (-1))\ngo to x: (0) y: (0)\n\nwhen flag clicked\nforever\n    if <<not <touching (level v)?>> and <(YV) > [0]>> then\n        play sound [Jump v] until done\n    end\nend\n\nwhen I receive [set up v]\nset [walk v] to [5]\nforever\n    change [walk v] by (1)\n    if <(Walk) > [7]> then\n        set [walk v] to [5]\n    end\n    if <(Run Speed) = [1]> then\n        wait (0.1) seconds\n    else\n        wait (0.05) seconds\n    end\nend\n\nwhen I receive [set up v]\nforever\n    if <key (space v) pressed?> then\n        set [run speed v] to [2]\n    else\n        set [run speed v] to [1]\n    end\nend\n\nwhen I receive [set up v]\nset [idol animation v] to [2]\nforever\n    change [idol animation v] by (1)\n    if <(Idol Animation) > [4]> then\n        set [idol animation v] to [2]\n    end\n    wait (0.1) seconds\nend\n\nwhen I receive [set up v]\nforever\n    broadcast (Tick v)\nend\n\nwhen I receive [set up v]\nshow\nset size to (125) %\nset [xv v] to [0]\nset [yv v] to [0]\nforever\n    Platformer\nend\n\nwhen I receive [set up v]\nforever\n    if <(Timer On?) = [Yes]> then\n        Timer\n    end\nend\n\nwhen I receive [tick v]\nchange [100time v] by (3.33333)\n\nwhen flag clicked\nhide\nset [100time v] to [0]\nset [timer on? v] to [Yes]\n\nwhen I receive [set up v]\nforever\n    if <touching (spikes v)?> then\n        set [sx v] to [860]\n        set [sy v] to [0]\n        change [times loss v] by (1)\n        broadcast (Reset v) and wait\n        broadcast (Set Up v) and wait\n    end\nend\n\nwhen I receive [set up v]\nset [sleep animation v] to [8]\nforever\n    change [sleep animation v] by (1)\n    if <(Sleep Animation) > [9]> then\n        set [sleep animation v] to [8]\n    end\n    wait (0.5) seconds\nend\n\ndefine Timer\nset [time v] to ((round (100time)) / (100))\nif <(letter ((length of (Time)) - (1)) of (Time)) = [.]> then\n    set [time v] to (join (Time) [0])\nelse\n    if <not <(letter ((length of (Time)) - (2)) of (Time)) = [.]>> then\n        set [time v] to (join (Time) [.00])\n    end\nend\n\nwhen I receive [show you win! v]\nset [timer on? v] to [No]\nhide\nstop [other scripts in sprite v]\n\n@Level\n\nwhen I receive [set up v]\nswitch costume to (2 v)\nset size to (400) %\nswitch costume to (1 v)\n\nwhen I receive [set up v]\nhide\nset [my x v] to [0]\nset [my y v] to [0]\nset [sx v] to [860]\nset [sy v] to [0]\nClone [1000] [0]\nset [my x v] to [99999]\n\nwhen I receive [set up v]\nforever\n    if <(SY) > [1000]> then\n        set [sx v] to [860]\n        set [sy v] to [0]\n        change [times loss v] by (1)\n        broadcast (Reset v) and wait\n        broadcast (Set Up v) and wait\n    end\nend\n\ndefine Clone (x) (y)\ncreate clone of (_myself_ v)\nset [my x v] to (x)\nset [my y v] to (y)\n\nwhen I receive [tick v]\nMy Position ((My X) + (SX)) ((My Y) + (SY))\n\ndefine My 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\n@Stars\n\nwhen I receive [tick v]\nMy Position ((My X) + (SX)) ((My Y) + (SY))\nif <touching (player v)?> then\n    change [stars collected v] by (1)\n    start sound [Collect v]\n    if <(STARS COLLECTED) = (STARS COLLECTED MAX)> then\n        broadcast (Change Flag Color v)\n    end\n    delete this clone\nend\n\ndefine My Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\nnext costume\n\nwhen flag clicked\n\ndefine Clone (x) (y)\nset [my x v] to (x)\nset [my y v] to (y)\nchange [stars collected max v] by (1)\ncreate clone of (_myself_ v)\n\nwhen I receive [tick v]\nset [show stars collected and stars collected max v] to (join (join (STARS COLLECTED) [ of ]) (STARS COLLECTED MAX))\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [set up v]\nhide\nset [stars collected v] to [0]\nset [stars collected max v] to [0]\nset [my x v] to [0]\nset [my y v] to [0]\nClone [930] [100]\nClone [850] [-550]\nClone [419] [70]\nClone [100] [-200]\nClone [220] [-500]\nClone [-800] [-200]\nset [my x v] to [99999]\n\n@Flag\n\nwhen I receive [tick v]\nMy Position ((My X) + (SX)) ((My Y) + (SY))\n\ndefine My 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 (x) (y)\nset [my x v] to (x)\nset [my y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [set up v]\nhide\nset size to (200) %\nswitch costume to (1 v)\nset [my x v] to [0]\nset [my y v] to [0]\nClone [-800] [-64]\nset [my x v] to [99999]\n\nwhen I receive [change flag color v]\nswitch costume to (2 v)\n\nwhen I receive [tick v]\nif <<(costume [number v]) = [2]> and <touching (player v)?>> then\n    broadcast (Show You Win! v)\nend\n\n@You Win\n\nwhen flag clicked\nhide\ngo to x: (0) y: (50)\nhide variable [☁ best time v]\nhide variable [times loss v]\nhide variable [time v]\nhide variable [show stars collected and stars collected max v]\n\nwhen I receive [show you win! v]\nshow\nbroadcast (Stop Timer v)\nif <(Time) < (☁ BEST TIME)> then\n    set [☁ best time v] to (Time)\n    switch costume to (you got the world record! v)\nelse\n    switch costume to (you win! v)\nend\nshow variable [times loss v]\nshow variable [☁ best time v]\n\nwhen I receive [tick v]\ngo to [front v] layer\n\nwhen I receive [set up v]\nshow variable [time v]\nshow variable [show stars collected and stars collected max v]\n\nset [☁ best time v] to [999.99]\n\n@Spikes\n\nwhen I receive [set up v]\nhide\nset size to (400) %\nswitch costume to (1 v)\nset [my x v] to [0]\nset [my y v] to [0]\nset [sx v] to [860]\nset [sy v] to [0]\nrepeat (8)\n    Clone [0] [0]\nend\nset [my x v] to [99999]\n\ndefine Clone (x) (y)\ncreate clone of (_myself_ v)\nset [my x v] to (x)\nset [my y v] to (y)\nnext costume\n\nwhen I receive [tick v]\nMy Position ((My X) + (SX)) ((My Y) + (SY))\n\ndefine My 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\nwhen flag clicked\nset [times loss v] to [0]\nswitch costume to (8 v)\n\n@Text\n\ndefine Say (thing) (sound)\nset instrument to (20 v)\nset [t v] to []\nset [textlenght v] to ((length of (thing)) - (1))\nrepeat until <(textlenght) = [-1]>\n    set [t v] to (join (t) (letter ((length of (thing)) - (textlenght)) of (thing)))\n    change [textlenght v] by (-1)\n    say (t)\n    play note (74) for ((sound) * (0.01)) beats\nend\nwait (1) seconds\nsay []\n\nwhen flag clicked\nhide\nforever\n    if <(length of (username)) < [3]> then\n        set [username v] to [YOU]\n    else\n        set [username v] to (username)\n    end\nend\n\nwhen I receive [show you win! v]\nwait (0.5) seconds\nshow\nset size to (500) %\ngo to x: (-135) y: (-252)\nglide (0.4) secs to x: (-135) y: (-129)\nSay [Wow!] [0.3]\nwait (1) seconds\nSay (join (Username) [ WON!]) [0.3]\nwait (1) seconds\nSay (join (Username) [ IS THE BEST!!!]) [0.3]\nwait (1) seconds\nSay [How about a Love and Favorite and a FOLLOW!!] [0.3]\nforever\n    wait (1) seconds\n    Say [Love and Favorite and YOU'LL be the best Scratcher ever!] [0.3]\n    wait (1) seconds\n    Say (join (join [Please FOLLOW me ] (Username)) [!]) [0.3]\n    wait (1) seconds\n    Say (join (Username) [ BEAT THE GAME!!]) [0.3]\n    wait (1) seconds\n    Say (join (Username) [ IS AWESOME!!]) [0.3]\nend\n\nwhen I receive [show you win! v]\nforever\n    wait (0.5) seconds\n    next costume\nend\n\n@Thumbnail\n\nwhen flag clicked\nshow\nswitch costume to (start v)\n\nshow\nclear graphic effects\ngo to [front v] layer\ngo to x: (0) y: (0)\nswitch costume to (thumbnail v)\n\nwhen I receive [set up v]\nhide\n\n@Sprite1\n\nwhen flag clicked\nshow\nset size to (300) %\ngo to x: (0) y: (31)\nforever\n    go to [front v] layer\n    if <touching (mouse-pointer v)?> then\n        set [ghost v] effect to (20)\n        if <mouse down?> then\n            hide\n            broadcast (Reset v) and wait\n            broadcast (Set Up v) and wait\n            stop [this script v]\n        end\n    else\n        clear graphic effects\n    end\nend\n\n