Stickman - Platformer

Instructions:                          -- Stickman - Platformer --\n- Use arrow keys/WASD or tap screen to move, (Space \n  bar is also for jump).\n- Press M or tap on the sound icon to mute/unmute.\n- Press H or tap on the player to toggle high contrast \n  mode. In case it's hard to see.\n- Get to the end. There's currently 22 levels to play.\n- Leave a love, favorite, follow if you like it!\n\nI really hope you guys like it!

@Stage\n\nwhen flag clicked\n\nforever\n    play sound [Nightime-SoundBible v] until done\nend\n\nwhen flag clicked\nswitch backdrop to (backdrop1 v)\nset volume to (40) %\nset [stage: hc v] to []\nforever\n    play sound [Video Game 1 v] until done\nend\n\nwhen I receive [mute/unmute v]\nif <(volume) = [0]> then\n    set volume to (40) %\nelse\n    set volume to (0) %\nend\n\nwhen I receive [high contrast v]\nif <(Stage: HC) > []> then\n    set [brightness v] effect to (0)\n    set [stage: hc v] to []\nelse\n    set [brightness v] effect to (100)\n    set [stage: hc v] to [1]\nend\n\n@Player\n\nwhen flag clicked\nset volume to (100) %\nset [i v] to [1]\nset [level v] to [1]\nset [win v] to []\nset [hc v] to []\nswitch costume to (stand v)\nbroadcast (Level v) and wait\nbroadcast (Game on v)\n\ndefine Jump\nif <(YC) > [0]> then\n    if <(falling) < [3]> then\n        set [sy v] to [10]\n    end\nend\n\ndefine Slope\nset [slope v] to [0]\nrepeat until <<(slope) = [8]> or <not <touching (level v)?>>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <touching (level v)?> then\n    change x by ((-1) * (sx))\n    set [sx v] to [0]\n    change y by ((0) - (slope))\nend\n\ndefine x\nset [x key v] to (<(XC) > [0]> - <(XC) < [0]>)\nif <(x key) = [0]> then\n    if <([abs v] of (sx) ) < [1]> then\n        set [sx v] to [0]\n    end\n    set [frame v] to [0]\nelse\n    point in direction ((90) * (x key))\n    change [sx v] by ((x key) * (1.7))\n    change [frame v] by (0.3)\n    if <(timer) > ((sound) + (0.25))> then\n        if <not <(falling) > [0]>> then\n            start sound [Footsteps2 v]\n            set [sound v] to (timer)\n        end\n    end\nend\nset [sx v] to ((sx) * (0.8))\nchange x by (sx)\nSlope\n\ndefine y\nJump\nchange [falling v] by (1)\nif <<(sy) < [4]> or <(YC) > [0]>> then\n    change [sy v] by (-1)\nelse\n    change [sy v] by (-2)\nend\nchange y by (sy)\nrepeat until <not <touching (level v)?>>\n    if <(sy) > [0]> then\n        change y by ((-1) * (sy))\n    else\n        change y by (1)\n        set [falling v] to [0]\n    end\n    set [sy v] to [0]\nend\n\ndefine Set player costume\nif <(falling) < [3]> then\n    if <(frame) = [0]> then\n        switch costume to (stand v)\n    else\n        switch costume to ([floor v] of ((1) + ((frame) mod (4))) )\n    end\nelse\n    if <(sy) > [0]> then\n        if <(timer) > ((sound) + (0.32))> then\n            start sound [Boing v]\n            set [sound v] to (timer)\n        end\n        switch costume to (jump v)\n    else\n        switch costume to (fall2 v)\n    end\nend\n\ndefine Next Level\nif <(x position) < [-239]> then\n    change [level v] by (-1)\n    set x to (238)\n    broadcast (Level v) and wait\n    Fix collision [0]\nend\nif <(x position) > [239]> then\n    change [level v] by (1)\n    set x to (-238)\n    broadcast (Level v) and wait\n    Fix collision [0]\nend\n\ndefine Fix collision (dir)\nset [dir v] to (direction)\nset [dist v] to [1]\npoint in direction (dir)\nrepeat (128)\n    if <not <touching (level v)?>> then\n        point in direction (dir)\n        stop [this script v]\n    end\n    move (dist) steps\n    turn right (180) degrees\n    change [dist v] by (1)\nend\nbroadcast (Death v)\npoint in direction (dir)\n\ndefine Death\nif <<touching (lava/spike v)?> or <(y position) < [-193]>> then\n    broadcast (Death v)\nend\n\nwhen I receive [death v]\nstop [other scripts in sprite v]\nrepeat (20)\n    change size by (5)\n    change [ghost v] effect by (5)\nend\nhide\nset size to (50) %\nset [ghost v] effect to (0)\nbroadcast (Level v) and wait\nbroadcast (Game on v)\n\nwhen I receive [game on v]\nReset\ngo to x: (-190) y: (-120)\nshow\nforever\n    switch costume to (hitbox v)\n    set rotation style [don't rotate v]\n    x\n    y\n    Next Level\n    Death\n    set rotation style [left-right v]\n    Set player costume\n    win?\nend\n\ndefine Reset\nset [sy v] to [0]\nset [sx v] to [0]\nset [sound v] to [-99]\nset [falling v] to [99]\nset size to (50) %\nset [ghost v] effect to (0)\nFix collision [0]\n\nwhen I start as a clone\nset [ghost v] effect to (0)\nrepeat (10)\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\ncreate clone of (_myself_ v)\n\ndefine win?\nif <(WIN) > []> then\n    change [color v] effect by (5)\n    if <touching color (#ffad00)?> then\n        set [sy v] to [30]\n    end\nend\n\nwhen I receive [mute/unmute v]\nif <(volume) = [0]> then\n    set volume to (100) %\nelse\n    set volume to (0) %\nend\n\nwhen [h v] key pressed\nbroadcast (High contrast v)\n\nwhen I receive [high contrast v]\nif <(HC) > []> then\n    set [brightness v] effect to (0)\n    set [hc v] to []\nelse\n    set [brightness v] effect to (-100)\n    set [hc v] to [1]\nend\n\nwhen this sprite clicked\nbroadcast (High contrast v)\n\n@Level\n\nwhen flag clicked\ngo to x: (0) y: (0)\n\nwhen I receive [level v]\nswitch costume to (LEVEL)\n\nwhen I receive [mute/unmute v]\nif <(volume) = [0]> then\n    set volume to (100) %\nelse\n    set volume to (0) %\nend\n\n@Lava/spike\n\nwhen flag clicked\ngo to x: (0) y: (0)\n\nwhen I receive [level v]\ngo to [back v] layer\nswitch costume to (LEVEL)\n\nwhen I receive [mute/unmute v]\nif <(volume) = [0]> then\n    set volume to (100) %\nelse\n    set volume to (0) %\nend\n\n@control\n\nwhen flag clicked\nforever\n    set [xc v] to (<<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(mouse x) > ([x position v] of [player v])>>> - <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(mouse x) < ([x position v] of [player v])>>>)\n    set [yc v] to (<<<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <key (space v) pressed?>> or <<mouse down?> and <(mouse y) > [-20]>>> - ())\nend\n\nwhen I receive [mute/unmute v]\nif <(volume) = [0]> then\n    set volume to (100) %\nelse\n    set volume to (0) %\nend\n\n@LEVEL TEXT\n\nwhen I start as a clone\nshow\nforever\n    Color text (HC)\n    change costume to (letter (index) of (TEXT))\n    set x to ((((index) - (0.5)) - ((length of (TEXT)) / (2))) * ((size) / (1.65)))\n    change size by ((0.2) * ((size) - (size)))\nend\n\ndefine Setup\nset [index v] to [1]\nrepeat (length of (TEXT))\n    create clone of (_myself_ v)\n    change x by ((size) / (1))\n    change [index v] by (1)\nend\nhide\n\ndefine change costume to (costume)\nif <not <(costume) = (costume [name v])>> then\n    switch costume to ( v)\n    switch costume to (costume)\nend\n\nwhen I receive [clear clones v]\ndelete this clone\n\ndefine Create text: (text) at y: (y) with a size of (size)\nbroadcast (CLEAR CLONES v)\nset [size v] to (size)\nset [text v] to (text)\ngo to x: (x) y: (y)\nSetup\n\nwhen I receive [level v]\nSwitch level\n\nwhen I receive [mute/unmute v]\nif <(volume) = [0]> then\n    set volume to (100) %\nelse\n    set volume to (0) %\nend\n\ndefine Switch level\nif <(LEVEL) < [23]> then\n    Create text: (join [LEVEL:] (LEVEL)) at y: [157] with a size of [30]\n    switch backdrop to (backdrop1 v)\nelse\n    Create text: [Thanks for PIaying!] at y: [157] with a size of [30]\n    switch backdrop to (backdrop2 v)\n    set [win v] to [1]\nend\n\nwhen I receive [high contrast v]\nif <(HC) > []> then\n    set [hc v] to []\nelse\n    set [hc v] to [1]\nend\n\nwhen flag clicked\nset [hc v] to []\n\ndefine Color text (brightness)\nif <(brightness) > []> then\n    set [brightness v] effect to (-100)\nelse\n    set [brightness v] effect to (100)\nend\n\n@mute/unmute\n\nwhen flag clicked\ngo to x: (-221) y: (161)\nswitch costume to (unmuted v)\n\nwhen this sprite clicked\nbroadcast (Mute/Unmute v)\nnext costume\n\nwhen [m v] key pressed\nbroadcast (Mute/Unmute v)\nnext costume\n\n@Thumbnail\n\nwhen flag clicked\ngo to x: (0) y: (0)\nshow\nset [ghost v] effect to (100)\ngo to [front v] layer\n\n