My Platformer Engine

Instructions: ------Instructions------\nUse the arrow keys, WASD, or Drag your finger on the screen to move\n---------------------------\n\nThis is a engine not a full game

@Stage\n\nwhen flag clicked\nforever\n    play sound [Nebula v] until done\nend\n\n@Player\n\nwhen flag clicked\nset [level v] to [1]\nset [x velocity v] to [0]\nset [y velocity v] to [0]\ngo to x: (-200) y: (-84)\nforever\n    Physics [1] [0.9] [13]\nend\n\ndefine Physics (speed) (friction) (jump height)\nchange y by (Y Velocity)\nif <touching (level v)?> then\n    repeat until <not <touching (level v)?>>\n        change y by ((([abs v] of (Y Velocity) ) / (Y Velocity)) * (-1))\n    end\n    set [y velocity v] to [0]\nelse\n    change [y velocity v] by (-1)\nend\nif <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<(mouse x) > (x position)> and <mouse down?>>> then\n    change [x velocity v] by (speed)\nend\nif <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<(x position) > (mouse x)> and <mouse down?>>> then\n    change [x velocity v] by ((speed) * (-1))\nend\nset [x velocity v] to ((X Velocity) * (friction))\nchange x by (X Velocity)\nset [slope v] to [0]\nif <touching (level v)?> then\n    repeat until <<not <touching (level v)?>> or <(Slope) = [8]>>\n        change [slope v] by (1)\n        change y by (1)\n    end\nend\nif <touching (level v)?> then\n    change y by ((Slope) * (-1))\n    repeat until <not <touching (level v)?>>\n        change x by ((([abs v] of (X Velocity) ) / (X Velocity)) * (-1))\n    end\n    if <not <touching (water v)?>> then\n        if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<(mouse y) > ((y position) + (15))> and <mouse down?>>> then\n            if <(X Velocity) > [0]> then\n                set [x velocity v] to [-8]\n            else\n                set [x velocity v] to [8]\n            end\n            set [y velocity v] to [10]\n        else\n            set [x velocity v] to [0]\n        end\n    end\nend\nchange y by (-1)\nif <<<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<(mouse y) > ((y position) + (15))> and <mouse down?>>> and <touching (level v)?>> then\n    set [y velocity v] to (jump height)\nend\nif <touching (water v)?> then\n    set [y velocity v] to [2]\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<(mouse y) > ((y position) + (15))> and <mouse down?>>> then\n        set [y velocity v] to [7]\n    end\nend\nif <<<<key (down arrow v) pressed?> or <key (s v) pressed?>> or <<((y position) - (15)) > (mouse y)> and <mouse down?>>> and <touching (water v)?>> then\n    set [y velocity v] to [-3.5]\nend\nchange y by (1)\nif <touching (danger v)?> then\n    set [x velocity v] to [0]\n    set [y velocity v] to [0]\n    go to x: (-200) y: (-84)\nend\nif <touching (goal v)?> then\n    set [x velocity v] to [0]\n    set [y velocity v] to [0]\n    change [level v] by (1)\n    go to x: (-200) y: (-84)\nend\nif <touching (trampoline v)?> then\n    set [y velocity v] to [17]\nend\n\n@Level\n\nwhen flag clicked\nforever\n    go to x: (0) y: (0)\n    switch costume to (Level)\nend\n\n@Water\n\nwhen flag clicked\nforever\n    set y to (([sin v] of ((timer) * (200)) ) * (10))\n    switch costume to (Level)\nend\n\n@Danger\n\nwhen flag clicked\nshow\nforever\n    go to x: (0) y: (0)\n    switch costume to (Level)\nend\n\n@Trampoline\n\nwhen flag clicked\nshow\nforever\n    go to x: (0) y: (0)\n    switch costume to (Level)\nend\n\n@Goal\n\nwhen flag clicked\nforever\n    go to x: (0) y: (0)\n    switch costume to (Level)\nend\n\n@Thumbnail\n\nwhen flag clicked\nhide\nforever\n    set [timer v] to (timer)\nend\n\nwhen [timer v] > (Timer)\nshow\ngo to [front v] layer\ngo to x: (0) y: (408)\nset [speed v] to [-3]\nrepeat until <(y position) < [10]>\n    change [speed v] by (-1)\n    change y by (Speed)\nend\nset [speed v] to [0]\ngo to x: (0) y: (0)\n\n