Basic Platformer Physics: Collision [EXAMPLE]
@Stage\n\nwhen flag clicked\nforever\n    if <not <(backdrop [number v]) = []>> then\n        if <(Level) = [1]> then\n            switch backdrop to (backdrop1 v)\n        end\n        if <(Level) = [2]> then\n            switch backdrop to (backdrop2 v)\n        end\n    end\nend\n\n@Sprite1\n\nwhen flag clicked\nset [jumping? v] to [false]\nset [y velocity v] to [0]\nset [x velocity v] to [0]\nset [max velocity v] to [15]\nset [gravity v] to [-1]\nset [move speed v] to [5]\nset rotation style [left-right v]\nforever\n    if <(Jumping?) = [true]> then\n        change y by (Y Velocity)\n        change [y velocity v] by (gravity)\n    end\n    if <(Jumping?) = [false]> then\n        if <key (up arrow v) pressed?> then\n            set [jumping? v] to [true]\n            set [y velocity v] to (max velocity)\n        end\n    end\n    Resolve Y\n    if <key (left arrow v) pressed?> then\n        change [x velocity v] by ((move speed) * (-1))\n        point in direction (-90)\n        change x by (X Velocity)\n    end\n    if <key (right arrow v) pressed?> then\n        change [x velocity v] by (move speed)\n        point in direction (90)\n        change x by (X Velocity)\n    end\n    Resolve X\nend\n\ndefine Resolve Y\nswitch costume to (costume2 v)\nif <touching color (#000000)?> then\n    if <<(Y Velocity) < [0]> or <(Y Velocity) = [0]>> then\n        repeat until <not <touching color (#000000)?>>\n            change y by (1)\n        end\n        set [y velocity v] to [0]\n        set [jumping? v] to [false]\n    end\n    if <[0] < (Y Velocity)> then\n        repeat until <not <touching color (#000000)?>>\n            change y by (-1)\n        end\n        set [y velocity v] to [0]\n        set [jumping? v] to [true]\n    end\nelse\n    if <(Jumping?) = [false]> then\n        change y by (-1)\n        if <not <touching color (#000000)?>> then\n            set [y velocity v] to [0]\n            set [jumping? v] to [true]\n        end\n        change y by (1)\n    end\nend\nswitch costume to (costume1 v)\n\ndefine Resolve X\nswitch costume to (costume2 v)\nif <color (#ff0000) is touching (#000000)?> then\n    if <<(X Velocity) < [0]> or <(X Velocity) = [0]>> then\n        repeat until <not <color (#ff0000) is touching (#000000)?>>\n            change x by (1)\n        end\n    end\n    if <[0] < (X Velocity)> then\n        repeat until <not <color (#ff0000) is touching (#000000)?>>\n            change x by (-1)\n        end\n    end\nend\nif <color (#00ff55) is touching (#000000)?> then\n    repeat until <not <touching color (#000000)?>>\n        change y by (1)\n    end\nend\nset [x velocity v] to [0]\nswitch costume to (costume1 v)\n\n
This example extends my last example of basic platformer jumping physics with basic collision detecting and resolving.  Click "see inside" so see the code and comments describing the process\n\nleft and right to move\nup to jump