Scrolling Platformer tutorial
@Stage\n\n@player\n\ndefine Move\nset [player sx v] to ((Player Sx) * (0.8))\nchange x by (round (Player Sx))\nset [i v] to [0]\nrepeat until <<not <touching (level v)?>> or <(i) = [8]>>\n    change y by (1)\n    change [i v] by (1)\nend\nif <(i) = [8]> then\n    change x by ((0) - (round (Player Sx)))\n    change y by (-8)\n    set [player sx v] to [0]\nend\n\nwhen I receive [start v]\nshow\nset rotation style [left-right v]\ngo to x: (0) y: (0)\nswitch costume to (costume1 v)\nset [player sx v] to [0]\nset [player sy v] to [0]\nset [cam x v] to [0]\nset [cam y v] to [0]\nbroadcast (tick v) and wait\nforever\n    Physics\n    broadcast (tick v)\nend\n\ndefine Physics\nchange [player sy v] by (-1)\nchange [falling v] by (1)\nchange y by (Player Sy)\nGo Up\nControls <<key (right arrow v) pressed?> or <key (d v) pressed?>> <<key (left arrow v) pressed?> or <key (a v) pressed?>> <<key (up arrow v) pressed?> or <key (w v) pressed?>>\nMove\nchange [cam x v] by (x position)\nchange [cam y v] by (y position)\ngo to x: (0) y: (0)\nif <(Cam Y) < [-300]> then\n    set [cam x v] to (spawn x)\n    set [cam y v] to (spawn y)\nend\n\ndefine Controls <right> <left> <jump>\nif <right> then\n    change [player sx v] by (3)\n    point in direction (90)\nend\nif <left> then\n    change [player sx v] by (-3)\n    point in direction (-90)\nend\nif <<jump> and <(Falling) = [0]>> then\n    change [player sy v] by (15)\nend\n\ndefine Go Up\nset [i v] to [0]\nrepeat until <<not <touching (level v)?>> or <(i) = [16]>>\n    change [i v] by (1)\n    if <<(Player Sy) > [-1]> and <(Falling) > [0]>> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling v] to [0]\n    end\n    set [player sy v] to [0]\nend\n\nwhen flag clicked\nbroadcast (start v)\n\n@level\n\nwhen I receive [tick v]\ntick\n\ndefine tick\ngo to x: ((x) - (Cam X)) y: ((y) - (Cam Y))\nif <<((x) - (Cam X)) = (x position)> and <((y) - (Cam Y)) = (y position)>> then\n    show\nelse\n    hide\nend\n\ndefine Create Level x (x) y (y) Costume (costume)\nswitch costume to (costume)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nforever\n    play sound [Northern-Passage v] until done\nend\n\nwhen I receive [start v]\nCreate Level x [480] y [-100] Costume [P2]\nCreate Level x [480] y [80] Costume [P2.1]\nset [x v] to [0]\nset [y v] to [-100]\nswitch costume to (p1 v)\n\n@thumbnail\n\nwhen flag clicked\nhide\n\n
Remix or see inside and backpack the scripts. \nCredit appreciated (@neanderthal11)\n\nLeave a ❤️ and a ⭐️ if you found this useful. Feel free to leave a link of your platformer if you used my tutorial.\n\nPost any questions in the comments.\n\nCheck out my platformers:\n\nSinking Into Darkness:\nhttps://scratch.mit.edu/projects/300568765\n\nCube Parkour (scrolling): https://scratch.mit.edu/projects/322825538\n