Underground - platformer.

Instructions: Arrow keys to move.\nAvoid lava.

@Stage\n\nwhen flag clicked\nforever\n    if <<<(scene #) = [109]> or <(scene #) = [108]>> or <(scene #) = [107]>> then\n        switch backdrop to (air v)\n    else\n        switch backdrop to (cave v)\n    end\nend\n\nwhen flag clicked\nforever\n    if <not <(scene #) = [109]>> then\n        play sound [Cave v] until done\n    end\nend\n\nwhen flag clicked\nwait until <(scene #) = [109]>\nstop all sounds\nstart sound [Win v]\n\n@blank\n\n@player\n\nwhen flag clicked\nset [respawn x v] to [-183]\nset [respawn y v] to [-74]\nset [respawn scene v] to [1]\nreset game\nwait (0) seconds\ngame loop\n\ndefine fall\nchange [ground? v] by (-1)\nchange [speed y v] by (-1)\nchange y by (speed y)\nchange [falling v] by (1)\ncheck if toutching something solid\nif <(toutching) > [0]> then\n    repeat until <(toutching) = [0]>\n        if <(speed y) > [0]> then\n            change y by (-1)\n            set [falling v] to [99]\n        else\n            change y by (1)\n            set [falling v] to [0]\n            set [ground? v] to [10]\n            set [playing jump sound? v] to [0]\n        end\n        check if toutching something solid\n    end\n    set [speed y v] to ((speed y) * (0.75))\nend\n\ndefine check if toutching something solid\nset [toutching v] to [0]\nif <touching (level v)?> then\n    change [toutching v] by (1)\nend\n\ndefine handle controlls up/down\nif <(up) > [0]> then\n    if <(falling) < [4]> then\n        set [speed y v] to [10]\n        if <(playing jump sound?) = [0]> then\n            start sound [Jump v]\n            set [playing jump sound? v] to [1]\n        end\n    end\nend\n\ndefine handle controlls left/right\nchange [sx v] by ((x axis) * (2))\nset [sx v] to ((sx) * (0.75))\nchange [frame v] by ((sx) * (0.1))\nif <(sx) = [0]> then\n    set [frame v] to [0]\nend\nif <([abs v] of (sx) ) < [1]> then\n    set [sx v] to [0]\nend\nif <(([floor v] of (frame) ) mod (5)) = [0]> then\n    set [playing walk? v] to [0]\nend\nif <not <(sx) = [0]>> then\n    if <(playing walk?) = [0]> then\n        if <(falling) = [0]> then\n            start sound (join [Footsteps] (pick random (1) to (3)))\n            set [playing walk? v] to [1]\n        end\n    end\nend\nif <(x axis) = [0]> then\n    stop [this script v]\nend\npoint in direction (x axis)\n\ndefine move x\nchange x by (sx)\ncheck if toutching something solid\nif <(toutching) > [0]> then\n    repeat ([floor v] of ([abs v] of (sx) ) )\n        change y by (1)\n        check if toutching something solid\n        set [sx v] to ((sx) * (0.9))\n        if <(toutching) = [0]> then\n            stop [this script v]\n        end\n    end\n    change y by ((0) - ([floor v] of ([abs v] of (sx) ) ))\n    repeat until <(toutching) = [0]>\n        if <(sx) > [0]> then\n            change x by (-1)\n        else\n            change x by (1)\n        end\n        check if toutching something solid\n    end\n    set [sx v] to [0]\nend\n\ndefine walk off screen\nif <([abs v] of (x position) ) > [235]> then\n    if <(x position) > [0]> then\n        set x to (-235)\n        change [scene # v] by (1)\n    else\n        set x to (235)\n        change [scene # v] by (-1)\n    end\nend\nif <([abs v] of (y position) ) > [180]> then\n    if <(y position) > [0]> then\n        set y to (-140)\n        change [scene # v] by (100)\n    else\n        set y to (180)\n        change [scene # v] by (-100)\n    end\nend\n\ndefine slip\nchange y by (-1)\ncheck if toutching something solid\nif <(toutching) = [0]> then\n    change y by (1)\n    stop [this script v]\nend\nchange x by (1)\ncheck if toutching something solid\nif <(toutching) = [0]> then\n    set [falling v] to [99]\n    change [speed y v] by (-1)\n    change [sx v] by (1)\n    stop [this script v]\nend\nchange x by (-2)\ncheck if toutching something solid\nif <(toutching) = [0]> then\n    set [falling v] to [99]\n    change [speed y v] by (-1)\n    change [sx v] by (-1)\n    stop [this script v]\nend\nchange x by (1)\nchange y by (1)\n\nwhen I receive [kill player v]\nstop [other scripts in sprite v]\nstart sound [Oops v]\nset [can die? v] to [false]\nset [speed y v] to [10]\nrepeat (50)\n    set size to (999999) %\n    change y by (speed y)\n    change [speed y v] by (-1)\n    change size by (-1)\n    change [ghost v] effect by (2)\n    set size to (100) %\nend\nhide\nclear graphic effects\nwait (1) seconds\nreset game\nwait (0) seconds\ngame loop\n\ndefine reset game\nshow\nclear graphic effects\nset size to (100) %\ngo to x: (respawn x) y: (respawn y)\npoint in direction (90)\nset [can die? v] to [true]\nset [scene # v] to (respawn scene)\nset [falling v] to [0]\nset [speed y v] to [0]\nset [sx v] to [0]\nset [ground? v] to [0]\nset [frame v] to [0]\nset [playing jump sound? v] to [0]\nset [playing walk? v] to [0]\n\ndefine game loop\nforever\n    set rotation style [don't rotate v]\n    switch costume to (hitbox v)\n    fall\n    handle controlls up/down\n    move x\n    handle controlls left/right\n    walk off screen\n    slip\n    costume\nend\n\ndefine costume\nset rotation style [left-right v]\nif <(speed y) > [0]> then\n    switch costume to (jump v)\n    stop [this script v]\nend\nif <(ground?) < [1]> then\n    switch costume to (fall v)\n    stop [this script v]\nend\nif <not <(sx) = [0]>> then\n    switch costume to (join [walk] ((([floor v] of (frame) ) mod (4)) + (1)))\n    stop [this script v]\nend\nswitch costume to (stand v)\n\n@level\n\nwhen flag clicked\nforever\n    switch costume to (join [scene] (scene #))\n    erase all\n    make shadow\n    go to x: (0) y: (0)\nend\n\ndefine make shadow\nset [brightness v] effect to (-100)\nset [ghost v] effect to (90)\nchange y by (-25)\nstamp\nclear graphic effects\nchange y by (25)\n\n@controlls\n\nwhen flag clicked\nforever\n    set [up v] to (<key (up arrow v) pressed?> - ())\n    set [down v] to (<key (down arrow v) pressed?> - ())\n    set [right v] to (<key (right arrow v) pressed?> - ())\n    set [left v] to (<key (left arrow v) pressed?> - ())\n    set [y axis v] to ((up) - (down))\n    set [x axis v] to ((right) - (left))\nend\n\n@level danger\n\nwhen flag clicked\ngo to [back v] layer\ngo to x: (0) y: (0)\nforever\n    switch costume to (blank v)\n    switch costume to (join [scene] (scene #))\n    set y to ((5) * ([sin v] of ((timer) * (100)) ))\n    if <touching (player v)?> then\n        if <(can die?) = [true]> then\n            broadcast (kill player v)\n        end\n    end\nend\n\n@checkpoints\n\ndefine create checkpoint at (x) (y) in scene (scene #)\ngo to [back v] layer\nset [spawn x v] to (x)\nset [spawn y v] to (y)\nchange [spawn y v] by (15)\nswitch costume to (inactive v)\ngo to x: (x) y: (y)\nset [my scene v] to (scene #)\ncreate clone of (_myself_ v)\nset [my scene v] to []\n\nwhen flag clicked\ncreate checkpoint at [62] [-115] in scene [5]\ncreate checkpoint at [131] [48] in scene [2]\ncreate checkpoint at [55] [75] in scene [12]\ncreate checkpoint at [-160] [107] in scene [109]\n\nwhen I start as a clone\nforever\n    if <(scene #) = (my scene)> then\n        show\n        if <<<(respawn x) = (spawn x)> and <(respawn y) = (spawn y)>> and <(respawn scene) = (my scene)>> then\n            switch costume to (active v)\n        else\n            switch costume to (inactive v)\n            if <touching (player v)?> then\n                start sound [Coin v]\n                set [respawn scene v] to (my scene)\n                set [respawn x v] to (spawn x)\n                set [respawn y v] to (spawn y)\n            end\n        end\n    else\n        hide\n    end\nend\n\n@sound\n\n