The Adventures of Scratch Cat -- Platformer

Instructions: A or left arrow key: Move left\nD or right arrow key: Move right\nW or up arrow key: Jump (Hold to jump slightly higher)\nS or down arrow key: Fall through platforms\nTo wall jump: Start away from the wall and hit the wall while still ascending. Keep holding the direction of the wall until you are done wall jumping. Do not switch keys in the middle of a wall jump.\nE to show how many stars and deaths you have.\nBe sure to report any glitch or suggestion in the comments!\nPress the sun icon to turn off the sun if it is causing the program to lag.\nPress the sound icon to turn on or off the sound.

@Stage\n\nwhen flag clicked\nset volume to (50) %\nforever\n    repeat (3)\n        repeat (5)\n            play sound [medieval1 v] until done\n        end\n        wait (3) seconds\n        repeat (5)\n            play sound [medieval2 v] until done\n        end\n        wait (3) seconds\n    end\n    wait (3) seconds\n    repeat (2)\n        repeat (5)\n            play sound [guitar chords1 v] until done\n        end\n        wait (1) seconds\n        repeat (5)\n            play sound [guitar chords2 v] until done\n        end\n        wait (1) seconds\n    end\n    wait (3) seconds\nend\n\nwhen I receive [right v]\nrepeat (pick random (1) to (1))\n    next backdrop\nend\n\nwhen flag clicked\nforever\n    if <(Sound) = [1]> then\n        set volume to (50) %\n    else\n        set volume to (0) %\n    end\nend\n\n@Ground\n\nwhen I receive [right v]\nnext costume\n\nwhen flag clicked\nswitch costume to (costume1 v)\ngo to x: (0) y: (0)\n\n@Platforms\n\nwhen I receive [right v]\nnext costume\n\nwhen flag clicked\nswitch costume to (costume1 v)\ngo to x: (0) y: (0)\nforever\n    if <(costume [number v]) > [8]> then\n        change y by (1)\n        wait (0.05) seconds\n        change y by (-1)\n        wait (0.05) seconds\n    end\nend\n\n@Player\n\ndefine Controls - Jump, Crouch\nif <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n    if <<(jump key) = [0]> and <(falling?) < [3]>> then\n        start sound [pop v]\n        set [speed y v] to [14]\n        set [falling? v] to [6]\n        set [jump key v] to [1]\n    end\nelse\n    set [jump key v] to [0]\nend\nif <<key (s v) pressed?> or <key (down arrow v) pressed?>> then\n    set [in platforrm v] to [2]\nend\nif <touching color (#ff9999)?> then\n    if <<(jump key) = [0]> and <(falling?) < [3]>> then\n        start sound [pop v]\n        set [speed y v] to [20]\n        set [falling? v] to [6]\n        set [jump key v] to [1]\n    end\nelse\n    set [jump key v] to [0]\nend\nif <<key (s v) pressed?> or <key (down arrow v) pressed?>> then\n    set [in platforrm v] to [2]\nend\n\ndefine Check Hit Ceiling / Floor <>\nGet Touching <not >\nif <(touch) = [0]> then\n    set [in platforrm v] to [1]\nelse\n    if <<up?> and <(touch) = [1]>> then\n        set [in platforrm v] to [2]\n    end\nend\nrepeat until <(touch) < (in platforrm)>\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    Get Touching <not <up?>>\n    set [speed y v] to [0]\nend\n\ndefine Set Costume\nif <(falling?) < [6]> then\n    if <(frame) = [0]> then\n        switch costume to (stand_1 v)\n    else\n        switch costume to ([floor v] of ((4) + ((frame) mod (8))) )\n    end\nelse\n    if <(speed y) > [0]> then\n        switch costume to (jump_1 v)\n    else\n        switch costume to (fall_1 v)\n    end\nend\n\ndefine Reset Level_Lose\nchange [deaths v] by (1)\nchange [☁ all deaths v] by (1)\nstart sound [meow2 v]\ngo to [front v] layer\nset size to (25) %\nset rotation style [left-right v]\ngo to x: (-175) y: (200)\nreset timer\nshow\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [falling? v] to [10]\nset [in platforrm v] to [1]\nset [frame v] to [0]\nset [wall jump v] to [0]\n\ndefine Get Touching <>\nif <touching (ground v)?> then\n    set [touch v] to [9]\nelse\n    if <<check platform?> and <touching (platforms v)?>> then\n        set [touch v] to [1]\n    else\n        set [touch v] to [0]\n    end\nend\n\ndefine Check For Next Level\nif <(x position) > [220]> then\n    broadcast (Right v)\n    Reset Level_Win\nend\n\ndefine None\npoint in direction (direction)\nchange x by (speed)\nchange [frame v] by (([abs v] of (speed) ) / (8))\nset [slope v] to [0]\nGet Touching <(in platforrm) = [1]>\nrepeat until <<(slope) = (max steep)> or <(touch) = [0]>>\n    change y by (1)\n    change [slope v] by (1)\n    Get Touching <(in platforrm) = [1]>\nend\nif <(slope) = (max steep)> then\n    change x by ((0) - (speed))\n    change y by ((0) - (slope))\n    if <<(touch) = [1]> and <(in platforrm) = [1]>> then\n        set [in platforrm v] to [2]\n        Walk (direction) (speed) max steep (max steep)\n        if <(speed x) = [0]> then\n            set [in platforrm v] to [1]\n        end\n    else\n        if <<<<key (w v) pressed?> or <key (up arrow v) pressed?>> and <([abs v] of (speed) ) > [3.5]>> and <(touch) > [1]>> then\n            start sound [boing v]\n            set [speed x v] to ((-1.2) * (speed))\n            set [speed y v] to [11]\n            set [falling? v] to [6]\n            set [wall jump v] to [15]\n        else\n            set [speed x v] to [0]\n        end\n    end\nend\n\ndefine Reset Level_Win\ngo to [front v] layer\nset size to (25) %\nset rotation style [left-right v]\ngo to x: (-175) y: (200)\nreset timer\nshow\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [falling? v] to [10]\nset [in platforrm v] to [1]\nset [frame v] to [0]\nset [wall jump v] to [0]\n\ndefine Controls - Left and Right\nset [speed x v] to ((speed x) * (0.7))\nif <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n    change [speed x v] by (-1.5)\nend\nif <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n    change [speed x v] by (1.5)\nend\n\nwhen flag clicked\nset [deaths v] to [0]\nReset Level_Win\nforever\n    switch costume to (hitbox v)\n    Check For Next Level\n    Controls - Jump, Crouch\n    Gravity\n    Check Hit Ceiling / Floor <(speed y) > [0]>\n    if <key (e v) pressed?> then\n        if <(Var) = [0]> then\n            show variable [stars: v]\n            show variable [deaths v]\n            set [var v] to [1]\n        else\n            hide variable [stars: v]\n            hide variable [deaths v]\n            set [var v] to [0]\n        end\n    end\n    if <(y position) < [-189]> then\n        Reset Level_Lose\n    end\n    if <touching (death v)?> then\n        set [speed y v] to [14]\n        Reset Level_Lose\n    end\n    if <(wall jump) > [0]> then\n        change [wall jump v] by (-1)\n    else\n        Controls - Left and Right\n    end\n    if <(speed x) < [-0.5]> then\n        Walk (-90) (speed x) max steep (([ceiling v] of ([abs v] of ((speed x) * (1.3)) ) ) + (1))\n    else\n        if <(speed x) > [0.5]> then\n            Walk (90) (speed x) max steep (([ceiling v] of ([abs v] of ((speed x) * (1.3)) ) ) + (1))\n        else\n            set [frame v] to [0]\n        end\n    end\n    Set Costume\n    broadcast (tick v) and wait\nend\n\ndefine Gravity\nif <<(speed y) < [4]> or <<key (w v) pressed?> or <<key (up arrow v) pressed?> or <touching color (#ff9999)?>>>> then\n    change [speed y v] by (-1)\nelse\n    change [speed y v] by (-1)\nend\nchange y by (speed y)\nchange [falling? v] by (1)\n\nwhen flag clicked\nforever\n    if <(Sound) = [1]> then\n        set volume to (100) %\n    else\n        set volume to (0) %\n    end\nend\n\n@Signs\n\nwhen I receive [right v]\nnext costume\nnext costume\n\nwhen flag clicked\nswitch costume to (costume1 v)\ngo to x: (0) y: (0)\nforever\n    if <touching (player v)?> then\n        next costume\n        wait until <not <touching (player v)?>>\n        switch costume to ((costume [number v]) - (1))\n    end\nend\n\n@Death\n\nwhen I receive [right v]\nnext costume\n\nwhen flag clicked\nswitch costume to (costume1 v)\ngo to x: (0) y: (0)\n\n@Stars\n\ndefine None\nrepeat (number of clones)\n    create clone of (_myself_ v)\nend\n\nwhen flag clicked\nset [ghost v] effect to (100)\nset [stars: v] to [0]\ndelete (all) of [x v]\ndelete (all) of [y v]\nSet Star Locations\nset size to (75) %\ngo to x: (0) y: (0)\n\ndefine Set Star Locations\nadd [0] to [x v]\nadd [0] to [y v]\nadd [0] to [x v]\nadd [-90] to [y v]\nadd [-75] to [x v]\nadd [100] to [y v]\nadd [110] to [x v]\nadd [-145] to [y v]\nadd [50] to [x v]\nadd [170] to [y v]\nadd [-235] to [x v]\nadd [80] to [y v]\nadd [40] to [x v]\nadd [-60] to [y v]\nadd [80] to [x v]\nadd [-50] to [y v]\nadd [30] to [x v]\nadd [125] to [y v]\nadd [-20] to [x v]\nadd [130] to [y v]\nadd [160] to [x v]\nadd [150] to [y v]\nadd [200] to [x v]\nadd [-25] to [y v]\nadd [0] to [x v]\nadd [25] to [y v]\n\ndefine Collect\nchange [stars: v] by (1)\nchange [☁ all stars v] by (1)\nstart sound [fairydust v]\nset size to (100) %\nrepeat (5)\n    change size by (10)\nend\nrepeat (5)\n    change [ghost v] effect by (10)\n    change size by (-20)\nend\nset [ghost v] effect to (100)\n\nwhen I start as a clone\nshow\nclear graphic effects\ngo to x: (item ([costume # v] of [ground v]) of [x v]) y: (item ([costume # v] of [ground v]) of [y v])\nwait until <<touching (player v)?> or <([x position v] of [player v]) > [220]>>\nif <touching (player v)?> then\n    Collect\n    delete this clone\nelse\n    delete this clone\nend\n\nwhen I receive [right v]\nCreate (1) Clones\n\nwhen flag clicked\nforever\n    if <(Sound) = [1]> then\n        set volume to (100) %\n    else\n        set volume to (0) %\n    end\nend\n\n@Sun\n\nwhen flag clicked\nset [rotate v] to [0]\nset rotation style [all around v]\npoint in direction (90)\ngo to x: (0) y: (-180)\ngo [backward v] (999) layers\nset [ghost v] effect to (0)\nset size to (200) %\nforever\n    if <(Lag) = [1]> then\n        show\n        turn right (0.1) degrees\n        wait (0.25) seconds\n    else\n        hide\n    end\nend\n\n@Sun_icon\n\nwhen flag clicked\ngo to x: (220) y: (160)\nset [brightness v] effect to (0)\nset [lag v] to [1]\n\nwhen this sprite clicked\nif <(Lag) = [1]> then\n    set [lag v] to [0]\n    set [brightness v] effect to (-50)\nelse\n    set [lag v] to [1]\n    set [brightness v] effect to (0)\nend\n\n@Sound_icon\n\nwhen flag clicked\nset size to (50) %\ngo to x: (170) y: (155)\n\nwhen this sprite clicked\nif <(Sound) = [1]> then\n    set [sound v] to [0]\n    next costume\nelse\n    set [sound v] to [1]\n    next costume\nend\n\n