Realistic Platformer Script
@Stage\n\n@Sprite1\n\nwhen flag clicked\nhide\n\ndefine engine\nchange y by (yspeed)\nif <touching color (#000000)?> then\n    repeat until <not <touching color (#000000)?>>\n        if <(yspeed) > [0]> then\n            change y by (-1)\n        else\n            change y by (1)\n        end\n    end\n    set [yspeed v] to [0]\nend\nchange [yspeed v] by (() - (gravity))\nif <(gravity) > [0]> then\n    change y by (-1)\nelse\n    change y by (1)\nend\nif <touching color (#000000)?> then\n    if <key (up arrow v) pressed?> then\n        change [yspeed v] by (y speed)\n    end\n    if <key (right arrow v) pressed?> then\n        change [xspeed v] by (x speed)\n    end\n    if <key (left arrow v) pressed?> then\n        change [xspeed v] by (() - (x speed))\n    end\n    set [xspeed v] to ((0.7) * (xspeed))\nend\nif <(gravity) > [0]> then\n    change y by (1)\nelse\n    change y by (-1)\nend\nset [xspeed v] to ((0.99) * (xspeed))\nchange x by (xspeed)\nif <(gravity) > [0]> then\n    if <touching color (#000000)?> then\n        change y by (1)\n        if <touching color (#000000)?> then\n            change y by (1)\n            if <touching color (#000000)?> then\n                change y by (1)\n                if <touching color (#000000)?> then\n                    change y by (1)\n                    if <touching color (#000000)?> then\n                        change y by (1)\n                        if <touching color (#000000)?> then\n                            change y by (-5)\n                            repeat until <not <touching color (#000000)?>>\n                                if <(xspeed) > [0]> then\n                                    change x by (-1)\n                                else\n                                    change x by (1)\n                                end\n                            end\n                            if <key (up arrow v) pressed?> then\n                                if <(xspeed) > [0]> then\n                                    set [xspeed v] to (() - (x speed))\n                                else\n                                    set [xspeed v] to (x speed)\n                                end\n                                set [yspeed v] to (y speed)\n                            else\n                                set [xspeed v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nelse\n    if <touching color (#000000)?> then\n        change y by (-1)\n        if <touching color (#000000)?> then\n            change y by (-1)\n            if <touching color (#000000)?> then\n                change y by (-1)\n                if <touching color (#000000)?> then\n                    change y by (-1)\n                    if <touching color (#000000)?> then\n                        change y by (-1)\n                        if <touching color (#000000)?> then\n                            change y by (5)\n                            repeat until <not <touching color (#000000)?>>\n                                if <(xspeed) > [0]> then\n                                    change x by (-1)\n                                else\n                                    change x by (1)\n                                end\n                            end\n                            if <key (up arrow v) pressed?> then\n                                if <(xspeed) > [0]> then\n                                    set [xspeed v] to (() - (x speed))\n                                else\n                                    set [xspeed v] to (x speed)\n                                end\n                                set [yspeed v] to (y speed)\n                            else\n                                set [xspeed v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\nif <key (r v) pressed?> then\n    reset level\nend\nif <<mouse down?> and <(mouse y) > [-50]>> then\n    set [initx v] to (x position)\n    set x to (mouse x)\n    if <touching color (#000000)?> then\n        set x to (initx)\n    end\n    set [inity v] to (y position)\n    set y to (mouse y)\n    if <touching color (#000000)?> then\n        set y to (inity)\n    end\n    set [initx v] to (x position)\n    set x to (mouse x)\n    if <touching color (#000000)?> then\n        set x to (initx)\n    end\n    set [inity v] to (y position)\n    set y to (mouse y)\n    if <touching color (#000000)?> then\n        set y to (inity)\n    end\nend\n\ndefine reset level\ngo to x: (0) y: (50)\nset [xspeed v] to [0]\nset [yspeed v] to [0]\nset [gravity v] to [0.8]\nset [x speed v] to [2]\nset [y speed v] to [6]\n\nwhen I receive [introdone v]\nshow\nreset level\nwait (1) seconds\nset rotation style [left-right v]\nforever\n    engine\nend\n\n@levels\n\n@x speed\n\nwhen this sprite clicked\nask (join (join [What level would you like to set the horizontal movement to? The current level is ] (x speed)) [.]) and wait\nset [x speed v] to (answer)\n\n@y speed\n\nwhen this sprite clicked\nask (join (join [What level would you like to set the vertical movement to? The current level is ] (y speed)) [.]) and wait\nset [y speed v] to (answer)\n\n@gravity\n\nwhen this sprite clicked\nask (join (join [What level would you like to set the gravity to? The current level is ] (gravity)) [.]) and wait\nset [gravity v] to (answer)\n\n@thumbnail\n\nwhen flag clicked\nhide\nforever\n    reset timer\nend\n\nwhen [timer v] > (0.1)\nset [ghost v] effect to (100)\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\n\n@blackbackground\n\nwhen flag clicked\nshow\nclear graphic effects\nwait (0.1) seconds\nwait until <(skip) = [1]>\nrepeat (5)\n    change [ghost v] effect by (20)\nend\nhide\nclear graphic effects\n\nwhen I receive [stop all v]\nstop [other scripts in sprite v]\n\n@logo\n\nwhen flag clicked\nset [skip v] to [0]\nstart sound [A Elec Bass v]\npoint in direction (90)\nclear graphic effects\nshow\ngo to x: (0) y: (0)\ngo to [front v] layer\nswitch costume to (1 v)\nset size to (200) %\nrepeat (20)\n    if <mouse down?> then\n        set [skip v] to [1]\n        broadcast (introdone v)\n        repeat (4)\n            change [ghost v] effect by (25)\n        end\n        clear graphic effects\n        hide\n        stop [this script v]\n    end\n    wait (0.05) seconds\nend\nrepeat (19)\n    if <mouse down?> then\n        broadcast (introdone v)\n        set [skip v] to [1]\n        hide\n        clear graphic effects\n        stop [this script v]\n    end\n    change [ghost v] effect by (5)\nend\nset size to (100) %\nswitch costume to (2 v)\nrepeat (5)\n    change [ghost v] effect by (-20)\n    if <mouse down?> then\n        broadcast (introdone v)\n        set [skip v] to [1]\n        hide\n        clear graphic effects\n        stop [this script v]\n    end\nend\nrepeat (20)\n    if <mouse down?> then\n        set [skip v] to [1]\n        broadcast (introdone v)\n        repeat (4)\n            change [ghost v] effect by (25)\n        end\n        clear graphic effects\n        hide\n        stop [this script v]\n    end\n    wait (0.05) seconds\nend\nrepeat (19)\n    change [ghost v] effect by (20)\n    if <mouse down?> then\n        broadcast (introdone v)\n        set [skip v] to [1]\n        hide\n        clear graphic effects\n        stop [this script v]\n    end\nend\nhide\nset [skip v] to [1]\nclear graphic effects\nbroadcast (introdone v)\n\nwhen flag clicked\nforever\n    go to [front v] layer\nend\n\nwhen I receive [stop all v]\nstop [other scripts in sprite v]\n\n