Scratch Month 2020 Platformer

Instructions: As you might know it's Scratch month 2020!\nSo happy scratch month!\n\nLeft and right arrow keys to move\nUp to jump\nCollect all the coins to go to the next level\n\nCreated by @skidsteerloader\nIf you take code or sprites please give credit\nThis was an old game that i started working on but never finshed. then I thought I should finish it up for scratch month!\nScratch on\n          ~skidsteerloader

@Stage\n\nwhen [space v] key pressed\nset [mouse v] to (join [x, ] (join ((SCROLL X) + (mouse x)) (join [ y, ] ((SCROLL Y) + (mouse y)))))\nif <(mouse x) > [-240]> then\n    show variable [mouse v]\nelse\n    hide variable [mouse v]\nend\n\n@Splash\n\nwhen flag clicked\nset [ghost v] effect to (100)\n\ngo to [front v] layer\nshow\n\n@Starting\n\nwhen flag clicked\ngo to x: (20) y: (20)\ngo to [front v] layer\nshow\nhide variable [time v]\nbroadcast (Button v)\nforever\n    switch costume to (when click v)\n    wait (pick random (1) to (4)) seconds\n    repeat (3)\n        next costume\n    end\n    repeat (3)\n        switch costume to ((costume [number v]) - (1))\n    end\nend\n\nwhen I receive [play game v]\nhide\nstop [other scripts in sprite v]\n\n@Play Buttons\n\nwhen I receive [button v]\nset [music? v] to [YES]\nset [sound? v] to [YES]\ngo to [front v] layer\nswitch costume to (p v)\nshow\ngo to x: (39) y: (45)\ncreate clone of (_myself_ v)\nswitch costume to (s v)\nchange y by (-40)\ncreate clone of (_myself_ v)\nchange y by (-40)\nswitch costume to (m v)\nforever\n    if <touching (mouse-pointer v)?> then\n        set [brightness v] effect to (0)\n        if <mouse down?> then\n            if <(costume [number v]) = [1]> then\n                switch costume to (m2 v)\n                set [music? v] to [NO]\n            else\n                switch costume to (m v)\n                set [music? v] to [YES]\n            end\n            wait until <not <mouse down?>>\n        end\n    else\n        set [brightness v] effect to (-100)\n    end\nend\n\nwhen I start as a clone\nif <(costume [number v]) = [3]> then\n    forever\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (0)\n            if <mouse down?> then\n                if <(costume [number v]) = [3]> then\n                    switch costume to (s2 v)\n                    set [sound? v] to [NO]\n                else\n                    switch costume to (s v)\n                    set [sound? v] to [YES]\n                end\n                wait until <not <mouse down?>>\n            end\n        else\n            set [brightness v] effect to (-100)\n        end\n    end\nelse\n    if <(costume [number v]) = [5]> then\n        forever\n            if <touching (mouse-pointer v)?> then\n                set [brightness v] effect to (0)\n                if <mouse down?> then\n                    broadcast (Play Game v) and wait\n                end\n            else\n                set [brightness v] effect to (-100)\n            end\n        end\n    end\nend\n\nwhen I receive [play game v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@Cat\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    broadcast (Out v) and wait\n    repeat until <(END) > []>\n        set [time v] to (round (timer))\n        point in direction (90)\n        broadcast (Enemy Tick v)\n        Tick\n        Get Scrolling\n        Walk\n        broadcast (Tick v) and wait\n    end\n    if <(END) = [win]> then\n        Game ~ win\n        broadcast (Check Time v) and wait\n    else\n        Game ~ die\n    end\nend\n\ndefine Game On\nshow\nset [player sx v] to [0]\nset [player sy v] to [0]\nset [player x v] to [0]\nset [player y v] to [0]\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nset [player dir v] to [90]\nset [falling v] to [3]\nset [frame v] to [0]\nset [end v] to []\nset [sound 1 is done? v] to [0]\nset [time v] to [0]\nclear graphic effects\nCheck Collide\nGet Scrolling\nWalk\nreset timer\nbroadcast (Tick v) and wait\n\ndefine Tick\nswitch costume to (hitbox v)\nif <key (left arrow v) pressed?> then\n    Momentum [-.7] [0]\n    set [player dir v] to [-90]\nend\nif <key (right arrow v) pressed?> then\n    Momentum [.7] [0]\n    set [player dir v] to [90]\nend\nset [player sx v] to ((PLAYER SX) * (0.9))\nif <([abs v] of (PLAYER SX) ) > [0.9]> then\n    Change player x by (round (PLAYER SX))\nend\nif <(PLAYER SY) > [-20]> then\n    Momentum [0] [-1]\nend\nChange Player y by (PLAYER SY)\nif <key (up arrow v) pressed?> then\n    if <(FALLING) < [3]> then\n        set [player sy v] to [10]\n        set [falling v] to [3]\n        if <(SOUND?) = [YES]> then\n            start sound [jump v]\n        end\n    end\nend\nCheck Collide\nif <(PLAYER Y) < [-180]> then\n    set [end v] to [die]\nend\n\ndefine Change player x by (sx)\nchange [player x v] by (sx)\nchange [frame v] by (0.5)\nCheck Collide\nif <touching (level v)?> then\n    repeat (10)\n        change [player y v] by (1)\n        Check Collide\n        if <not <touching (level v)?>> then\n            stop [this script v]\n        end\n    end\n    change [player y v] by (-10)\n    repeat until <not <touching (level 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        set [player sx v] to [0]\n        Check Collide\n    end\nend\n\ndefine Momentum (dx) (dy)\nchange [player sx v] by (dx)\nchange [player sy v] by (dy)\nCheck Collide\n\ndefine Check Collide\ngo to x: ((PLAYER X) - (SCROLL X)) y: ((PLAYER Y) - (SCROLL Y))\n\ndefine Change Player y by (sy)\nset [slide? v] to [0]\nchange [player y v] by (sy)\nchange [falling v] by (1)\nCheck Collide\nif <touching (level v)?> then\n    change [player x v] by (-1)\n    Check Collide\n    if <not <touching (level v)?>> then\n        set [slide? v] to [1]\n    end\n    change [player x v] by (1)\n    Check Collide\nend\nrepeat until <not <touching (level v)?>>\n    if <(sy) > [0]> then\n        change [player y v] by (-1)\n    else\n        change [player y v] by (1)\n        set [falling v] to [0]\n    end\n    set [player sy v] to [0]\n    Check Collide\nend\n\ndefine Get Scrolling\nchange [scroll x v] by (round ((((PLAYER X) + (center)) - (SCROLL X)) * (0.1)))\nif <(PLAYER DIR) > (center)> then\n    change [center v] by (2)\nelse\n    change [center v] by (-2)\nend\nif <(SCROLL X) < [0]> then\n    set [scroll x v] to [0]\nend\nchange [scroll y v] by (round (((PLAYER Y) - (SCROLL Y)) * (0.1)))\nif <(SCROLL Y) < [0]> then\n    set [scroll y v] to [0]\nend\nCheck Collide\n\nif <(Slide?) = <touching (_edge_ v)?>> then\n    Momentum [-1] [-1]\nend\nset [slide? v] to [0]\n\nwhen [space v] key pressed\n\nGame On\n\ndefine Walk\npoint in direction (PLAYER DIR)\nset rotation style [left-right v]\nif <(FALLING) < [6]> then\n    if <([abs v] of (PLAYER SX) ) > [1]> then\n        switch costume to ([floor v] of ((2) + ((FRAME) mod (4))) )\n        if <(SOUND?) = [YES]> then\n            if <(Sound 1 is done?) = [0]> then\n                broadcast (Foot v)\n            end\n        end\n    else\n        switch costume to (stand v)\n    end\nelse\n    if <(PLAYER SY) > [0]> then\n        switch costume to (jump v)\n    else\n        switch costume to (fall v)\n    end\nend\n\ndefine Game ~ win\nchange [level v] by (1)\nswitch costume to (win v)\nset [player sy v] to [0]\nrepeat until <(y position) > [180]>\n    change [player sy v] by (.5)\n    change [player y v] by (PLAYER SY)\n    Check Collide\n    change [brightness v] effect by (5)\n    change volume by (-10)\nend\nif <(LEVEL) > [3]> then\n    broadcast (Win Da Hole Game v) and wait\nend\nbroadcast (Level complete v) and wait\n\ndefine Game ~ die\nif <(SOUND?) = [YES]> then\n    start sound [hurt v]\nend\nswitch costume to (die v)\nset [player sy v] to [15]\nset rotation style [all around v]\npoint in direction (90)\nchange [player y v] by (20)\nCheck Collide\nrepeat until <(y position) < [-180]>\n    change [player sy v] by (-1)\n    change [player y v] by (PLAYER SY)\n    Check Collide\n    turn right (15) degrees\n    change volume by (-10)\nend\nclear sound effects\nhide\nwait (1) seconds\n\nshow variable [time v]\n\nwhen I receive [setup v]\nclear sound effects\nset volume to (100) %\nif <(MUSIC?) = [YES]> then\n    broadcast (Music v)\nend\n\nstart sound [happy tech v]\n\nchange volume by (-10)\n\nstart sound [jump v]\n\nstart sound [footstep concrete v]\n\nwhen I receive [foot v]\nset [sound 1 is done? v] to [1]\nplay sound [WalkOnRocks2 v] until done\nset [sound 1 is done? v] to [0]\n\nwait (.001) seconds\n\nwhen I receive [music v]\nplay sound [happy tech v] until done\nplay sound [happy tech v] until done\nplay sound [happy tech v] until done\nplay sound [happy tech v] until done\nplay sound [happy tech v] until done\nplay sound [happy tech v] until done\n\n@Level\n\nwhen I receive [tick v]\nPosition of ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [setup v]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1 1 v)\n    Create Clone of [360] [0]\n    Create Clone of [400] [0]\n    Create Clone of [360] [0]\n    Create Clone of [360] [0]\n    Create Clone of [500] [0]\n    Create Clone of [0] [360]\n    Create Clone of [360] [100]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2 1 v)\n        Create Clone of [500] [0]\n        Create Clone of [300] [0]\n        Create Clone of [320] [0]\n        Create Clone of [320] [0]\n        Create Clone of [320] [0]\n    else\n        switch costume to (level 3 1 v)\n        Create Clone of [360] [0]\n        Create Clone of [360] [0]\n        Create Clone of [360] [0]\n        Create Clone of [600] [0]\n        Create Clone of [500] [0]\n        Create Clone of [500] [0]\n    end\nend\n\ndefine Create Clone of (x) (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\ndefine Position of (x) (y)\ngo to x: (x) y: (y)\nset [is showing? v] to <<(x) = (x position)> and <(y) = (y position)>>\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\n@Paralax\n\nwhen I receive [tick v]\nPosition of ((((SCROLL X) * (-.5)) mod (478)) - (x)) ((((SCROLL Y) * (-.5)) mod (279)) - (y))\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [setup v]\ngo to [back v] layer\nshow\nswitch costume to (paralax2 v)\nset [x v] to [0]\nset [y v] to [0]\ncreate clone of (_myself_ v)\nset [x v] to [479]\nset [y v] to [0]\ncreate clone of (_myself_ v)\nset [x v] to [0]\nset [y v] to [280]\ncreate clone of (_myself_ v)\nset [x v] to [479]\nset [y v] to [280]\n\ndefine Position of (x) (y)\ngo to x: (x) y: (y)\nset [is showing? v] to <<(x) = (x position)> and <(y) = (y position)>>\nif <(LEVEL) = [1]> then\n    if <<(x) = (x position)> and <(y) = (y position)>> then\n        show\n    else\n        hide\n    end\nelse\n    hide\nend\n\n@Tiles&Tests\n\nwhen this sprite clicked\n\ngo to x: (0) y: (0)\n\nsay [Hello!] for (2) seconds\n\nset size to (100) %\n\nchange x by (10)\n\npoint towards (mouse-pointer v)\n\nchange y by (10)\n\nset [falling v] to [0]\n\nchange [player x v] by (1)\n\n@Enemy\n\nwhen I receive [enemy tick v]\n\nPosition of ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <(is showing?) = [true]> then\n    if <(way) = [1]> then\n        change [x v] by (-2)\n    end\n    if <(way) = [2]> then\n        change [x v] by (2)\n    end\n    Position of ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n    Slope\n    Position of ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n    change [sy v] by (-1)\n    change [y v] by (sy)\n    Position of ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n    if <touching (level v)?> then\n        change [y v] by ((0) - (sy))\n        set [sy v] to [0]\n    end\n    Position of ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nend\nPosition of ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [tick v]\nPosition of ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\ndefine Position of (x) (y)\ngo to x: (x) y: (y)\nset [is showing? v] to <<(x) = (x position)> and <(y) = (y position)>>\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 I receive [setup v]\nset [x v] to [-9999999999999999]\n\nCreate clone of [Monster1] at x [1329] y [0] start going [1]\nCreate clone of [Monster1] at x [1350] y [0] start going [1]\n\ndefine Slope\nif <touching (level v)?> then\n    repeat (10)\n        change [y v] by (1)\n        Position of ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n        if <not <touching (level v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-10)\n    if <(way) = [1]> then\n        set [way v] to [2]\n        change [x v] by (2)\n    else\n        if <(way) = [2]> then\n            set [way v] to [1]\n            change [x v] by (-2)\n        end\n    end\n    Position of ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nend\n\ndefine Create clone of (monster) at x (x) y (y) start going (way)\nset [x v] to (x)\nset [y v] to (y)\nset [way v] to (way)\nset [is showing? v] to [false]\nset [sy v] to [0]\nswitch costume to (monster)\ncreate clone of (_myself_ v)\n\n@Story\n\nwhen flag clicked\nswitch costume to (1 v)\nrepeat (4)\n    next costume\n    wait (.05) seconds\nend\n\n@Collectables\n\nwhen I receive [tick v]\nPosition of ((x) - (SCROLL X)) (((y) + (([sin v] of ((frame) * (10)) ) * (20))) - (SCROLL Y))\nif <touching (cat v)?> then\n    change [collected v] by (1)\n    if <(SOUND?) = [YES]> then\n        start sound [pop v]\n    end\n    if <(COLLECTED) = (COLLECTED MAX)> then\n        set [end v] to [win]\n    end\n    delete this clone\nend\n\ndefine Position of (x) (y)\nchange [frame v] by (.5)\nswitch costume to ([floor v] of ((1) + ((frame) mod (7))) )\nset size to ((100) + (([sin v] of ((frame) * (20)) ) * (20))) %\ngo to x: (x) y: (y)\nset [is showing? v] to <<(x) = (x position)> and <(y) = (y position)>>\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nset [brightness v] effect to ((0) + (([sin v] of ((frame) * (20)) ) * (20)))\n\nwhen I receive [setup v]\nset [collected max v] to [0]\nset [collected v] to [0]\nswitch costume to (ani1 v)\nif <(LEVEL) = [1]> then\n    Create Clone of [57] [19]\n    Create Clone of [203] [66]\n    Create Clone of [358] [173]\n    Create Clone of [725] [125]\n    Create Clone of [915] [138]\n    Create Clone of [1488] [97]\n    Create Clone of [2544] [587]\nelse\n    if <(LEVEL) = [2]> then\n        Create Clone of [135] [-8]\n        Create Clone of [377] [31]\n        Create Clone of [542] [49]\n        Create Clone of [698] [6]\n        Create Clone of [939] [37]\n        Create Clone of [1198] [134]\n        Create Clone of [1410] [141]\n        Create Clone of [1442] [40]\n        Create Clone of [1515] [-40]\n        Create Clone of [1677] [-40]\n        Create Clone of [1867] [-24]\n        Create Clone of [1866] [162]\n    else\n        Create Clone of [132] [50]\n        Create Clone of [291] [70]\n        Create Clone of [470] [-17]\n        Create Clone of [731] [84]\n        Create Clone of [958] [23]\n        Create Clone of [1291] [85]\n        Create Clone of [1684] [119]\n        Create Clone of [2153] [73]\n        Create Clone of [2707] [47]\n        Create Clone of [2960] [101]\n    end\nend\nset [x v] to [-9999999999999999999999999999]\nset [y v] to [0]\n\ndefine Create Clone of (x) (y)\nset [x v] to (x)\nset [y v] to (y)\nset [frame v] to (pick random (1) to (200))\nchange [collected max v] by (1)\ncreate clone of (_myself_ v)\n\nwhen I receive [reset v]\ndelete this clone\n\n@0\n\nwhen I receive [level complete v]\nshow\ngo to [front v] layer\nhide variable [time v]\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\nrepeat (20)\n    change [ghost v] effect by (-5)\nend\nwait (1) seconds\n\nwhen I receive [setup v]\nhide\n\nwhen I receive [out v]\nrepeat (20)\n    change [ghost v] effect by (5)\nend\nhide\n\n@Scores\n\nwhen I receive [button v]\n\ngo to [front v] layer\nshow list [level 1 high score v]\nshow\nforever\n    if <<mouse down?> and <touching (mouse-pointer v)?>> then\n        wait until <not <mouse down?>>\n        broadcast (See score v) and wait\n        hide list [level 1 high score v]\n    end\nend\n\nwhen I receive [play game v]\n\nhide\nstop [other scripts in sprite v]\nshow list [level 1 high score v]\n\n@Cloud Data\n\ndefine write (val) to encoded\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 [check time v]\nif <(TIME) < ((☁ High 1) + (5))> then\n    set [☁ high 1 v] to (TIME)\n    set [encoded v] to []\n    write (join (username) (join [ at ] (join (☁ High 1) [ seconds]))) to encoded\n    set [☁ cloud 1 v] to (encoded)\nend\nbroadcast (See score v) and wait\n\ndefine value = read from encoded\nset [value v] to []\nset [letter# v] to [1]\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\nset [☁ high 1 v] to [80808080]\nset [☁ high 2 v] to [80808080]\nset [encoded v] to []\nwrite (join (username) (join [ at ] (join (☁ High 1) [ seconds]))) to encoded\nset [☁ cloud 1 v] to (encoded)\n\nwhen I receive [see score v]\nset [encoded v] to (☁ CLOUD 1)\nvalue = read from encoded\ndelete all of [level 1 high score v]\nadd (value) to [level 1 high score v]\n\nset [encoded v] to (☁ CLOUD 1)\nvalue = read from encoded\ndelete all of [level 1 high score v]\nadd (value) to [level 1 high score v]\n\n@If level 2\n\nwhen I receive [setup v]\nif <(LEVEL) = [2]> then\n    switch costume to (home page v)\n    show\nelse\n    if <(LEVEL) = [3]> then\n        switch costume to (my profile v)\n        show\n    else\n        switch costume to (the code v)\n        show\n    end\nend\n\nhide\n\n@End\n\nwhen I receive [win da hole game v]\ngo to [front v] layer\nset size to (0) %\nshow\nrepeat (10)\n    change size by (10)\nend\nforever\n    play sound [happy tech v] until done\nend\n\nwhen flag clicked\nhide\n\n