Scrolling Platformer Engine

Instructions: This engine sucks so don't use it\n\n--Instructions--\nSee inside for instructions and make sure to backpack the "player", "background", and the "ground" sprites. Make sure to use with credit.\n\nMAKE SURE TO FOLLOW THE INSTRUCTIONS BEFORE USE OR IT WILL NOT WORK\n\n--Updates--\nv1.1 - Changed ground checking system so that it doesn't have to use a clone and removes 3 public variables, and it's more responsive\nv1.2 - Made code clearer and easier to understand | Changed thumbnail\nv1.3 - Hopefully fixed the player disappearing and falling through the ground bug

@Stage\n\n@Player\n\ndefine physics speed: (speed)\ncheck collision\nif <not <(collision?) = [1]>> then\n    change [yv v] by (-1)\nend\nchange [y v] by (yv)\nposition\ncheck collision\nif <(collision?) = [1]> then\n    repeat ([abs v] of ([ceiling v] of (yv) ) )\n        check collision\n        if <(collision?) = [1]> then\n            change [y v] by ((([abs v] of (yv) ) / (yv)) * (-1))\n            position\n        end\n    end\n    set [yv v] to [0]\nend\nchange [x v] by (xv)\nposition\ncheck collision\nif <(collision?) = [1]> then\n    set [slope v] to [0]\n    check collision\n    repeat until <<(slope) = [-8]> or <not <(collision?) = [1]>>>\n        change [slope v] by (-1)\n        change [y v] by (1)\n        position\n    end\n    if <(slope) = [-8]> then\n        change [y v] by (slope)\n        position\n    end\n    repeat ([abs v] of ([ceiling v] of (xv) ) )\n        change [x v] by ((([abs v] of (xv) ) / (xv)) * (-1.5))\n        position\n    end\n    set [xv v] to [0]\nend\nturn right (direction) degrees\nset [direction v] to ((direction) * (0.6))\nset [xv v] to ((xv) * (speed))\nturn\n\ndefine position\nset size to ((size) * (4)) %\ngo to x: ((x) - (scroll x)) y: ((y) - (scroll y))\nset size to ((size) / (4)) %\nif <<(round ((x) - (scroll x))) = (round (x position))> and <(round ((y) - (scroll y))) = (round (y position))>> then\n    show\nelse\n    hide\nend\n\ndefine controls\nchange [y v] by (-1)\nposition\nif <<<key (w v) pressed?> or <key (up arrow v) pressed?>> and <touching (ground v)?>> then\n    set [yv v] to [20]\nend\nchange [y v] by (1)\nposition\nif <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n    change [xv v] by (-1)\nend\nif <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n    change [xv v] by (1)\nend\n\nwhen flag clicked\npoint in direction (90)\nset size to (65) %\nshow\nforever\n    broadcast (reset v)\n    switch costume to (player v)\n    set [x v] to [0]\n    set [y v] to [0]\n    set [xv v] to [0]\n    set [yv v] to [0]\n    set [direction v] to [0]\n    set [slope v] to [0]\n    set [scroll x v] to (x)\n    set [scroll y v] to (y)\n    point in direction (90)\n    position\n    repeat until \n        controls\n        physics speed: [0.9]\n        change [scroll x v] by (round (((x) - (scroll x)) / (10)))\n        change [scroll y v] by (round (((y) - (scroll y)) / (10)))\n        create scroll barriers x: [] y: []\n        position\n    end\n    if <not <(y) < [-720]>> then\n        death animation\n    end\nend\n\ndefine create scroll barriers x: (x) y: (y)\nif <not <(x) = []>> then\n    if <(scroll x) > (x)> then\n        set [scroll x v] to (x)\n    end\n    if <(scroll x) < ((0) - (x))> then\n        set [scroll x v] to ((0) - (x))\n    end\nend\nif <not <(y) = []>> then\n    if <(scroll y) > (y)> then\n        set [scroll y v] to (y)\n    end\n    if <(scroll y) < ((0) - (y))> then\n        set [scroll y v] to (y)\n    end\nend\n\ndefine death animation\n\ndefine check collision\nset [collision? v] to <touching (ground v)?>\n\ndefine turn\ncheck collision\nif <not <(collision?) = [1]>> then\n    change [x v] by (10)\n    position\n    check collision\n    if <not <(collision?) = [1]>> then\n        change [direction v] by (3)\n        change [xv v] by (0.3)\n    end\n    change [x v] by (-20)\n    position\n    check collision\n    if <not <(collision?) = [1]>> then\n        change [direction v] by (-3)\n        change [xv v] by (-0.3)\n    end\n    change [x v] by (10)\n    position\n    turn right (2) degrees\n    check collision\n    if <not <(collision?) = [1]>> then\n        change [direction v] by (1)\n    end\n    turn left (4) degrees\n    check collision\n    if <not <(collision?) = [1]>> then\n        change [direction v] by (-1)\n    end\n    turn right (2) degrees\n    turn right (10) degrees\n    check collision\n    if <not <(collision?) = [1]>> then\n        change [direction v] by (2)\n    end\n    turn left (20) degrees\n    check collision\n    if <not <(collision?) = [1]>> then\n        change [direction v] by (-2)\n    end\n    turn right (10) degrees\nend\n\n@Background\n\nwhen flag clicked\nhide\ninitialize tiles\n\ndefine split (input)\nset [i v] to [0]\nset [x v] to []\nrepeat until <(letter (i) of (input)) = [.]>\n    change [i v] by (1)\n    if <not <(letter (i) of (input)) = [.]>> then\n        set [x v] to (join (x) (letter (i) of (input)))\n    end\nend\nset [y v] to []\nrepeat until <(letter (i) of (input)) = []>\n    change [i v] by (1)\n    if <not <(letter (i) of (input)) = []>> then\n        set [y v] to (join (y) (letter (i) of (input)))\n    end\nend\n\ndefine initialize tiles\nswitch costume to (join [0] [])\nrepeat (costume [number v])\n    next costume\n    if <not <(costume [name v]) = [dummy]>> then\n        split (costume [name v])\n        set [x v] to ((x) * (480))\n        set [y v] to ((y) * (360))\n        create clone of (_myself_ v)\n    end\nend\n\ndefine position\nset [costume v] to (costume [name v])\nswitch costume to (dummy v)\nset size to ((size) * (4)) %\nswitch costume to (costume)\ngo to x: ((x) - (scroll x)) y: ((y) - (scroll y))\nset size to ((size) / (4)) %\nif <<((x) - (scroll x)) = (x position)> and <((y) - (scroll y)) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I start as a clone\nset size to (100) %\ngo to [back v] layer\nforever\n    position\nend\n\n@Ground\n\nwhen flag clicked\nhide\ninitialize tiles\n\ndefine split (input)\nset [i v] to [0]\nset [x v] to []\nrepeat until <(letter (i) of (input)) = [.]>\n    change [i v] by (1)\n    if <not <(letter (i) of (input)) = [.]>> then\n        set [x v] to (join (x) (letter (i) of (input)))\n    end\nend\nset [y v] to []\nrepeat until <(letter (i) of (input)) = []>\n    change [i v] by (1)\n    if <not <(letter (i) of (input)) = []>> then\n        set [y v] to (join (y) (letter (i) of (input)))\n    end\nend\n\ndefine initialize tiles\nswitch costume to (join [0] [])\nrepeat (costume [number v])\n    next costume\n    if <not <<(costume [name v]) = [dummy]> or <(costume [name v]) = [fill]>>> then\n        split (costume [name v])\n        set [x v] to ((x) * (480))\n        set [y v] to ((y) * (360))\n        create clone of (_myself_ v)\n    end\nend\n\ndefine position\nset [costume v] to (costume [name v])\nswitch costume to (dummy v)\nset size to ((size) * (4)) %\nswitch costume to (fill v)\ngo to x: ((x) - (scroll x)) y: ((y) - (scroll y))\nswitch costume to (costume)\nset size to ((size) / (4)) %\nif <<((x) - (scroll x)) = (x position)> and <((y) - (scroll y)) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I start as a clone\nset size to (100) %\nforever\n    position\nend\n\n@DELETE THIS\n\nwhen flag clicked\nhide\nforever\n    reset timer\nend\n\nwhen [timer v] > (0)\ngo to x: (0) y: (0)\nswitch costume to (dummy v)\nset size to (100) %\nswitch costume to (2 v)\nshow\n\n