Scrolling Platformer Tutorial Part 2!!        #tutorials #all          
@Stage\n\n@SLides\n\nwhen flag clicked\nReset\nforever\n    if <not <(costume [number v]) = (last costume)>> then\n        if <<key (space v) pressed?> or <<mouse down?> or <key (right arrow v) pressed?>>> then\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            next costume\n            repeat (10)\n                change [ghost v] effect by (-10)\n            end\n        end\n    end\n    if <not <(costume [number v]) = (first costume)>> then\n        if <key (left arrow v) pressed?> then\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            switch costume to ((costume [number v]) - (1))\n            repeat (10)\n                change [ghost v] effect by (-10)\n            end\n        end\n    end\nend\n\ndefine Reset\nclear graphic effects\nswitch costume to (intro v)\nset [first costume v] to (costume [number v])\nswitch costume to ((costume [number v]) - (1))\nset [last costume v] to (costume [number v])\nswitch costume to (intro v)\ngo to x: (0) y: (0)\n\n@NailThumb\n\nwhen flag clicked\nforever\n    go to x: (0) y: (0)\n    show\n    set [ghost v] effect to (100)\n    go to [front v] layer\nend\n\n@Coin Scripts\n\nwhen flag clicked\nhide\nset [coins v] to [0]\nset [y v] to [0]\nset [x v] to [0]\nswitch costume to (coin v)\nclone at x: [584] y: [-68]\nset [x v] to [-99999]\n\nwhen I receive [setup v]\nset [coins v] to [0]\nset [y v] to [0]\nset [x v] to [0]\nswitch costume to (coin v)\nclone at x: [584] y: [-68]\nset [x v] to [-99999]\n\ndefine clone at x: (x) y: (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [tick v]\nset size to (100) %\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <touching (player scripts v)?> then\n    change [coins v] by (1)\n    delete this clone\nend\n\nwhen I receive [reset v]\ndelete this clone\n\n@Checkpoint Scripts\n\nwhen flag clicked\nhide\nset [checkpoint v] to [0]\nset [y v] to [0]\nset [x v] to [0]\nswitch costume to (closed v)\nclone at x: [685] y: [-70]\nset [x v] to [-99999]\n\nwhen I receive [start game v]\n\ndefine clone at x: (x) y: (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [tick v]\nset size to (400) %\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <(costume [number v]) = [2]> then\n    if <touching (player scripts v)?> then\n        switch costume to (open v)\n        change [checkpoint v] by (1)\n    end\nend\ngo to [back v] layer\n\nwhen [p v] key pressed\nset [mouse scroll v] to (join ((SCROLL X) + (mouse x)) (join [, ] ((SCROLL Y) + (mouse y))))\n\n@Danger Scripts\n\nwhen flag clicked\nset [y v] to [0]\nset [x v] to [0]\nhide\n\nwhen I receive [start game v]\nswitch costume to (1 v)\nclone distance x: [480] y: [0]\nclone distance x: [360] y: [100]\n\ndefine clone distance x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\ndefine Position\ngo to x: ((x) - (SCROLL X)) y: ((y) - (SCROLL Y))\nif <<((x) - (SCROLL X)) = (x position)> and <((y) - (SCROLL Y)) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [tick v]\nPosition\n\n@Ground Scripts\n\nwhen flag clicked\nset [y v] to [0]\nset [x v] to [0]\nhide\n\nwhen I receive [start game v]\nswitch costume to (1 v)\nclone distance x: [480] y: [0]\nclone distance x: [360] y: [100]\n\ndefine clone distance x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\n@Player Scripts\n\nwhen flag clicked\nhide\nbroadcast (Start Game v)\n\ndefine Reset\nif <(CHECKPOINT) = [0]> then\n    set [x v] to [0]\n    set [y v] to [0]\nelse\n    if <(CHECKPOINT) = [1]> then\n        set [x v] to [683]\n        set [y v] to [-70]\n    end\nend\nset [sx v] to [0]\nset [sy v] to [0]\nset [scroll x v] to (x)\nset [scroll y v] to (y)\nset [sky time v] to [0]\nshow\nclear graphic effects\n\nwhen I receive [start game v]\nReset\nforever\n    Tick\n    if <touching (danger v)?> then\n        broadcast (Reset v) and wait\n        broadcast (Setup v) and wait\n    end\nend\n\ndefine Tick\nGame\nchange [x v] by (sx)\nchange [y v] by (sy)\nset [scroll x v] to (round (x))\nif <(SCROLL X) < [0]> then\n    set [scroll x v] to [0]\nend\nif <(SCROLL Y) > [-80]> then\n    set [scroll y v] to (round ((y) / (4)))\nelse\n    Reset\nend\nbroadcast (Tick v)\nPosition\nchange [sky time v] by (1)\nchange y by (-1)\nif <touching (ground v)?> then\n    set [sky time v] to [0]\nend\nif <touching (danger v)?> then\n    Reset\nend\nchange y by (1)\n\ndefine Position\ngo to x: ((x) - (SCROLL X)) y: ((y) - (SCROLL Y))\n\ndefine Game\nif <(sy) > [-25]> then\n    change [sy v] by (-1)\nend\nSpeed [2] friction [0.7]\nJump hieght [10]\nslope [8]\n\ndefine Speed (speed) friction (friction)\nchange [sx v] by ((<<key (right arrow v) pressed?> or <key (d v) pressed?>> - <<key (a v) pressed?> or <key (left arrow v) pressed?>>) * (speed))\nset [sx v] to ((sx) * (friction))\nchange x by (sx)\n\ndefine Jump hieght (hieght)\nif <<<key (w v) pressed?> or <key (up arrow v) pressed?>> and <(sky time) < [2]>> then\n    set [sy v] to (hieght)\nend\n\ndefine slope (slope)\nset [slope v] to [0]\nrepeat until <<(slope) = (slope)> or <not <touching (ground v)?>>>\n    change y by (1)\n    change [slope v] by (1)\n    if <touching (ground v)?> then\n        change y by ((slope) * (-1))\n        repeat until <not <touching (ground v)?>>\n            change x by ((sx) * (-1))\n        end\n        if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n            set [sy v] to [10]\n            if <(sx) < [0]> then\n                set [sx v] to [16]\n            else\n                set [sx v] to [-16]\n            end\n        else\n            set [sx v] to [0]\n        end\n    end\nend\nchange y by (sy)\nif <touching (ground v)?> then\n    change y by ((sy) * (-1))\n    set [sy v] to [0]\nend\n\nrepeat until <not <touching (ground v)?>>\n\n
Part 1!: https://scratch.mit.edu/projects/429821607/\n\nActually sure you can comment this is like griffpatch's but no hate please.\n\nNO HATE I know this isn't good but yeah NO HATE :(\n\nI noticed that slopes don't work ;-;\n\nIn this part, we will be covering how to make danger, checkpoints, and coins! Sorry if it's confusing.\n\n\n\n\n@StratfordJames for some art in the thumbnail.\n\n#tutorials #all #scrolling #platformer #tutorial #part #2