Red Ball (Scrolling Platformer)

Instructions: Arrow Keys WASD/ Mobile\nW-up\nD-Right\nA-Left \n\nCheckpoints added\n\ngriffpatch for tutorial\n

@Stage\n\nwhen [m v] key pressed\nset [mouse v] to (join ((mouse x) + (SCROLL X)) (join [,] ((mouse y) + (SCROLL Y))))\nshow variable [mouse v]\n\nwhen I receive [play game v]\nforever\n    play sound [red_ball_main_theme_-6950660994915802122 v] until done\nend\n\n@Clouds\n\nwhen I receive [green flag v]\nshow\n\nwhen I receive [tick v]\nPosition at ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [set up v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1 1 v)\n    Clone at X: [550] Y: [-40]\nend\n\ndefine Position at (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\ndefine Clone at X: (x) Y: (y)\ncreate clone of (_myself_ v)\nset [x v] to (x)\nset [y v] to (y)\nnext costume\n\n@Danger\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition at ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [set up v]\nhide\nset [x v] to [-9999]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1 1 v)\n    Clone at X: [761] Y: [-95]\n    Clone at X: [850] Y: [60]\n    Clone at X: [1200] Y: [210]\n    Clone at X: [1708] Y: [275]\n    Clone at X: [2136] Y: [407]\n    Clone at X: [2616] Y: [234]\n    Clone at X: [2735] Y: [235]\n    Clone at X: [2504] Y: [236]\n    Clone at X: [2873] Y: [235]\n    Clone at X: [2993] Y: [235]\n    Clone at X: [3122] Y: [235]\n    Clone at X: [3942] Y: [474]\n    Clone at X: [4132] Y: [556]\n    Clone at X: [4070] Y: [472]\n    Clone at X: [4193] Y: [556]\n    Clone at X: [4248] Y: [630]\n    Clone at X: [4292] Y: [630]\n    Clone at X: [4400] Y: [690]\n    Clone at X: [3553] Y: [375]\n    Clone at X: [-555] Y: [-6]\n    Clone at X: [5053] Y: [988]\n    Clone at X: [5200] Y: [988]\n    Clone at X: [5855] Y: [1253]\n    Clone at X: [6000] Y: [1253]\n    Clone at X: [6172] Y: [1253]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 1 1 v)\n        Clone at X: [397] Y: [64]\n        Clone at X: [501] Y: [64]\n        Clone at X: [595] Y: [64]\n        Clone at X: [702] Y: [63]\n        Clone at X: [1118] Y: [58]\n        Clone at X: [1157] Y: [138]\n        Clone at X: [1512] Y: [175]\n    end\nend\n\ndefine Position at (x) (y)\ngo to x: (x) y: (y)\nif <<(round (x)) = (round (x position))> and <(round (y)) = (round (y position))>> then\n    show\nelse\n    hide\nend\n\ndefine Clone at X: (x) Y: (y)\ncreate clone of (_myself_ v)\nset [x v] to (x)\nset [y v] to (y)\nnext costume\n\nturn right (15) degrees\n\n@Platform\n\nwhen I receive [green flag v]\nshow\n\nwhen I receive [tick v]\nPosition at ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [set up v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1 1 v)\n    Clone at X: [550] Y: [-40]\n    Clone at X: [1073] Y: [23]\n    Clone at X: [1440] Y: [217]\n    Clone at X: [2015] Y: [285]\n    Clone at X: [2450] Y: [360]\n    Clone at X: [3000] Y: [343]\n    Clone at X: [3580] Y: [375]\n    Clone at X: [4127] Y: [461]\n    Clone at X: [4900] Y: [766]\n    Clone at X: [5700] Y: [1030]\n    Clone at X: [6300] Y: [1173]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2 1 v)\n        Clone at X: [530] Y: [37]\n        Clone at X: [1110] Y: [150]\n    end\nend\n\ndefine Position at (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\ndefine Clone at X: (x) Y: (y)\ncreate clone of (_myself_ v)\nset [x v] to (x)\nset [y v] to (y)\nnext costume\n\n@Blank\n\n@Thumbnail\n\nwhen flag clicked\nshow\nset [ghost v] effect to (100)\ngo to [front v] layer\n\n@EXIT\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition at ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <touching (redball v)?> then\n    set [exit v] to [Win]\nend\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [set up v]\nhide\nset [x v] to [-9999]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (portal open v)\n    Clone at X: [6644] Y: [1334]\nend\n\ndefine Position at (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\ndefine Clone at X: (x) Y: (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\n@RedBall\n\ndefine Position\ngo to x: ((x) - (SCROLL X)) y: ((y) - (SCROLL Y))\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]\nforever\n    broadcast (Reset v) and wait\n    broadcast (Set Up v) and wait\n    Game-On\n    repeat until <[] < (EXIT)>\n        Tick\n        broadcast (Tick v) and wait\n    end\n    if <(EXIT) = [Win]> then\n        Game-win\n    else\n        Game-die\n    end\nend\n\ndefine Game-On\nif <(CHECK) = [1]> then\n    set [x v] to [0]\n    set [y v] to [0]\n    set [scroll y v] to [0]\n    set [scroll x v] to [0]\n    set [sx v] to [0]\n    set [sy v] to [0]\n    set [exit v] to []\n    set [in air v] to [0]\n    show\nelse\n    if <<(CHECK) = [2]> and <(LEVEL) = [1]>> then\n        set [x v] to [3428]\n        set [y v] to [383]\n        set [scroll y v] to [381]\n        set [scroll x v] to [3428]\n        set [sx v] to [0]\n        set [sy v] to [0]\n        set [exit v] to []\n        set [in air v] to [0]\n        show\n    else\n        if <<(CHECK) = [2]> and <(LEVEL) = [2]>> then\n            set [x v] to [0]\n            set [y v] to [0]\n            set [scroll y v] to [0]\n            set [scroll x v] to [0]\n            set [sx v] to [0]\n            set [sy v] to [0]\n            set [exit v] to []\n            set [in air v] to [0]\n            show\n        end\n    end\nend\n\ndefine Tick\nswitch costume to (hitbox v)\nif <<<key (d v) pressed?> or <key (right arrow v) pressed?>> or <<mouse down?> and <(mouse x) > (x position)>>> then\n    change [sx v] by (2)\n    turn right (15) degrees\nend\nif <<<key (a v) pressed?> or <key (left arrow v) pressed?>> or <<mouse down?> and <(x position) > (mouse x)>>> then\n    change [sx v] by (-2)\n    turn left (15) degrees\nend\nif <<<key (w v) pressed?> or <key (up arrow v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>> then\n    if <(in air) < [4]> then\n        set [sy v] to [13]\n    end\nend\nset [sx v] to ((sx) * (0.8))\nif <([abs v] of (sx) ) > [0.9]> then\n    Change Player x by (round (sx))\nend\nChange Player y by (sy)\nif <(sy) > [-20]> then\n    change [sy v] by (-2)\nend\nset [scroll x v] to (x)\nTest-Die\nif <(SCROLL X) < [0]> then\n    set [scroll x v] to [0]\nend\nchange [scroll y v] by (round (((y) - (SCROLL Y)) / (10)))\nif <(SCROLL Y) < [0]> then\n    set [scroll y v] to [0]\nend\nPosition\nif <(y) < [-180]> then\n    set [exit v] to [Die]\nend\nswitch costume to (idle  v)\n\ndefine Change Player x by (sx)\nchange [x v] by (sx)\nPosition\nif <touching (platform v)?> then\n    repeat (12)\n        change [y v] by (1)\n        Position\n        if <not <touching (platform v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    repeat until <not <touching (platform v)?>>\n        if <(sx) > [0]> then\n            change [x v] by (-1)\n        else\n            change [x v] by (2)\n        end\n        Position\n    end\nend\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\n\ndefine Change Player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nPosition\nrepeat until <not <touching (platform v)?>>\n    if <(sy) > [0]> then\n        change [y v] by (-1)\n    else\n        change [y v] by (1)\n        set [in air v] to [0]\n    end\n    Position\n    set [sy v] to [0]\nend\n\ndefine Game-die\nset [exit v] to []\nrepeat (5)\n    hide\n    wait (0.1) seconds\n    show\n    wait (0.1) seconds\nend\nhide\nwait (0.5) seconds\n\ndefine Test-Die\nif <touching (danger v)?> then\n    set [exit v] to [Die]\nend\n\ndefine Game-win\nchange [level v] by (1)\n\nset [check v] to [0]\n\n@Checkpoint\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition at ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <touching (redball v)?> then\n    if <(costume [number v]) = [1]> then\n        switch costume to (check v)\n        change [check v] by (1)\n    end\nend\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [set up v]\n\ndefine Position at (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\ndefine Clone at X: (x) Y: (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nhide\nset [x v] to [-9999]\nset [y v] to [0]\nset [check v] to [1]\nswitch costume to (no check v)\nif <(LEVEL) = [1]> then\n    Clone at X: [3427] Y: [410]\nend\n\n