A Platformer

Instructions: Cubey has been trapped in a large metal maze! Help him escape! Use arrow keys or AD to move side to side. Use space to jump. Try to get to the right side of the screen! Pls, leave a like or favorite! I spent a long time on this! Sometimes there is a weird glitch and Cubey spawns in the ground. If this happens press "r". As soon as you press the green flag, the timer will start, so be ready!!!!! Post your time in the chat. My record is 28.2 seconds. I am sure you can beat it. Look at more of my projects @DDoggos_101 !!!

@Stage\n\nwhen flag clicked\n\nforever\n\n\n\nswitch backdrop to (backdrop2 v)\n\nwait (5) seconds\n\n@Cubey\n\nwhen flag clicked\nforever\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        change [speedx v] by (2)\n    end\n    if <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n        change [speedx v] by (-2)\n    end\n    change x by (speedX)\n    if <<touching (sprite9 v)?> or <touching (platform v)?>> then\n        change x by ((speedX) * (-1))\n        set [speedx v] to [0]\n    else\n        set [speedx v] to ((speedX) * (0.8))\n    end\n    change y by (speedY)\n    if <<touching (platform v)?> or <touching (sprite9 v)?>> then\n        change y by ((speedY) * (-1))\n        set [speedy v] to [0]\n        if <(lock) = [0]> then\n            if <<key (up arrow v) pressed?> or <key (space v) pressed?>> then\n                set [speedy v] to [15]\n                set [lock v] to [1]\n            end\n        end\n    else\n        change [speedy v] by (-1)\n        set [lock v] to [0]\n    end\nend\n\nwhen flag clicked\nforever\n    play sound [bensound-clearday v] until done\n    play sound [bensound-thelounge v] until done\n    play sound [bensound-moose v] until done\n    play sound [bensound-clearday v] until done\n    play sound [alexander-nakarada-superepic v] until done\nend\n\nwhen flag clicked\nforever\n    if <touching color (#ff0000)?> then\n        switch costume to (costume2 v)\n        wait (.15) seconds\n        hide\n        set x to (-185)\n        set y to (-148)\n        switch costume to (costume1 v)\n        show\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (spikes v)?> then\n        switch costume to (costume2 v)\n        wait (.15) seconds\n        hide\n        set y to (-148)\n        set x to (-185)\n        switch costume to (costume1 v)\n        show\n    end\nend\n\nwhen flag clicked\nhide\nset x to (-185)\nset y to (-148)\nshow\n\nwhen flag clicked\nset [level v] to [1]\n\nwhen I receive [newlevel v]\ngo to x: (-185) y: (-148)\n\nwhen flag clicked\nforever\n    if <touching (trampoline v)?> then\n        change [speedy v] by (pick random (18) to (20))\n    end\nend\n\nwhen flag clicked\nset [speedy v] to [0]\n\nwhen flag clicked\nforever\n    if <touching (smashing thingies v)?> then\n        switch costume to (costume2 v)\n        wait (.15) seconds\n        hide\n        switch costume to (costume1 v)\n        set x to (-185)\n        set y to (-148)\n        switch costume to (costume1 v)\n        show\n    end\nend\n\nwhen [r v] key pressed\nhide\nset x to (-185)\nset y to (-148)\nshow\n\nwhen flag clicked\nforever\n    if <touching (sprite1 v)?> then\n        switch costume to (costume2 v)\n        wait (.15) seconds\n        hide\n        switch costume to (costume1 v)\n        go to x: (-185) y: (-148)\n        switch costume to (costume1 v)\n        show\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (sprite2 v)?> then\n        change [speedy v] by (10)\n    end\nend\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nwhen flag clicked\nforever\n    switch costume to (costume1 v)\n    wait (4) seconds\n    switch costume to (costume6 v)\n    wait (.15) seconds\n    switch costume to (costume7 v)\nend\n\nwhen flag clicked\nforever\n    if <key (down arrow v) pressed?> then\n        switch costume to (costume3 v)\n        wait (3) seconds\n        switch costume to (costume1 v)\n    end\nend\n\nwhen flag clicked\nset [time v] to [0]\nforever\n    wait (.01) seconds\n    change [time v] by (.1)\n    if <(Level) = [Finish!!!]> then\n        stop [all v]\n    end\nend\n\nplay sound [alexander-nakarada-superepic v] until done\n\nwhen flag clicked\nforever\n    if <(Time) < (WR:)> then\n        set [wr: v] to (Time)\n    end\nend\n\nwhen flag clicked\nforever\n    wait (.07) seconds\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nset [ghost v] effect to (50)\nrepeat (5)\n    wait (.02) seconds\n    change size by (-3)\nend\nrepeat (4)\n    wait (0) seconds\n    change [ghost v] effect by (25)\nend\ndelete this clone\n\nwhen I start as a clone\nforever\n    go to x: ((x position) - (3)) y: (y position)\nend\n\n@Platform\n\nwhen flag clicked\nswitch costume to (level 1 v)\n\nwhen I receive [newlevel v]\nforever\n    if <(Level) = [2]> then\n        switch costume to (level 2 v)\n    end\n    if <(Level) = [3]> then\n        switch costume to (level 3 v)\n    end\n    if <(Level) = [4]> then\n        switch costume to (level 4 v)\n    end\n    if <(Level) = [5]> then\n        switch costume to (level 5 v)\n    end\n    if <(Level) = [6]> then\n        switch costume to (level 6 v)\n    end\n    if <(Level) = [7]> then\n        switch costume to (level 7 v)\n    end\n    if <(Level) > [7]> then\n        switch costume to (finish!!! v)\n        wait (5) seconds\n        switch costume to (level 1 v)\n        set [level v] to [1]\n    end\nend\n\nif <(Level) = [8]> then\n    switch costume to (level 8 v)\nend\n\nwhen flag clicked\n\nwhen flag clicked\n\nforever\n    if <[7] < (Level)> then\nend\n\nreset timer\n\n@spikes\n\nwhen flag clicked\nforever\n    if <(Level) = [1]> then\n        switch costume to (costume2 v)\n        show\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [2]> then\n        switch costume to (costume1 v)\n        show\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) > [6]> then\n        hide\n    end\nend\n\nwhen flag clicked\nreset timer\n\n@Sprite9\n\n@Level increaser\n\nwhen flag clicked\nforever\n    if <touching (cubey v)?> then\n        change [level v] by (1)\n        broadcast (newlevel v)\n    end\nend\n\n@trampoline\n\nwhen flag clicked\nswitch costume to (costume1 v)\nforever\n    if <touching (cubey v)?> then\n        repeat (6)\n            next costume\n        end\n    end\n    switch costume to (costume1 v)\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [6]> then\n        show\n    end\nend\n\nwhen flag clicked\nforever\n    if <<(Level) < [6]> or <(Level) > [6]>> then\n        hide\n    end\nend\n\n@lava\n\nwhen flag clicked\nforever\n    if <(Level) > [4]> then\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) < [4]> then\n        show\n    end\nend\n\n@smashing thingies\n\nwhen flag clicked\nforever\n    repeat (74)\n        change y by (5)\n    end\n    repeat (37)\n        change y by (-10)\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [7]> then\n        show\n    end\nend\n\nwhen flag clicked\nforever\n    if <<[7] < (Level)> or <(Level) < [7]>> then\n        hide\n    end\nend\n\n@Sprite2\n\nwhen flag clicked\nforever\n    if <<(Level) < [6]> or <(Level) > [6]>> then\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [6]> then\n        show\n    end\nend\n\n@Sprite1\n\nwhen flag clicked\nforever\n    if <<[7] < (Level)> or <(Level) < [7]>> then\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [7]> then\n        show\n    end\nend\n\n@Clouds\n\nwhen flag clicked\nforever\n    if <(Level) = [7]> then\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [8]> then\n        show\n    end\nend\n\nwhen flag clicked\nhide\n\n@lava2\n\nwhen flag clicked\nforever\n    if <(Level) > [4]> then\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) < [4]> then\n        show\n    end\nend\n\nwhen flag clicked\nforever\n    switch costume to (costume1 v)\n    set y to (63)\n    repeat (3)\n        change y by (3)\n        wait (.25) seconds\n    end\n    switch costume to (costume2 v)\n    wait (.5) seconds\n    set y to (63)\nend\n\nwhen flag clicked\nset y to (0)\n\n@Sprite5\n\nwhen flag clicked\nhide\n\nshow\n\n@LvL and Time\n\n