Prison break || A platformer

Instructions: New game: https://scratch.mit.edu/projects/502695389\n\nUse the arrow keys, WASD or drag your mouse / finger to move the prisoner.\nSome levels, prisoners are dangerous, others, they're not. Escape the prison. You can choose how many lives you have heading into the game play!\nAlso, you must avoid sports equipment, the basketballs can hit your head and baseball bats are dangerous!\nHave fun with it!

@Stage\n\nwhen flag clicked\nforever\n    play sound [Bossfight - Wobbly Tooth, Crunchy Apple v] until done\nend\n\n@Sprite2\n\nwhen flag clicked\nset [deaths v] to [0]\nbroadcast (start/restart level v)\nset [xv v] to [0]\nset [yv v] to [0]\ngo to x: (0) y: (0)\nforever\n    Physics [1] [0.9] [15]\nend\n\ndefine Physics (speed) (friction) (jump height)\nchange [yv v] by (-1)\nif <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(x position) < (mouse x)>>> then\n    change [xv v] by (speed)\n    point in direction (90)\nend\nif <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(mouse x) < (x position)>>> then\n    change [xv v] by ((speed) * (-1))\n    point in direction (-90)\nend\nset [xv v] to ((Xv) * (friction))\nchange x by (Xv)\nset [slope v] to [0]\nif <touching (main level v)?> then\n    repeat until <<not <touching (main level v)?>> or <(slope) = [-8]>>\n        change [slope v] by (-1)\n        change y by (1)\n    end\nend\nif <<touching (main level v)?> or <touching (locked v)?>> then\n    change y by (slope)\n    repeat until <not <<touching (main level v)?> or <touching (locked v)?>>>\n        change x by ((([abs v] of (Xv) ) / (Xv)) * (-1))\n    end\nend\nchange y by (Yv)\nif <touching (main level v)?> then\n    repeat until <not <touching (main level v)?>>\n        change y by ((([abs v] of (Yv) ) / (Yv)) * (-1))\n    end\n    set [yv v] to [0]\nend\nif <not <touching (sprite13 v)?>> then\n    change y by (-1)\n    if <<<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(y position) < (mouse y)>>> and <touching (main level v)?>> then\n        set [yv v] to (jump height)\n    end\n    change y by (1)\nelse\n    set [yv v] to [0]\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(y position) < (mouse y)>>> then\n        change y by (4)\n    end\nend\n\nwhen I receive [start/restart level v]\nset [yv v] to [0]\nset [key collected? v] to [no]\nhide\ngo to x: (-215) y: (-60)\nshow\n\nwhen flag clicked\nforever\n    if <<<touching (saws v)?> or <touching (still obstacles v)?>> or <<touching (lava v)?> or <<touching (basketball v)?> or <<touching (baseball player v)?> or <touching (wild dog v)?>>>>> then\n        change [deaths v] by (1)\n        broadcast (start/restart level v)\n    end\n    if <[230] < (x position)> then\n        broadcast (next level v)\n    end\n    if <(y position) < [-170]> then\n        change [deaths v] by (1)\n        broadcast (start/restart level v)\n    end\nend\n\nwhen I receive [next level v]\nchange [backdrop v] by (1)\nbroadcast (start/restart level v)\n\nwhen flag clicked\nforever\n    if <touching (trampoline v)?> then\n        set [yv v] to [20]\n    end\nend\n\nwhen flag clicked\nforever\n    if <<<<<<key (left arrow v) pressed?> or <<key (right arrow v) pressed?> or <<key (d v) pressed?> or <key (a v) pressed?>>>> or <<mouse down?> and <(x position) < (mouse x)>>> or <<mouse down?> and <(mouse x) < (x position)>>> and <(Yv) = [0]>> and <not <touching (sprite13 v)?>>> then\n        next costume\n        wait (0) seconds\n    else\n        switch costume to (costume1 v)\n    end\nend\n\nbroadcast (lobby v)\n\nwhen I receive [start game v]\nset [deaths v] to [0]\ngo to x: (-215) y: (-60)\n\nwhen I receive [start game v]\nwait until <(Deaths) = (Death requirement)>\nstop [all v]\n\n@main level\n\nwhen flag clicked\nset [backdrop v] to [1]\nforever\n    set [brightness v] effect to (([y position v] of [sprite3 v]) / (15))\n    switch costume to (backdrop)\n    go to [front v] layer\n    go [backward v] (11) layers\nend\n\nset [backdrop v] to [14]\n\nchange [backdrop v] by (-1)\n\n@Sprite1\n\nwhen flag clicked\nshow\nswitch costume to (costume1 v)\nset [brightness v] effect to (-100)\nset size to (142) %\ngo to x: (0) y: (0)\nrepeat (100)\n    change [brightness v] effect by (1)\n    change size by (-0.2)\nend\nbroadcast (buttons v)\n\nwhen I receive [start game v]\nhide\n\nwhen I receive [lobby v]\nshow\n\n@Sprite3\n\nwhen flag clicked\nhide\n\nwhen I receive [buttons v]\nshow\nset [ghost v] effect to (100)\nset size to (80) %\ngo to x: (0) y: (-175)\nrepeat (100)\n    change y by (1.5)\n    change [ghost v] effect by (-2)\nend\nforever\n    if <touching (mouse-pointer v)?> then\n        set size to (100) %\n        set [brightness v] effect to (-10)\n    else\n        set size to (80) %\n        clear graphic effects\n    end\nend\n\nwhen this sprite clicked\nbroadcast (Start game v)\n\nwhen I receive [start game v]\nhide\nset [backdrop v] to [1]\n\nwhen I receive [lobby v]\nset [deaths v] to [0]\nshow\n\n@Sprite4\n\nwhen flag clicked\nforever\n    go to [back v] layer\nend\n\n@still obstacles\n\nwhen flag clicked\nforever\n    show\n    go to [back v] layer\n    go [forward v] (2) layers\n    switch costume to (backdrop)\nend\n\nset [backdrop v] to [6]\n\n@Sprite5\n\nwhen flag clicked\nforever\n    hide\n    reset timer\nend\n\nwhen [timer v] > (0.0000000000001)\ngo to x: (0) y: (-360)\nshow\nif <not <(y position) = [0]>> then\n    forever\n        go to [front v] layer\n        change y by ([abs v] of ((y position) / (5)) )\n    end\nend\n\n@Sprite6\n\nwhen flag clicked\nhide\n\nwhen I receive [buttons v]\nshow\nset [ghost v] effect to (100)\nset size to (80) %\ngo to x: (0) y: (-175)\nwait until <([y position v] of [sprite3 v]) < [50]>\nrepeat (100)\n    change y by (0.75)\n    change [ghost v] effect by (-2)\nend\nforever\n    if <touching (mouse-pointer v)?> then\n        set size to (100) %\n        set [brightness v] effect to (-10)\n    else\n        set size to (80) %\n        clear graphic effects\n    end\nend\n\nwhen this sprite clicked\nbroadcast (settings v)\n\nwhen I receive [start game v]\nhide\nset [backdrop v] to [1]\n\nwhen I receive [lobby v]\nshow\n\n@Sprite7\n\nwhen flag clicked\nforever\n    switch costume to (death requirement costume)\nend\n\nwhen I receive [settings v]\nshow\nwait until <<key (space v) pressed?> or <<mouse down?> and <not <touching (mouse-pointer v)?>>>>\nhide\n\nwhen flag clicked\nset [deaths v] to [0]\nhide\nset [death requirement costume v] to [2]\n\nwhen flag clicked\nforever\n    if <key (right arrow v) pressed?> then\n        next costume\n        wait (0.5) seconds\n    end\n    if <key (left arrow v) pressed?> then\n        switch costume to ((costume [number v]) - (1))\n        wait (0.5) seconds\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (mouse-pointer v)?> then\n        set size to (105) %\n        set [brightness v] effect to (-5)\n    else\n        set size to (100) %\n        clear graphic effects\n    end\nend\n\nwhen I receive [start game v]\nif <(costume [number v]) = [2]> then\n    set [death requirement v] to [100000000]\nelse\n    if <(costume [number v]) = [1]> then\n        set [death requirement v] to [1]\n    else\n        if <(costume [number v]) = [3]> then\n            set [death requirement v] to [3]\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    set [touching mouse? v] to <touching (mouse-pointer v)?>\nend\n\n@lives\n\n@Sprite8\n\nwhen I receive [settings v]\ngo to [front v] layer\nshow\nwait until <<key (space v) pressed?> or <<mouse down?> and <(touching mouse?) = [false]>>>\nhide\n\nwhen flag clicked\nforever\n    if <touching (mouse-pointer v)?> then\n        set [brightness v] effect to (-10)\n    else\n        clear graphic effects\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nforever\n    set size to ([size v] of [sprite7 v]) %\nend\n\nwhen this sprite clicked\nchange [death requirement costume v] by (1)\n\n@Sprite9\n\nwhen flag clicked\nhide\nforever\n    if <touching (mouse-pointer v)?> then\n        set [brightness v] effect to (-10)\n    else\n        clear graphic effects\n    end\nend\n\nwhen I receive [settings v]\ngo to [front v] layer\nshow\nwait until <<key (space v) pressed?> or <<mouse down?> and <(touching mouse?) = [false]>>>\nhide\n\nwhen flag clicked\nforever\n    set size to ([size v] of [sprite7 v]) %\nend\n\nwhen this sprite clicked\nchange [death requirement costume v] by (-1)\n\n@basketball\n\nwhen flag clicked\ngo to x: (-165) y: (-105)\nforever\n    turn right (2) degrees\n    if <(backdrop) = [3]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\ngo to x: (-165) y: (-105)\nwait until <(backdrop) = [3]>\nforever\n    glide (1) secs to x: (165) y: (-105)\n    glide (1) secs to x: (-165) y: (-105)\nend\n\n@Sprite10\n\nwhen flag clicked\nset [backdrop v] to [1]\nhide\n\nwhen I receive [start game v]\nshow\nforever\n    switch costume to (backdrop)\n    go to [back v] layer\nend\n\n@baseball player\n\nwhen flag clicked\nforever\n    wait (0) seconds\n    next costume\nend\n\nwhen flag clicked\ngo to x: (0) y: (-100)\nwait until <(backdrop) = [4]>\nforever\n    repeat until <(x position) = [200]>\n        point in direction (90)\n        change x by (5)\n    end\n    repeat until <(x position) = [-200]>\n        point in direction (-90)\n        change x by (-5)\n    end\nend\n\nwhen flag clicked\nforever\n    if <(backdrop) = [4]> then\n        show\n    else\n        hide\n    end\nend\n\n@Sprite11\n\ngo to [front v] layer\n\nforever\n    wait (0) seconds\n    next costume\nend\n\n@Sprite13\n\nwhen flag clicked\nforever\n    switch costume to (backdrop)\nend\n\n@wild dog\n\nwhen flag clicked\nforever\n    wait (0) seconds\n    next costume\nend\n\nwhen flag clicked\ngo to x: (0) y: (-105)\nwait until <(backdrop) = [12]>\nforever\n    repeat until <(x position) = [-200]>\n        point in direction (-90)\n        change x by (-5)\n    end\n    repeat until <(x position) = [0]>\n        point in direction (90)\n        change x by (5)\n    end\nend\n\nwhen flag clicked\nforever\n    if <(backdrop) = [12]> then\n        show\n    else\n        hide\n    end\nend\n\n