Sunset | A scrolling platformer

Instructions: Sunset | A scrolling platformer\n-------------------------------------------------------------------------\nThis is my first scrolling platformer and I actually like it very much.\n-------------------------------------------------------------------------\nInstructions:\nUse arrow keys to move.\nAvoid spikes and lava.\nIf you stay still for too long the ground vanishes.\n(Hint: The last row of spikes are fake)\n-------------------------------------------------------------------------\nUpdates:\n7th June 2021 - shared\n18th June 2021 - I moved the clouds a little upward so that now no one can cheat! ;)

@Stage\n\nwhen I receive [start v]\nforever\n    play sound [Sunlight v] until done\nend\n\n@Player\n\nchange [x v] by (8)\n\nchange [y v] by (1)\n\nset [scroll x v] to (X)\n\ndefine Restart\nset [x v] to [0]\nset [y v] to [0]\nset [y velocity v] to [0]\nset [game state v] to [Playing]\nset [y velocity v] to [0]\n\nwhen I receive [play game v]\nshow\nset [level v] to [1]\nRestart\nforever\n    repeat until <not <(Game State) = [Playing]>>\n        Update\n        Position\n    end\n    Fail\nend\n\ndefine Update\nif <key (left arrow v) pressed?> then\n    X: [-8]\nend\nif <key (right arrow v) pressed?> then\n    X: [8]\nend\nif <key (up arrow v) pressed?> then\n    if <(Air Time) < [4]> then\n        set [y velocity v] to [15]\n    end\nend\nchange [y velocity v] by (-2)\nY: (Y velocity)\nchange [scroll x v] by (((X) - (Scroll X)) / (10))\nchange [scroll y v] by (((Y) - (Scroll Y)) / (10))\nif <(Y) < [-180]> then\n    set [game state v] to [Death]\nend\nif <<touching (lava v)?> or <touching (spikes v)?>> then\n    set [game state v] to [Death]\nend\nif <(Scroll Y) < [0]> then\n    set [scroll y v] to [0]\nend\nif <(Scroll X) < [0]> then\n    set [scroll x v] to [0]\nend\n\ndefine Position\ngo to x: ((X) - (Scroll X)) y: ((Y) - (Scroll Y))\n\ndefine Y: (y velocity)\nchange [air time v] by (1)\nchange [y v] by (y velocity)\nPosition\nrepeat until <not <touching (ground v)?>>\n    if <(y velocity) > [0]> then\n        change [y v] by (-1)\n    else\n        change [y v] by (1)\n        set [air time v] to [0]\n    end\n    Position\n    set [y velocity v] to [0]\nend\n\ndefine X: (x velocity)\nchange [x v] by (x velocity)\nPosition\nif <touching (ground v)?> then\n    repeat (8)\n        change [y v] by (1)\n        Position\n        if <not <touching (ground v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-8)\n    repeat until <not <touching (ground v)?>>\n        if <(x velocity) > [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 Fail\nstop [other scripts in sprite v]\nrepeat (5)\n    hide\n    wait (.1) seconds\n    show\n    wait (.1) seconds\nend\nbroadcast (play Game v)\n\nwhen I receive [start v]\nshow\ngo to x: (-124) y: (-126)\nbroadcast (play Game v)\n\nwhen flag clicked\nhide\n\n@Ground\n\ndefine Platform: (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 start as a clone\nshow\nforever\n    Platform: ((X) - (Scroll X)) ((Y) - (Scroll Y))\nend\n\ngo to x: ((X) - (Scroll X)) y: ((Y) - (Scroll Y))\n\nwhen I receive [you won v]\nhide\n\ngo to x: (163) y: (0)\n\nwhen I receive [start v]\nset [x v] to [0]\nset [y v] to [0]\nhide\nswitch costume to (level 1 v)\ncreate clone of (_myself_ v)\nset [x v] to [480]\nset [y v] to [0]\nswitch costume to (level 2 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 3 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 4 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 5 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 6 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 7 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 8 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 9 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 10 v)\ncreate clone of (_myself_ v)\n\n@Ground2\n\ndefine Platform: (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 start as a clone\nshow\nforever\n    Platform: ((X) - (Scroll X)) ((Y) - (Scroll Y))\nend\n\ngo to x: ((X) - (Scroll X)) y: ((Y) - (Scroll Y))\n\nwhen I receive [you won v]\nhide\n\ngo to x: (163) y: (0)\n\nwhen I receive [start v]\nset [x v] to [0]\nset [y v] to [0]\nhide\nswitch costume to (level 1 v)\ncreate clone of (_myself_ v)\nset [x v] to [480]\nset [y v] to [0]\nswitch costume to (level 2 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 3 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 4 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 5 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 6 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 7 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 8 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 9 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 10 v)\ncreate clone of (_myself_ v)\n\n@Lava\n\ndefine Platform: (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 start as a clone\ngo to [back v] layer\nshow\nforever\n    Platform: ((X) - (Scroll X)) ((Y) - (Scroll Y))\nend\n\ngo to x: ((X) - (Scroll X)) y: ((Y) - (Scroll Y))\n\nwhen I receive [start v]\nset [x v] to [0]\nset [y v] to [0]\nhide\nswitch costume to (level 1 v)\ncreate clone of (_myself_ v)\nset [x v] to [480]\nset [y v] to [0]\nswitch costume to (level 2 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 3 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 4 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 5 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 6 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 7 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 8 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 9 v)\ncreate clone of (_myself_ v)\n\n@Spikes\n\ndefine Platform: (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 start as a clone\ngo to [back v] layer\nshow\nforever\n    Platform: ((X) - (Scroll X)) ((Y) - (Scroll Y))\nend\n\ngo to x: ((X) - (Scroll X)) y: ((Y) - (Scroll Y))\n\nwhen I receive [start v]\nset [x v] to [0]\nset [y v] to [0]\nhide\nswitch costume to (level 1 v)\ncreate clone of (_myself_ v)\nset [x v] to [480]\nset [y v] to [0]\nswitch costume to (level 2 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 3 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 4 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 5 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 6 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 7 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 8 v)\ncreate clone of (_myself_ v)\nchange [x v] by (480)\nset [y v] to [0]\nswitch costume to (level 9 v)\ncreate clone of (_myself_ v)\n\n@My Intro\n\nwhen I start as a clone\nshow\nif <(ID) = [Particle]> then\n    switch costume to (bg v)\n    set size to (pick random (10) to (75)) %\n    go to [front v] layer\n    go to x: (pick random (-400) to (240)) y: (-300)\n    point in direction (60)\n    if <(timer) > [5]> then\n        show\n    else\n        hide\n    end\n    set [ghost v] effect to (50)\n    if <(size) < [40]> then\n        go [backward v] (1) layers\n    end\n    set [i v] to (pick random (3) to (7))\n    set [id v] to (pick random (2) to (6))\n    repeat until <<(x position) > [399]> or <<(x position) < [-399]> or <<(y position) > [399]> or <(y position) < [-399]>>>>\n        switch costume to (movehack v)\n        move (i) steps\n        change y by (ID)\n        change [id v] by (.01)\n        switch costume to (particle v)\n        if <(timer) > [5]> then\n            show\n            if <(timer) > [8.7]> then\n                hide\n            end\n        end\n    end\n    delete this clone\nend\nif <(ID) = [Line]> then\n    point in direction (135)\n    switch costume to (blank v)\n    set size to (100) %\n    if <(timer) > [1.5]> then\n        set [ghost v] effect to (0)\n    else\n        set [ghost v] effect to (100)\n    end\n    switch costume to (movehack v)\n    go to x: (-325) y: (200)\n    go to [back v] layer\n    go [forward v] (5) layers\n    repeat until <(x position) > [300]>\n        switch costume to (movehack v)\n        if <(timer) > [1.5]> then\n            if <(timer) > [7.5]> then\n                delete this clone\n            else\n                change x by (5)\n                change y by (-5)\n                change [ghost v] effect by (-10)\n            end\n        else\n            change x by (10)\n            change y by (-10)\n        end\n        switch costume to (linething v)\n    end\n    delete this clone\nend\nif <(ID) = [BG]> then\n    switch costume to (bg v)\n    set size to (1) %\n    go to [front v] layer\n    go [backward v] (2) layers\n    repeat (5)\n        change size by (((10) - (size)) / (8))\n    end\n    repeat (50)\n        switch costume to (blank v)\n        change size by (((700) - (size)) / (12))\n        switch costume to (bg v)\n    end\n    wait until <(timer) > [8.7]>\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\n    delete this clone\nend\nif <(ID) = [CE]> then\n    switch costume to (ce v)\n    set size to (1) %\n    go to [back v] layer\n    go [forward v] (1) layers\n    set [i v] to [1]\n    repeat (15)\n        change [i v] by ((i) / (8))\n        change size by (i)\n    end\n    repeat (7)\n        change size by (((100) - (size)) / (12))\n    end\n    repeat (14)\n        change size by (((100) - (size)) / (12))\n        change size by (2)\n        next costume\n    end\n    delete this clone\nend\nif <(ID) = [BG2]> then\n    switch costume to (bg2 v)\n    set size to (100) %\n    set [ghost v] effect to (100)\n    go to [back v] layer\n    point in direction (90)\n    repeat (10)\n        change [ghost v] effect by (-10)\n    end\n    wait until <(timer) > [8]>\n    delete this clone\nend\nif <(ID) = [CT]> then\n    switch costume to (circlething2 v)\n    set size to (60) %\n    set [ghost v] effect to (100)\n    go to [back v] layer\n    go [forward v] (1) layers\n    point in direction (90)\n    go to x: (-133) y: (-46)\n    repeat (10)\n        change [ghost v] effect by (-10)\n        turn right (2) degrees\n    end\n    repeat until <(timer) > [7.5]>\n        turn right (2) degrees\n    end\n    delete this clone\nend\nif <(ID) = [CT2]> then\n    switch costume to (circlething2 v)\n    set size to (60) %\n    set [ghost v] effect to (100)\n    go to [back v] layer\n    go [forward v] (1) layers\n    point in direction (90)\n    go to x: (133) y: (46)\n    repeat (10)\n        change [ghost v] effect by (-10)\n        turn left (2) degrees\n    end\n    repeat until <(timer) > [7.5]>\n        turn left (2) degrees\n    end\n    delete this clone\nend\nif <(ID) = [Name]> then\n    set [id v] to [2]\n    if <(ID) = [1]> then\n        set [brightness v] effect to (-100)\n        switch costume to (logo3 v)\n    else\n        switch costume to (name v)\n    end\n    set size to (250) %\n    set [ghost v] effect to (100)\n    go to [front v] layer\n    point in direction (45)\n    repeat (50)\n        change [ghost v] effect by (-10)\n        change size by (((100) - (size)) / (12))\n        turn right (((90) - (direction)) / (12)) degrees\n    end\n    repeat until <(timer) > [5]>\n        change size by (-.25)\n    end\n    repeat (5)\n        change size by (((65) - (size)) / (12))\n        go to x: (pick random (-2) to (2)) y: (pick random (-2) to (2))\n        set [-kami's intro x v] to (x position)\n        set [-kami's intro y v] to (y position)\n        go to [front v] layer\n    end\n    if <(ID) = [1]> then\n        set [brightness v] effect to (0)\n        switch costume to (logo3 v)\n    else\n        switch costume to (name2 v)\n    end\n    repeat (15)\n        change size by (((65) - (size)) / (12))\n        go to x: (pick random (-2) to (2)) y: (pick random (-2) to (2))\n        set [-kami's intro x v] to (x position)\n        set [-kami's intro y v] to (y position)\n        go to [front v] layer\n    end\n    repeat (10)\n        change size by (-.25)\n        go to x: (pick random (-2) to (2)) y: (pick random (-2) to (2))\n        set [-kami's intro x v] to (x position)\n        set [-kami's intro y v] to (y position)\n    end\n    repeat (10)\n        change size by (-.25)\n        go to x: (pick random (-1) to (1)) y: (pick random (-1) to (1))\n        set [-kami's intro x v] to (x position)\n        set [-kami's intro y v] to (y position)\n    end\n    go to x: (0) y: (0)\n    set [-kami's intro x v] to [0]\n    set [-kami's intro y v] to [0]\n    repeat until <(timer) > [8]>\n        change size by (-.25)\n    end\n    set [i v] to [1]\n    set [id v] to [1]\n    repeat (10)\n        change size by (i)\n        turn right (ID) degrees\n        change [i v] by ((i) / (4))\n        change [id v] by ((ID) / (8))\n    end\n    repeat (5)\n        change size by (((250) - (size)) / (8))\n        turn right (((135) - (direction)) / (12)) degrees\n    end\n    repeat (10)\n        change size by (((250) - (size)) / (8))\n        turn right (((135) - (direction)) / (12)) degrees\n        change [ghost v] effect by (10)\n    end\n    wait (1) seconds\n    broadcast (Pizzarush's Intro v)\n    delete this clone\nend\n\nwhen flag clicked\nbroadcast (-Kami's Intro v)\n\nwhen I start as a clone\nif <(ID) = [BG]> then\n    go to x: (-Kami's Intro X) y: (-Kami's Intro Y)\nend\n\nwhen I receive [-kami's intro v]\nforever\n    Clone [Particle]\nend\n\nwhen I receive [-kami's intro v]\nset [-kami's intro x v] to [0]\nset [-kami's intro y v] to [0]\nreset timer\nstart sound [MUSICA v]\nset volume to (100) %\nhide\nclear graphic effects\nset size to (100) %\ngo to x: (0) y: (0)\npoint in direction (90)\nwait until <(timer) > [1.5]>\nClone [Skip]\nClone [BG2]\nClone [CE]\nClone [Name]\nClone [CT]\nClone [CT2]\nwait until <(timer) > [5]>\nClone [BG]\n\ndefine Clone (id)\nset [id v] to (id)\ncreate clone of (_myself_ v)\n\nwhen I receive [-kami's intro v]\nrepeat until <(timer) > [1.5]>\n    Clone [Line]\n    wait (.13) seconds\nend\nrepeat until <(timer) > [7.5]>\n    Clone [Line]\n    wait (.3) seconds\nend\n\nwhen I receive [skip -kami's intro v]\nstop [other scripts in sprite v]\nrepeat (10)\n    change [ghost v] effect by (10)\n    change volume by (-10)\nend\nbroadcast (Pizzarush's Intro v)\ndelete this clone\n\nwhen I start as a clone\nif <(ID) = [Skip]> then\n    forever\n        show\n        go to [front v] layer\n        clear graphic effects\n        set size to (100) %\n        go to x: (0) y: (0)\n        point in direction (90)\n        switch costume to (skip v)\n        if <<key (space v) pressed?> or <mouse down?>> then\n            broadcast (Skip -Kami's Intro v)\n        end\n        if <(timer) > [9]> then\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            delete this clone\n        end\n    end\nend\n\nwhen I receive [pizzarush's intro v]\nbroadcast (Start v)\n\n@Thumb\n\nwhen flag clicked\nshow\nset [ghost v] effect to (100)\ngo to [front v] layer\ngo to x: (0) y: (0)\nset volume to (100) %\n\n