Pug Platformer 2

Instructions: NEON GALAXY 4 OUT NOW: https://scratch.mit.edu/projects/409691580/\n\nUse the arrow keys to move.\nGet to the green block to get to the next level. If you touch red you restart the level.\n\nThis game is a sequel to my old game "Pug Platformer" fixing all its bugs and adding brand new levels with new mechanics.\n\n*Share your time in the comments*

@Stage\n\nwhen flag clicked\nforever\n    play sound [Sonic 3 - Ice Cap Zone Remix \(Plasma3Music.mp3 v] until done\nend\n\n@Engine\n\ndefine Touch Ground <>\nchange [falling? v] by (1)\nrepeat until <not <touching color (#666666)?>>\n    if <up?> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling? v] to [0]\n    end\n    set [speed y v] to [0]\nend\n\ndefine None\npoint in direction (direction)\nchange x by (speed)\nset [slope v] to [0]\nrepeat until <<(slope) = [8]> or <not <touching color (#666666)?>>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <(slope) = [8]> then\n    change x by ((0) - (speed))\n    change y by ((0) - (slope))\nend\nchange [frame v] by (0.5)\n\nwhen flag clicked\nset [speed y v] to [0]\nforever\n    switch costume to (8 v)\n    if <<(speed y) < [4]> or <key (up arrow v) pressed?>> then\n        change [speed y v] by (-1)\n    else\n        change [speed y v] by (-2)\n    end\n    change y by (speed y)\n    Touch Ground <(speed y) > [0]>\nend\n\ndefine Set Costume\nif <(falling?) < [3]> then\n    if <(frame) = [0]> then\n        switch costume to (5 v)\n    else\n        switch costume to ([floor v] of ((2) + ((frame) mod (7))) )\n    end\nelse\n    if <(speed y) > [0]> then\n        switch costume to (1 v)\n    else\n        switch costume to (2 v)\n    end\nend\n\nwhen flag clicked\nforever\n    if <key (left arrow v) pressed?> then\n        Walk (-90) (-6)\n    else\n        if <key (right arrow v) pressed?> then\n            Walk (90) (6)\n        else\n            set [frame v] to [0]\n        end\n    end\n    if <key (up arrow v) pressed?> then\n        if <<(jump key) = [0]> and <(falling?) < [3]>> then\n            set [speed y v] to [14]\n            set [falling? v] to [6]\n            set [jump key v] to [1]\n        end\n    else\n        set [jump key v] to [0]\n    end\n    Set Costume\nend\n\nforever\n    if <key (up arrow v) pressed?> then\n        wait (0.01) seconds\n        if <not <(falling?) < [3]>> then\n            play sound [Jump v] until done\n            wait until <touching color (#666666)?>\n        end\n    end\nend\n\nwhen flag clicked\nshow variable [time: v]\nforever\n    if <touching color (#ff0000)?> then\n        go to x: (-176) y: (-123)\n    end\nend\n\nwhen flag clicked\nswitch backdrop to (level1 v)\ngo to x: (-176) y: (-123)\npoint in direction (90)\nwait until <touching color (#ccffdd)?>\nbroadcast (message1 v)\nswitch backdrop to (level2 v)\ngo to x: (-176) y: (-123)\nwait until <touching color (#ccffdd)?>\nswitch backdrop to (level3 v)\ngo to x: (-176) y: (-123)\nwait until <touching color (#ccffdd)?>\nswitch backdrop to (level4 v)\ngo to x: (-176) y: (-123)\nwait until <touching color (#ccffdd)?>\nswitch backdrop to (level5 v)\ngo to x: (-176) y: (-123)\nwait until <touching color (#ccffdd)?>\nswitch backdrop to (level6 v)\ngo to x: (-176) y: (-123)\nwait until <touching color (#ccffdd)?>\nswitch backdrop to (level7 v)\ngo to x: (-176) y: (-123)\nwait until <touching color (#ccffdd)?>\nswitch backdrop to (level8 v)\ngo to x: (-176) y: (-123)\nwait until <touching color (#ccffdd)?>\nswitch backdrop to (level9 v)\ngo to x: (-176) y: (-123)\nwait until <touching color (#ccffdd)?>\nswitch backdrop to (level10 v)\ngo to x: (-176) y: (-123)\nwait until <touching color (#ccffdd)?>\nswitch backdrop to (level11 v)\ngo to x: (-176) y: (-123)\nwait until <touching color (#ccffdd)?>\nswitch backdrop to (level12 v)\ngo to x: (-176) y: (-123)\nwait until <touching color (#ccffdd)?>\nswitch backdrop to (level13 v)\ngo to x: (-176) y: (-123)\nwait until <touching color (#ccffdd)?>\nswitch backdrop to (game over v)\nbroadcast (end v)\ngo to x: (-176) y: (-123)\n\n@302301-200\n\nwhen flag clicked\nset [ghost v] effect to (0)\nchange [ghost v] effect by (50)\ngo to x: (-156) y: (28)\nshow\n\nwhen I receive [message1 v]\nhide\n\n@pug platformer 2\n\nwhen flag clicked\nhide variable [☁ global best v]\ngo to x: (0) y: (0)\nhide\n\nwhen flag clicked\nset [end v] to [0]\nset [time: v] to [0]\nrepeat until <(end) = [1]>\n    wait (1) seconds\n    if <not <(end) = [1]>> then\n        change [time: v] by (1)\n    end\nend\n\nwhen I receive [end v]\nset [end v] to [1]\nshow variable [☁ global best v]\n\nwhen flag clicked\nforever\n    if <(end) = [1]> then\n        if <(☁ Global Best) > (Time:)> then\n            set [☁ global best v] to (Time:)\n        end\n    end\nend\n\n