Galaxy || A Scrolling Platformer

Instructions:  ➡ Use Arrow keys, or tap to use (Mobile)\n ➡ Watch out for spikes and lava\n ➡ There are two checkpoints\n ➡ Love and fav for a cookie

@Stage\n\n@Blank\n\nwhen flag clicked\nswitch costume to (costume1 v)\nhide\n\n@Player\n\nset [x v] to [12043]\nset [y v] to [2500]\n\nwhen flag clicked\nbroadcast (Green Flag v) and wait\nbroadcast (Play Game v) and wait\nshow\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\n\nwhen I receive [play game v]\nforever\n    broadcast (Reset v) and wait\n    broadcast (Setip v) and wait\n    Game on\n    repeat until <(EXIT) > []>\n        Tick\n        broadcast (Tick v)\n    end\n    if <(EXIT) = [Win]> then\n        Game - Win\n    else\n        Game - Die\n    end\nend\n\ndefine Game on\nset [speed y v] to [0]\nset [speed x v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nset [scrollx v] to [0]\nset [scrolly v] to [0]\nset size to (10) %\nclear graphic effects\nshow\nset size to (30) %\nclear graphic effects\nshow\nif <(Checkpoint) = [0]> then\n    set [x v] to [0]\n    set [y v] to [0]\nend\n\ndefine Tick\nif <<key (left arrow v) pressed?> or <<mouse down?> and <(mouse x) < (x position)>>> then\n    change [speed x v] by (-2)\n    point in direction (-90)\nend\nif <<key (right arrow v) pressed?> or <<mouse down?> and <(mouse x) > (x position)>>> then\n    change [speed x v] by (2)\n    point in direction (90)\nend\nset [speed x v] to ((Speed x) * (0.8))\nif <([abs v] of (Speed x) ) > [0.9]> then\n    Change player x by (round (Speed x))\nend\nif <<key (up arrow v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>> then\n    if <(in air) < [4]> then\n        set [speed y v] to [16]\n    end\nend\nif <(Speed y) > [-20]> then\n    change [speed y v] by (-2)\nend\nChange player y by (Speed y)\nTest - Die\nchange [scrollx v] by (round (((x) - (scrollx)) / (5)))\nif <(scrollx) < [0]> then\n    set [scrollx v] to [0]\nend\nif <(scrollx) > [6200]> then\n    set [scrollx v] to [6200]\nend\nchange [scrolly v] by (round (((y) - (scrolly)) / (10)))\nif <(scrolly) < [0]> then\n    set [scrolly v] to [0]\nend\nPosition\nif <(y) < [-178]> then\n    set [exit v] to [Die]\nend\nif <<touching (spikes v)?> or <touching (lava v)?>> then\n    set [exit v] to [Die]\nend\n\ndefine Change player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nPosition\nrepeat until <not <touching (platforms 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 [speed y v] to [0]\nend\n\ndefine Position\ngo to x: ((x) - (scrollx)) y: ((y) - (scrolly))\n\ndefine Change player x by (sx)\nchange [x v] by (sx)\nPosition\nif <touching (platforms v)?> then\n    repeat (12)\n        change [y v] by (1)\n        Position\n        if <not <touching (platforms v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    if <<key (up arrow v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>> then\n        if <(sx) > [0]> then\n            set [speed x v] to [-16]\n        else\n            set [speed x v] to [16]\n        end\n        set [in air v] to [0]\n    else\n        set [speed x v] to [0]\n    end\n    repeat until <not <touching (platforms v)?>>\n        if <(sx) > [0]> then\n            change [x v] by (-1)\n        else\n            change [x v] by (1)\n        end\n        Position\n    end\nend\n\ndefine Game - Die\nif <(Checkpoint) = [1]> then\n    set [x v] to [1389]\n    set [y v] to [163]\nelse\n    if <<(Checkpoint) = [2]> or <(Checkpoint) = [3]>> then\n        set [x v] to [2600]\n        set [y v] to [294]\n    end\nend\nset [exit v] to []\nrepeat (5)\n    hide\n    wait (0.05) seconds\n    show\n    wait (0.05) seconds\nend\n\ndefine Game - Win\n\ndefine Test - Die\n\nwhen flag clicked\nforever\n\nif <not <(EXIT) = [die]>> then\n\nwhen flag clicked\nforever\n    play sound [TheFatRat - Fly Away \(Instrumental\) v] until done\nend\n\n@spikes\n\nwhen I receive [green flag v]\ngo to [back v] layer\nhide\n\nwhen I receive [tick v]\nPosition ((x) - (scrollx)) ((y) - (scrolly))\n\nwhen I receive [setip v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL2) = [1]> then\n    switch costume to (level 1-1 v)\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\nend\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 [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nwhen I receive [end v]\nforever\n    hide\n    delete this clone\nend\n\nwhen flag clicked\nset [level2 v] to [1]\n\n@Lava\n\nwhen I receive [green flag v]\ngo to [back v] layer\nhide\n\nwhen I receive [tick v]\nPosition ((x) - (scrollx)) ((y) - (scrolly))\n\nwhen I receive [setip 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: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\nend\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 [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nwhen I receive [end v]\nforever\n    hide\n    delete this clone\nend\n\nwhen flag clicked\nset [level v] to [1]\n\n@Checkpoint \n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <(costume [number v]) = [2]> then\n    if <touching (player v)?> then\n        change [checkpoint v] by (1)\n        switch costume to (green flag v)\n    end\nend\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\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\nset [checkpoint v] to [0]\nhide\nset [level2 v] to [1]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL2) = [1]> then\n    switch costume to (close flag v)\n    Clone at x: [1389] y: [169]\n    Clone at x: [2600] y: [294]\nend\n\nwhen I receive [end v]\nforever\n    hide\nend\n\nwhen I receive [end v]\nforever\n    hide\n    delete this clone\nend\n\n@Platforms\n\nwhen I receive [green flag v]\ngo to [front v] layer\nhide\n\nwhen I receive [tick v]\nPosition ((x) - (scrollx)) ((y) - (scrolly))\n\nwhen I receive [setip v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL2) = [1]> then\n    switch costume to (level 1-1 v)\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [60]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [90]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [0]\n    Clone at x: [480] y: [140]\nend\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 [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nwhen flag clicked\nset [level2 v] to [1]\n\n@TB\n\nwhen flag clicked\nforever\n    show\n    go to [front v] layer\n    set [ghost v] effect to (100)\n    go to x: (0) y: (0)\nend\n\ngo to [front v] layer\nhide\nset size to (100) %\n\nwhen flag clicked\n\nshow\n\n