Scrolling Platformer Starter


@Stage\n\nwhen [m v] key pressed\n\nset [mouse v] to (join (round ((mouse x) + (SCROLL_X))) (join [/] (round ((mouse y) + (SCROLL_Y)))))\nshow variable [mouse v]\n\n@Player\n\nwhen flag clicked\nbroadcast (Green Flag v) and wait\nbroadcast (Play Game v) and wait\n\nwhen I receive [play game v]\nset [level v] to [1]\nbroadcast (Set Up v) and wait\nforever\n    Reset\n    broadcast (Set Up v) and wait\n    repeat until <(EXIT) > []>\n        Tick\n        broadcast (Tick v) and wait\n    end\n    if <(EXIT) = [die]> then\n        Die Animation\n    else\n        if <(EXIT) = [win]> then\n            Win Animation\n            change [level v] by (1)\n        end\n    end\nend\n\ndefine Tick\ngo to [front v] layer\nif <<<key (w v) pressed?> or <key (up arrow v) pressed?>> and <(in air) < [4]>> then\n    set [yv v] to [12]\nend\nif <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n    change [xv v] by (-2)\n    point in direction (-90)\nelse\n    if <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n        change [xv v] by (2)\n        point in direction (90)\n    end\nend\nif <(yv) > [-15]> then\n    change [yv v] by (-1)\nend\nMove X (xv)\nMove Y (yv)\nset [xv v] to ((xv) * (.8))\nif <touching (danger v)?> then\n    set [exit v] to [die]\nend\nif <touching (exit v)?> then\n    set [exit v] to [win]\nend\nchange [scroll_x v] by (((x) - (SCROLL_X)) / (5))\nchange [scroll_y v] by ((((y) + (50)) - (SCROLL_Y)) / (5))\nif <(y) < [-1500]> then\n    set [exit v] to [die]\nend\nPosition\n\ndefine Reset\nset [x v] to [0]\nset [y v] to [-50]\nset [scroll_x v] to [0]\nset [scroll_y v] to [0]\nset [xv v] to [0]\nset [yv v] to [0]\npoint in direction (90)\nset [exit v] to []\nshow\nclear graphic effects\n\ndefine Move Y (y)\nchange [in air v] by (1)\nchange [y v] by (y)\nPosition\nif <touching (level v)?> then\n    set [n v] to [0]\n    repeat until <<not <touching (level v)?>> or <(n) > [50]>>\n        change [n v] by (1)\n        if <(yv) > [0]> then\n            change [y v] by (-1)\n        else\n            change [y v] by (1)\n        end\n        Position\n    end\n    set [yv v] to [0]\n    change [y v] by (-5)\n    Position\n    if <touching (level v)?> then\n        set [in air v] to [0]\n    end\n    change [y v] by (5)\n    Position\nend\n\ndefine Move X (x)\nchange [x v] by (x)\nPosition\nif <touching (level v)?> then\n    repeat (10)\n        change [y v] by (1)\n        Position\n        if <not <touching (level v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-10)\n    Position\n    if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n        if <(x) > [0]> then\n            set [xv v] to [-16]\n        else\n            set [xv v] to [16]\n        end\n        set [in air v] to [0]\n    else\n        set [xv v] to [0]\n    end\n    set [n v] to [0]\n    repeat until <<not <touching (level v)?>> or <(n) = [50]>>\n        if <(x) > [0]> then\n            change [x v] by (-1)\n        else\n            change [x v] by (1)\n        end\n        Position\n        change [n v] by (1)\n    end\n    if <(x) > [0]> then\n        change [x v] by (-1)\n    else\n        change [x v] by (1)\n    end\n    Position\nend\n\ndefine Position\ngo to x: ((x) - (SCROLL_X)) y: ((y) - (SCROLL_Y))\n\ndefine Die Animation\nset rotation style [all around v]\nset [yv v] to [10]\nrepeat until <(y position) < [-179]>\n    change y by (yv)\n    turn right (5) degrees\n    if <(yv) > [-15]> then\n        change [yv v] by (-1)\n    end\nend\nset rotation style [left-right v]\n\ndefine Win Animation\nrepeat (50)\n    change [ghost v] effect by (2)\n    change x by ((([x position v] of [exit v]) - (x position)) / (20))\n    change y by ((([y position v] of [exit v]) - (y position)) / (20))\nend\nhide\n\n@Level\n\nwhen I receive [tick v]\nPosition\nswitch costume to (id)\nif <<([abs v] of ((x position) - ((x) - (SCROLL_X))) ) < [1]> and <([abs v] of ((y position) - ((y) - (SCROLL_Y))) ) < [1]>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [set up v]\nif  then\n    delete this clone\nend\nif <(LEVEL) = [1]> then\n    Create Platform (x,y) [0] [0] id: [1]\n    Create Platform (x,y) [480] [0] id: [2]\n    Create Platform (x,y) [960] [0] id: [3]\n    Create Platform (x,y) [1400] [0] id: [4]\nelse\n    if <(LEVEL) = [2]> then\n        Create Platform (x,y) [0] [0] id: [5]\n    end\nend\n\ndefine Create Platform (x,y) (x) (y) id: (id)\ncreate clone of (_myself_ v)\nset [x v] to (x)\nset [y v] to (y)\nset [id v] to (id)\nswitch costume to (id)\n\ndefine Position\ngo to x: ((x) - (SCROLL_X)) y: ((y) - (SCROLL_Y))\n\n@Danger\n\nwhen I receive [tick v]\nPosition\nif <<([abs v] of ((x position) - ((x) - (SCROLL_X))) ) < [1]> and <([abs v] of ((y position) - ((y) - (SCROLL_Y))) ) < [1]>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [set up v]\nif  then\n    delete this clone\nend\nif <(LEVEL) = [1]> then\n    Create Obstacle (x,y) [892] [-44] id: [1]\n    Create Obstacle (x,y) [1025] [-44] id: [1]\nend\n\ndefine Create Obstacle (x,y) (x) (y) id: (id)\ncreate clone of (_myself_ v)\nset [x v] to (x)\nset [y v] to (y)\nswitch costume to (id)\n\ndefine Position\ngo to x: ((x) - (SCROLL_X)) y: ((y) - (SCROLL_Y))\n\n@Exit\n\nwhen I receive [tick v]\nPosition\nif <<([abs v] of ((x position) - ((x) - (SCROLL_X))) ) < [1]> and <([abs v] of ((y position) - ((y) - (SCROLL_Y))) ) < [1]>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [set up v]\nif <(LEVEL) = [1]> then\n    set [x v] to [1725]\n    set [y v] to [50]\nelse\n    if <(LEVEL) = [2]> then\n        set [x v] to [2000]\n        set [y v] to [0]\n    end\nend\n\ndefine Position\ngo to x: ((x) - (SCROLL_X)) y: ((y) - (SCROLL_Y))\n\n@Object Template\n\nwhen I receive [set up v]\n\nif  then\n    delete this clone\nend\nif <(LEVEL) = [1]> then\nend\n\ndefine Create Object (x,y) (x) (y) id: (id)\ncreate clone of (_myself_ v)\nset [x v] to (x)\nset [y v] to (y)\nswitch costume to (id)\n\nwhen I receive [tick v]\n\nPosition\nif <<([abs v] of ((x position) - ((x) - (SCROLL_X))) ) < [1]> and <([abs v] of ((y position) - ((y) - (SCROLL_Y))) ) < [1]>> then\n    show\nelse\n    hide\nend\n\ndefine Position\ngo to x: ((x) - (SCROLL_X)) y: ((y) - (SCROLL_Y))\n\nCreate Object (x,y) [replace this with x position] [replace this with y position] id: [replace this with costume#]\n\n@Thumbnail\n\nwhen flag clicked\nset [ghost v] effect to (100)\n\nwhen [timer v] > (.5)\ngo to [front v] layer\n\n