Perfect Scrolling Platformer Engine

Instructions: Have you ever been trying to make an awesome scrolling platformer, but your collisions are always wrong and it glitches too much? Well, I have created a perfect scrolling platformer by taking a regular, non-scrolling script and using it to simulate a scrolling platformer! Look inside to see how it works!\n==================================================\nPress space to switch between the simulator and scrolling platformer. Use the arrow keys to move.\n==================================================\nGood news! This platformer simulator can use any still-platforming script. If you don't like the one I've provided, feel free to use your own!

@Stage\n\n@Character\n\nwhen flag clicked\ngo to x: (0) y: (0)\nbroadcast (Check Screen v)\nPhysics (50) (10) (0.7)\n\nwhen I receive [check screen v]\nforever\n    if <key (space v) pressed?> then\n        set [still/scroll v] to (<(Still/Scroll) = [0]> * (1))\n        wait until <not <key (space v) pressed?>>\n    end\nend\n\ndefine None\nset [xvel v] to [0]\nset [yvel v] to [0]\nset size to (100) %\ncreate clone of (_myself_ v)\nset size to (size) %\nforever\n    switch costume to (hit box v)\n    set [ghost v] effect to (<(Still/Scroll) = [0]> * (100))\n    set [xvel v] to (((XVel) + ((<key (right arrow v) pressed?> - <key (left arrow v) pressed?>) * (speed))) * (0.9))\n    change x by (XVel)\n    if <touching (terrain simulator v)?> then\n        change y by (1)\n        if <touching (terrain simulator v)?> then\n            change y by (1)\n            if <touching (terrain simulator v)?> then\n                change y by (1)\n                if <touching (terrain simulator v)?> then\n                    change y by (1)\n                    if <touching (terrain simulator v)?> then\n                        change y by (1)\n                        if <touching (terrain simulator v)?> then\n                            change x by ((XVel) * (-1))\n                            change y by (-5)\n                            if <key (up arrow v) pressed?> then\n                                if <(XVel) > [0]> then\n                                    set [xvel v] to (((jump) - (5)) * (-1))\n                                else\n                                    set [xvel v] to ((jump) - (5))\n                                end\n                                set [yvel v] to ((jump) + (1))\n                            else\n                                set [xvel v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    change [yvel v] by (-1)\n    change y by (YVel)\n    if <touching (terrain simulator v)?> then\n        change y by ((YVel) * (-1))\n        set [yvel v] to [0]\n    end\n    change y by (-1)\n    if <<touching (terrain simulator v)?> and <key (up arrow v) pressed?>> then\n        set [yvel v] to (jump)\n    end\n    change y by (1)\nend\n\nwhen I start as a clone\nforever\n    switch costume to (character overlay v)\n    if <<key (right arrow v) pressed?> or <key (left arrow v) pressed?>> then\n        point in direction ((<key (right arrow v) pressed?> - <key (left arrow v) pressed?>) * (90))\n    end\n    set [ghost v] effect to (<(Still/Scroll) = [1]> * (100))\n    go to [front v] layer\n    go [backward v] (1) layers\n    go to x: (0) y: (0)\nend\n\n@Terrain Simulator\n\nwhen flag clicked\ngo to x: (0) y: (0)\nforever\n    set [ghost v] effect to (<(Still/Scroll) = [0]> * (100))\nend\n\n@Terrain Cover\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    go [backward v] (2) layers\n    Position ((100) / ([size v] of [character v]))\n    set [ghost v] effect to (<(Still/Scroll) = [1]> * (100))\nend\n\ndefine None\ngo to x: (((0) - ([x position v] of [character v])) * (size)) y: (((0) - ([y position v] of [character v])) * (size))\nswitch costume to (dot v)\nset size to ((100) * (size)) %\nswitch costume to (cover v)\n\n@Thumbnail\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\nforever\n    go to [front v] layer\nend\n\n