Platformer Journey (a scrolling platformer)

Instructions: use the arrow keys or W,A,S,D\n

@Stage\n\nwhen I receive [cut1 v]\nchange [ghost v] effect by (25)\nchange [ghost v] effect by (25)\n\nset [ghost v] effect to (0)\n\nwhen flag clicked\nset [ghost v] effect to (0)\n\n@Blank\n\ndefine when clicked\nplay sound [trance-Dragon v] until done\nplay sound [High Hopes - Panic! At The Disco v] until done\nplay sound [Marshmello, Bastille - Happier - Muzix.net.mp3 v] until done\n\nwhen flag clicked\nforever\n    change [counter v] by (1)\n    wait (0) seconds\n    if <(timer) > [1]> then\n        reset timer\n        set [fps v] to (counter)\n        set [counter v] to [0]\n    end\nend\n\nwhen flag clicked\nforever\n    if <(FPS) < [10]> then\n        ​​log​​ [game is too laggy]\n        ​​error​​ [debug]\n    end\nend\n\nwhen I receive [cut1 v]\nstop [other scripts in sprite v]\nplay sound [Dance Funky v] until done\n\nwhen flag clicked\nset [☁ cloudy v] to [3.1415926535 8979323846 2643383279 5028841971 6939937510 5820974944 5923078164 0628620899 8628034825 3421170679^P]\n\nwhen I receive [when clicked v]\nforever\n    when clicked\nend\n\n@Level\n\ndefine Go to pos\nswitch costume to (big v)\nset x to ((MyX) - (ScrollX))\nswitch costume to (lvlsegc)\n\nwhen I receive [lvl v]\nGo to pos\nif <(MyX) = [2400]> then\n    broadcast (Platformer v)\nend\n\nwhen I start as a clone\ngo to [back v] layer\n\nwhen I receive [next level v]\nchange [lvlsegc v] by (5)\n\ndefine Create lvl\nrepeat (5)\n    create clone of (_myself_ v)\n    change [lvlsegc v] by (1)\n    change [myx v] by (480)\nend\n\ndefine when clicked\nset [myx v] to [0]\nset [lvlsegc v] to [1]\nswitch costume to (costume1 v)\nshow\nset y to (0)\nCreate lvl\nhide\nbroadcast (Platformer v)\n\nwhen I receive [cut1 v]\nhide\nswitch backdrop to (wall 1 v)\n\nwhen flag clicked\nswitch backdrop to (backdrop1 v)\n\nwhen I receive [when clicked v]\nwhen clicked\n\nwhen flag clicked\nbroadcast (when clicked v)\n\n@Thumb\n\nwhen I receive [when clicked v]\nshow\nwait (3) seconds\nhide\nbroadcast (begin v)\n\nwhen flag clicked\nhide\n\n@Player\n\nwhen flag clicked\nwhen clicked\n\nwhen I receive [platformer v]\nif <(cl) = [0]> then\n    Platformer\n    broadcast (Lvl v)\n    create clone of (_myself_ v)\nend\n\ndefine Platformer\nswitch costume to ((<<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(mouse x) > (x position)>>> - <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(x position) > (mouse x)>>>) + (2))\nchange x by (Xspeed)\nif <<touching color (#4ec254)?> or <touching color (#020204)?>> then\n    repeat (8)\n        if <<touching color (#4ec254)?> or <touching color (#020204)?>> then\n            change y by (1)\n        end\n    end\n    if <<touching color (#4ec254)?> or <touching color (#020204)?>> then\n        change y by (-8)\n        repeat until <not <<touching color (#4ec254)?> or <touching color (#020204)?>>>\n            change x by ((0) - ((Xspeed) / ([abs v] of (Xspeed) )))\n        end\n        if <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<(mouse y) > (y position)> and <mouse down?>>>> then\n            set [xspeed v] to ((15) * ((0) - ((Xspeed) / ([abs v] of (Xspeed) ))))\n            set [yspeed v] to [12]\n        else\n            set [xspeed v] to [0]\n        end\n    end\nend\nchange [xspeed v] by ((2) * (<<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(mouse x) > (x position)>>> - <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(x position) > (mouse x)>>>))\nchange [xspeed v] by (<(Xspeed) < [0]> - <(Xspeed) > [0]>)\nchange [xspeed v] by (<(Xspeed) < [-10]> - <(Xspeed) > [10]>)\nchange y by (Yspeed)\nif <<touching color (#4ec254)?> or <touching color (#020204)?>> then\n    repeat until <not <<touching color (#4ec254)?> or <touching color (#020204)?>>>\n        change y by ((0) - ((Yspeed) / ([abs v] of (Yspeed) )))\n    end\n    if <<(Yspeed) < [0]> and <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<(mouse y) > (y position)> and <mouse down?>>>>> then\n        set [yspeed v] to [14]\n    else\n        set [yspeed v] to [0]\n    end\nend\nif <touching color (#9e4ec2)?> then\n    set [scrollx v] to [50]\n    set [xspeed v] to [0]\n    set [yspeed v] to [0]\n    set y to (0)\n    broadcast (Next Level v)\nend\nif <<<touching color (#ff5300)?> or <touching color (#525252)?>> or <touching color (#838383)?>> then\n    set [scrollx v] to [50]\n    set [xspeed v] to [0]\n    set [yspeed v] to [0]\n    set y to (0)\nend\nchange [yspeed v] by (-1)\nchange [scrollx v] by (x position)\nset x to (0)\nif <<touching color (#4ec2aa)?> and <<key (l v) pressed?> or <mouse down?>>> then\n    broadcast (cut1 v)\n    hide\n    stop [other scripts in sprite v]\nend\n\nwhen I start as a clone\nset [cl v] to [1]\nset [trail v] to (ScrollX)\nswitch costume to (costume1 v)\nset [ghost v] effect to (30)\nrepeat (10)\n    change [ghost v] effect by (7)\n    change size by (-5)\n    set x to ((Trail) - (ScrollX))\nend\ndelete this clone\n\nwhen I receive [begin v]\nshow\n\ndefine when clicked\nhide\nset [cl v] to [0]\nset [scrollx v] to [50]\nset [xspeed v] to [0]\nset [yspeed v] to [0]\ngo to x: (0) y: (0)\nif <(cl) = [0]> then\n    Platformer\n    broadcast (Lvl v)\n    create clone of (_myself_ v)\nend\n\n@Sprite1\n\nwhen flag clicked\nhide\n\nwhen I receive [cut1 v]\nset [ghost v] effect to (0)\nshow\nwait (2) seconds\nchange [ghost v] effect by (25)\nchange [ghost v] effect by (25)\n\nwhen I receive [end v]\nhide\n\n@Player2\n\nwhen flag clicked\nhide\n\nwhen I receive [cut1 v]\nshow\n\nwhen I receive [end v]\nhide\n\n@Sprite2\n\nwhen flag clicked\nhide\n\nwhen I receive [cut1 v]\nswitch costume to (costume12 v)\nshow\nwait (2) seconds\nrepeat (42)\n    start sound [Jump v]\n    next costume\n    wait (0.2) seconds\nend\nwait (2) seconds\nbroadcast (end v)\n\nwhen I receive [end v]\nhide\n\nwhen flag clicked\n\n@Thumb2\n\nwhen I receive [end v]\nset [color v] effect to (0)\nshow\nwait (1) seconds\nforever\n    wait (0.1) seconds\n    change [color v] effect by (20)\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [end v]\nforever\n    play sound [trance-Dragon v] until done\nend\n\n@Particle\n\nwhen flag clicked\nswitch costume to (costume1 v)\nhide\ngo to [back v] layer\nforever\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\ngo to [back v] layer\nset [ghost v] effect to (pick random (20) to (50))\nshow\nset y to (-10000)\nset [myx v] to (pick random ((ScrollX) - (400)) to ((ScrollX) + (400)))\nset [bubble speed v] to (pick random (5) to (12))\nset size to (pick random (50) to (150)) %\nrepeat (30)\n    switch costume to (costume2 v)\n    change y by (Bubble speed)\n    set x to ((MyX) - (ScrollX))\n    switch costume to (costume1 v)\n    change size by (-1)\n    change [ghost v] effect by (1)\nend\ndelete this clone\n\n