3D Platformer

Instructions: This is a 3D platformer engine!\n\nThere are 3 levels as of now.\n\nThe Quality slider changes what tier ground detection is at. I recommend above 2 for the best and least glitchy experience.

@Stage\n\n@Pen\n\nwhen flag clicked\nshow variable [quality v]\nset [level v] to [1]\nset pen size to (10)\nforever\n    erase all\n    if <(Level) = [1]> then\n        set pen color to (#ee7d16)\n        draw platform x: (200) y: (0) x2: (200) y2: (60)\n        draw platform x: (200) y: (150) x2: (200) y2: (200)\n        draw platform x: (150) y: (-250) x2: (150) y2: (-150)\n        draw platform x: (150) y: (0) x2: (200) y2: (0)\n        draw platform x: (-50) y: (-350) x2: (50) y2: (-350)\n        set pen color to (#632d99)\n        draw platform x: (-50) y: (0) x2: (150) y2: (0)\n        draw platform x: (350) y: (-300) x2: (450) y2: (-300)\n        draw platform x: (-50) y: (-250) x2: (50) y2: (-250)\n        draw platform x: (-50) y: (0) x2: (-50) y2: (150)\n        draw platform x: (150) y: (-250) x2: (100) y2: (-300)\n        draw platform x: (100) y: (-300) x2: (50) y2: (-350)\n        draw platform x: (-50) y: (-350) x2: (-100) y2: (-300)\n        draw platform x: (-100) y: (-300) x2: (-150) y2: (-250)\n        draw platform x: (-50) y: (-250) x2: (-50) y2: (0)\n        set pen color to (#5cb712)\n        draw platform x: (-150) y: (-250) x2: (-150) y2: (-150)\n        set pen color to (#2ca5e2)\n        draw platform x: (200) y: (-400) x2: (200) y2: (-100)\n    end\n    if <(Level) = [2]> then\n        set pen color to (#2ca5e2)\n        draw platform x: (300) y: (250) x2: (300) y2: (0)\n        draw platform x: (-55) y: (150) x2: (-55) y2: (-500)\n        set pen color to (#632d99)\n        draw platform x: (-50) y: (50) x2: (50) y2: (50)\n        draw platform x: (-50) y: (50) x2: (-50) y2: (150)\n        draw platform x: (-50) y: (150) x2: (50) y2: (200)\n        draw platform x: (200) y: (250) x2: (50) y2: (210)\n        set pen color to (#0e9a6c)\n        draw platform x: (50) y: (50) x2: (50) y2: (200)\n        set pen color to (#ee7d16)\n        draw platform x: (200) y: (50) x2: (200) y2: (200)\n        draw platform x: (200) y: (200) x2: (50) y2: (200)\n        draw platform x: (-50) y: (-100) x2: (300) y2: (-100)\n        draw platform x: (300) y: (-100) x2: (300) y2: (0)\n        draw platform x: (300) y: (250) x2: (300) y2: (350)\n        draw platform x: (-125) y: (400) x2: (-125) y2: (-150)\n        draw platform x: (-125) y: (-300) x2: (-125) y2: (-500)\n        draw platform x: (-125) y: (-500) x2: (-55) y2: (-500)\n        set pen color to (#5cb712)\n        draw platform x: (-125) y: (-500) x2: (-500) y2: (-500)\n    end\n    if <(Level) = [3]> then\n        set pen color to (#5cb712)\n        draw platform x: (-1200) y: (500) x2: (-1200) y2: (150)\n        set pen color to (#0e9a6c)\n        draw platform x: (50) y: (50) x2: (100) y2: (0)\n        draw platform x: (-100) y: (50) x2: (-150) y2: (0)\n        set pen color to (#632d99)\n        draw platform x: (-100) y: (50) x2: (50) y2: (50)\n        draw platform x: (-25) y: (200) x2: (-25) y2: (50)\n        draw platform x: (-200) y: (100) x2: (-300) y2: (100)\n        draw platform x: (-500) y: (150) x2: (-1200) y2: (150)\n        set pen color to (#ee7d16)\n        draw platform x: (-300) y: (175) x2: (-300) y2: (500)\n        draw platform x: (-600) y: (150) x2: (-700) y2: (150)\n        draw platform x: (-750) y: (150) x2: (-900) y2: (150)\n        draw platform x: (-1000) y: (150) x2: (-1200) y2: (150)\n    end\nend\n\ndefine None\npen up\ngo to x: ((X) + (x)) y: ((Y) + (y))\npen down\npoint towards (center v)\nmove ((distance to [center v]) / (-4)) steps\nset [goto y v] to (y position)\nset [goto x v] to (x position)\ngo to x: ((X) + (x)) y: ((Y) + (y))\ngo to x: ((X) + (x2)) y: ((Y) + (y2))\npoint towards (center v)\nmove ((distance to [center v]) / (-4)) steps\ngo to x: (Goto X) y: (Goto Y)\n\n@Center\n\n@Player\n\ndefine Hit detect\nswitch costume to (detect v)\nset [old rotation v] to (direction)\npoint in direction (90)\nrepeat (4)\n    turn right (90) degrees\n    if <<touching color (#2ca5e2)?> and <<key (up arrow v) pressed?> or <key (w v) pressed?>>> then\n        set [jump time v] to [5]\n    end\n    if <<touching color (#632d99)?> or <touching color (#2ca5e2)?>> then\n        set [old x v] to (x position)\n        set [old y v] to (y position)\n        if <<touching color (#2ca5e2)?> and <<key (up arrow v) pressed?> or <key (w v) pressed?>>> then\n            move ((5) + ((-10) * (Quality))) steps\n        end\n        move (-10) steps\n        change [xv v] by (((Old X) - (x position)) / (Quality))\n        change [yv v] by (((Old Y) - (y position)) / (Quality))\n        go to x: (Old X) y: (Old Y)\n        repeat (10)\n            if <<touching color (#632d99)?> or <touching color (#2ca5e2)?>> then\n                move (-1) steps\n            end\n        end\n        if <(direction) = [180]> then\n            set [jump time v] to [5]\n        end\n    end\nend\npoint in direction (Old Rotation)\nswitch costume to (main v)\n\ndefine Motion Quality\nrepeat (Quality)\n    change x by (((XV) / (Quality)) * (-1))\n    change y by (((YV) / (Quality)) * (-1))\n    if <<touching color (#632d99)?> or <touching color (#2ca5e2)?>> then\n        Hit detect\n    end\n    if <touching color (#109b6c)?> then\n        set [jump time v] to [5000]\n    end\nend\nchange [x v] by ((x position) * (-1))\nchange [y v] by ((y position) * (-1))\ngo to x: (0) y: (0)\n\nwhen I receive [start v]\npoint in direction (90)\nset [xv v] to [0]\nset [yv v] to [0]\nset [x v] to [0]\nset [y v] to [-100]\nforever\n    go to x: (0) y: (0)\n    change [yv v] by (1)\n    if <<<<key (up arrow v) pressed?> or <key (w v) pressed?>> and <[0] < (Jump Time)>> and <[0] = [0]>> then\n        set [jump time v] to [0]\n        set [yv v] to [-15]\n    end\n    change [jump time v] by (-1)\n    Motion Quality\n    turn right ((XV) * (-2.5)) degrees\nend\n\nwhen flag clicked\nbroadcast (start v)\n\nwhen I receive [start v]\nwait (0.01) seconds\nforever\n    if <<key (r v) pressed?> or <<[1000] < (Y)> or <touching color (#ee7d16)?>>> then\n        set [x v] to [0]\n        set [jump time v] to [0]\n        set [y v] to [-100]\n        set [xv v] to [0]\n        set [yv v] to [0]\n    end\n    if <touching color (#5db814)?> then\n        stop [other scripts in sprite v]\n        set [xv v] to ((XV) / (10))\n        set [yv v] to ((YV) / (10))\n        repeat (60)\n            change x by ((XV) * (-1))\n            change y by ((YV) * (-1))\n            turn right ((XV) * (-2.5)) degrees\n        end\n        broadcast (start v)\n        change [level v] by (1)\n        stop [this script v]\n    end\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        change [xv v] by (1)\n    end\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        change [xv v] by (-1)\n    end\n    set [yv v] to ((YV) / (1.05))\n    set [xv v] to ((XV) / (1.05))\nend\n\n@Light\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [ghost v] effect to (50)\ngo to [front v] layer\nforever\n    go to (player v)\nend\n\n@Sprite1\n\nwhen flag clicked\ngo to x: (0) y: (0)\ngo [backward v] (100) layers\n\n@Thumbnail\n\nwhen flag clicked\nhide\nwait (0.1) seconds\ngo to [front v] layer\ngo to x: (0) y: (0)\nforever\n    change [fps calculate v] by (1)\nend\n\nwhen flag clicked\nforever\n    wait (1) seconds\n    set [fps v] to (FPS Calculate)\n    set [fps calculate v] to [0]\nend\n\n