The Enexpected - A Platformer

Instructions: You can't click stop button lol !\nI bet you can't click the follow, love and share button in less than 5 secs ( I can do that ! ) !\nTry beating @zhuang5316 's highscore - 9 secs\nPlease don’t put hate comments and stuff like that\nEveryone pls follow, love, fav and share\nmight be a bit messy\nThe title is a mix of expected and unexpected\n-------------------------------Controls------------------------------\nArrow Keys or WASD to move\nDo not touch spikes\nThe red thingy makes u fast\nThe cyan thingy makes u slow\nThe cyan flag is where u spawn\nThe green flag is from where u go to next level\nThe trampoline makes u bounce.\nI tried making better arts\n------------------------------Controls----------------------( Real )\nDont touch spikes or the text or the music thing\nTouch the button for next level\nArrow keys to move

@Stage\n\n@Sprite10\n\nwhen flag clicked\nswitch backdrop to (backdrop1 v)\nclear graphic effects\nhide\nforever\n    go to (mouse-pointer v)\n    create clone of (_myself_ v)\n    change [color v] effect by (25)\n    go to [front v] layer\nend\n\nwhen I start as a clone\nhide\nshow\nset [ghost v] effect to (0)\nset size to (100) %\nrepeat (10)\n    change [ghost v] effect by (10)\n    change size by (-10)\nend\ndelete this clone\n\nwhen flag clicked\nforever\n    set [timer 2 v] to ((timer) + (.1))\nend\n\nwhen [timer v] > (timer 2)\nhide\nbroadcast (stop v)\n\n@Sprite8\n\nwhen I receive [save v]\nSave\ndelete all of [how to export v]\nhide list [how to export v]\nadd [Triple-click on the code to select the whole code. Press Ctrl+C to copy the code.] to [how to export v]\nadd (SAVE) to [how to export v]\nadd [] to [how to export v]\nadd [You can share your code with others here:] to [how to export v]\nadd [https://scratch.mit.edu/discuss/topic/478905/] to [how to export v]\nadd [] to [how to export v]\nadd [Please don't post your code in the comments, many codes are too long!] to [how to export v]\nadd [] to [how to export v]\n\nwhen flag clicked\nhide\n\n@Sprite7\n\ndefine Invalid code\nif <(timer) < [0.5]> then\n    Setup\n    broadcast (Invalid code! v)\nelse\n    Load (join [0] (item (history#) of [previous v]))\n    broadcast (Invalid code! v)\nend\n\nwhen flag clicked\nhide\n\n@Sprite6\n\nwhen I receive [save v]\nSave\ndelete all of [how to export v]\nhide list [how to export v]\nadd [Triple-click on the code to select the whole code. Press Ctrl+C to copy the code.] to [how to export v]\nadd (SAVE) to [how to export v]\nadd [] to [how to export v]\nadd [You can share your code with others here:] to [how to export v]\nadd [https://scratch.mit.edu/discuss/topic/478905/] to [how to export v]\nadd [] to [how to export v]\nadd [Please don't post your code in the comments, many codes are too long!] to [how to export v]\nadd [] to [how to export v]\n\nwhen flag clicked\nhide\n\n@Sprite5\n\ndefine Invalid code\nif <(timer) < [0.5]> then\n    Setup\n    broadcast (Invalid code! v)\nelse\n    Load (join [0] (item (history#) of [previous v]))\n    broadcast (Invalid code! v)\nend\n\nwhen flag clicked\nhide\n\n@Sprite4\n\nwhen I receive [save v]\nSave\ndelete all of [how to export v]\nhide list [how to export v]\nadd [Triple-click on the code to select the whole code. Press Ctrl+C to copy the code.] to [how to export v]\nadd (SAVE) to [how to export v]\nadd [] to [how to export v]\nadd [You can share your code with others here:] to [how to export v]\nadd [https://scratch.mit.edu/discuss/topic/478905/] to [how to export v]\nadd [] to [how to export v]\nadd [Please don't post your code in the comments, many codes are too long!] to [how to export v]\nadd [] to [how to export v]\n\nwhen flag clicked\nhide\n\n@Player\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nforever\n    set [die v] to []\n    Reset\n    repeat until <not <(Die) = []>>\n        broadcast (Collision v)\n        tick\n    end\n    Die\nend\n\ndefine Die\nset [ghost v] effect to (0)\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nwait (0.3) seconds\nset [die v] to []\n\nwhen flag clicked\nset [game mode v] to [Make]\nGreen Flag: Reset\nbroadcast (Reset v)\nset [current cos v] to [1]\n\ndefine tick\nshow\ngo to x: (0) y: (0)\nswitch costume to (hitbox v)\nset size to ((Tile Size) * (2)) %\ngo to [front v] layer\ngo [backward v] (36) layers\nif <(Game Mode) = [Play]> then\n    Play\nelse\n    Make [7]\nend\n\ndefine yv (yv)\nchange [jump v] by (2)\nif <not <[collision v] contains [6]?>> then\n    if <not <[collision v] contains [10]?>> then\n        change [player_y v] by (yv)\n    else\n        set [jump v] to [0]\n        set [xv v] to ((xv) * (0.97))\n        if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<key (down arrow v) pressed?> or <key (s v) pressed?>>> then\n            change [player_y v] by ((yv) / (3))\n        else\n            change [player_y v] by ((yv) / (4))\n        end\n    end\nelse\n    set [jump v] to [0]\n    set [xv v] to ((xv) * (0.95))\n    if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n        change [player_y v] by ((yv) / (2))\n    end\n    if <<key (down arrow v) pressed?> or <key (s v) pressed?>> then\n        change [player_y v] by ((yv) / (2))\n    end\nend\nPosition\nrepeat until <not <[collision v] contains [1]?>>\n    if <(yv) > [0]> then\n        change [player_y v] by (-1)\n    else\n        change [player_y v] by (1)\n        set [my variable v] to [0]\n        set [jump v] to [0]\n    end\n    set [my variable v] to [0]\n    Position\nend\n\ndefine xv (xv)\nforever\n    change [player_x v] by (xv)\n    Position\n    if <[collision v] contains [1]?> then\n        repeat until <not <[collision v] contains [1]?>>\n            if <(xv) > [0]> then\n                change [player_x v] by (-1)\n            else\n                change [player_x v] by (1)\n            end\n            Position\n        end\n        if <(walljump) = [1]> then\n            if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                if <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<key (right arrow v) pressed?> or <key (d v) pressed?>>> then\n                    if <(xv) > [0]> then\n                        set [xv v] to (((-7) / (30)) * (Tile Size))\n                    else\n                        set [xv v] to (((7) / (30)) * (Tile Size))\n                    end\n                    set [my variable v] to (((15) / (30)) * (Tile Size))\n                end\n            else\n                set [xv v] to [0]\n            end\n        end\n    end\n    Position\nend\n\nset [jump v] to [0]\n\nset [jump v] to [0]\n\ndefine Position\nset [player_y v] to (round (Player_Y))\nset [player_x v] to (round (Player_X))\nCollision\ngo to x: ((Player_X) - (Camera X)) y: ((Player_Y) - (Camera Y))\nif <not <((Player_Y) - (Camera Y)) = (y position)>> then\n    hide\nelse\n    show\nend\n\ndefine Reset\ngo to x: (0) y: (0)\nset [current cos v] to [1]\nif <(Game Mode) = [Make]> then\n    set [win v] to [0]\nend\nset [player_x v] to ((CheckX) * (Tile Size))\nset [player_y v] to ((CheckY) * (Tile Size))\nset [camera x v] to (Player_X)\nset [camera y v] to (Player_Y)\nset [xv v] to [0]\nset [my variable v] to [0]\nset [die v] to []\nset [ghost v] effect to (0)\n\ndefine Collision\ndelete all of [collision v]\nset [collision # v] to [1]\nrepeat (length of [x v])\n    add [0] to [collision v]\n    if <(item (Collision #) of [cos v]) = [3]> then\n        if <<((item (Collision #) of [y v]) * (Tile Size)) < ((Player_Y) + (((Tile Size) / (4)) * (3)))> and <((item (Collision #) of [y v]) * (Tile Size)) > ((Player_Y) - (((Tile Size) / (4)) * (3)))>> then\n            if <<((item (Collision #) of [x v]) * (Tile Size)) < ((Player_X) + (((Tile Size) / (4)) * (3)))> and <((item (Collision #) of [x v]) * (Tile Size)) > ((Player_X) - (((Tile Size) / (4)) * (3)))>> then\n                replace item (Collision #) of [collision v] with (item (Collision #) of [cos v])\n            end\n        end\n    else\n        if <(item (Collision #) of [cos v]) = [15]> then\n            if <<((item (Collision #) of [y v]) * (Tile Size)) < ((Player_Y) + (Tile Size))> and <([abs v] of ((item (Collision #) of [y v]) * (Tile Size)) ) > ((Player_Y) - (Tile Size))>> then\n                if <<((item (Collision #) of [x v]) * (Tile Size)) < ((Player_X) + (Tile Size))> and <((item (Collision #) of [x v]) * (Tile Size)) > ((Player_X) - (Tile Size))>> then\n                    if <(item (Collision #) of [coins v]) = [0]> then\n                        replace item (Collision #) of [collision v] with (item (Collision #) of [cos v])\n                    end\n                end\n            end\n        else\n            if <<((item (Collision #) of [y v]) * (Tile Size)) < ((Player_Y) + (((Tile Size) / (35)) * (34)))> and <((item (Collision #) of [y v]) * (Tile Size)) > ((Player_Y) - (((Tile Size) / (35)) * (35)))>> then\n                if <<((item (Collision #) of [x v]) * (Tile Size)) < ((Player_X) + (((Tile Size) / (25)) * (23)))> and <((item (Collision #) of [x v]) * (Tile Size)) > ((Player_X) - (((Tile Size) / (25)) * (23)))>> then\n                    replace item (Collision #) of [collision v] with (item (Collision #) of [cos v])\n                end\n            end\n        end\n    end\n    change [collision # v] by (1)\nend\n\ndefine Play\nset [player_y v] to (round (Player_Y))\nif <(Win) = [0]> then\n    if <[10] > ([abs v] of (xv) )> then\n        if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n            set [cos v] to [1]\n            change [xv v] by (((2) / (30)) * (Tile Size))\n        else\n            if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n                set [cos v] to [2]\n                change [xv v] by (((-2) / (30)) * (Tile Size))\n            else\n                set [cos v] to [3]\n            end\n        end\n    end\n    if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n        Position\n        if <(jump) < [5]> then\n            change [jump v] by (3)\n            set [my variable v] to (((21) / (30)) * (Tile Size))\n        end\n    end\nend\nset [my variable v] to ((my variable) * (0.99))\nset [xv v] to ((xv) * (0.8))\nif <(my variable) > [-13]> then\n    change [my variable v] by ((((2) / (30)) * (Tile Size)) * (-1))\nend\nyv (my variable)\nif <([abs v] of (xv) ) > [0]> then\n    xv (xv)\nend\nif <(Player_Y) < [-400]> then\n    hide\nend\nif <<<[collision v] contains [3]?> or <[collision v] contains [12]?>> or <(Player_Y) < [-500]>> then\n    set [die v] to [Die]\nend\nif <<[collision v] contains [4]?> or <[collision v] contains [5]?>> then\n    set [my variable v] to (((25) / (30)) * (Tile Size))\nend\nchange [camera x v] by (round (((Player_X) - (Camera X)) / (((8) * (30)) / (Tile Size))))\nif <(Player_Y) > [-200]> then\n    change [camera y v] by (round (((Player_Y) - (Camera Y)) / (((8) * (30)) / (Tile Size))))\nend\nPosition\nswitch costume to (Cos)\nCollision\n\ndefine Make (speed)\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    change [xv v] by (speed)\nelse\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        change [xv v] by ((speed) * (-1))\n    end\nend\nif <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n    set [my variable v] to ((speed) + (3))\nelse\n    if <<<key (down arrow v) pressed?> or <key (s v) pressed?>> and <(Player_Y) > [-50]>> then\n        set [my variable v] to (((speed) + (3)) * (-1))\n    end\nend\nset [my variable v] to ((my variable) * (0.6))\nset [xv v] to ((xv) * (0.5))\nchange [player_x v] by (xv)\nchange [player_y v] by (my variable)\nset [camera x v] to (Player_X)\nset [camera y v] to (Player_Y)\nswitch costume to (3 v)\ngo to x: ((0) - (Camera X)) y: ((Tile Size) - (Camera Y))\n\nwhen I receive [play game v]\nGreen Flag: Reset\nReset\n\nwhen I receive [start v]\nforever\n    go to [front v] layer\n    go [backward v] (50) layers\n    broadcast (Game Loop v)\nend\n\ndefine Green Flag: Reset\nset [checkx v] to [0]\nset [checky v] to [0]\nset [has won? v] to [0]\n\nset [win v] to [0]\nset [has won? v] to [0]\n\nwhen I receive [play game v]\n\ndefine Invalid code\nif <(timer) < [0.5]> then\n    Setup\n    broadcast (Invalid code! v)\nelse\n    Load (join [0] (item (history#) of [previous v]))\n    broadcast (Invalid code! v)\nend\n\n@Sprite3\n\nwhen I receive [save v]\nSave\ndelete all of [how to export v]\nhide list [how to export v]\nadd [Triple-click on the code to select the whole code. Press Ctrl+C to copy the code.] to [how to export v]\nadd (SAVE) to [how to export v]\nadd [] to [how to export v]\nadd [You can share your code with others here:] to [how to export v]\nadd [https://scratch.mit.edu/discuss/topic/478905/] to [how to export v]\nadd [] to [how to export v]\nadd [Please don't post your code in the comments, many codes are too long!] to [how to export v]\nadd [] to [how to export v]\n\nwhen flag clicked\nhide\n\n@Sprite2\n\ndefine Invalid code\nif <(timer) < [0.5]> then\n    Setup\n    broadcast (Invalid code! v)\nelse\n    Load (join [0] (item (history#) of [previous v]))\n    broadcast (Invalid code! v)\nend\n\nwhen flag clicked\nhide\n\n@Sprite1\n\nwhen I receive [save v]\nSave\ndelete all of [how to export v]\nhide list [how to export v]\nadd [Triple-click on the code to select the whole code. Press Ctrl+C to copy the code.] to [how to export v]\nadd (SAVE) to [how to export v]\nadd [] to [how to export v]\nadd [You can share your code with others here:] to [how to export v]\nadd [https://scratch.mit.edu/discuss/topic/478905/] to [how to export v]\nadd [] to [how to export v]\nadd [Please don't post your code in the comments, many codes are too long!] to [how to export v]\nadd [] to [how to export v]\n\nwhen I receive [stop v]\nhide\n\nwhen flag clicked\nshow\n\n@Sprite9\n\nwhen flag clicked\nhide\n\nwhen I receive [stop v]\nswitch backdrop to (backdrop2 v)\n\n@not touch\n\nwhen flag clicked\nswitch costume to (costume5 v)\nset [l v] to [1]\ngo to x: (0) y: (0)\nhide\nif <(item (l) of [levels v]) = [1]> then\n    next costume\n    show\nend\n\nwhen I receive [next v]\nchange [l v] by (1)\nhide\nif <(item (l) of [levels v]) = [1]> then\n    next costume\n    show\nend\n\n@you won\n\nwhen flag clicked\nhide\n\nwhen I receive [you won v]\nwait (0.5) seconds\nshow\ngo to [front v] layer\nset size to (0) %\npoint in direction (0)\ngo to x: (0) y: (-1000)\nrepeat (30)\n    change size by (((100) - (size)) / (5))\n    turn right (((90) - (direction)) / (5)) degrees\n    change y by (((0) - (y position)) / (5))\nend\n\n@white out\n\nwhen I receive [slide v]\nshow\ngo to [front v] layer\ngo to x: (0) y: (-1000)\nrepeat (40)\n    change y by (((0) - (y position)) / (5))\nend\nbroadcast (next v)\nset y to (1)\nrepeat (8)\n    change y by (y position)\nend\nhide\n\nwhen flag clicked\nhide\n\nwhen I receive [you won v]\ngo to x: (0) y: (0)\nstop [other scripts in sprite v]\n\n@Sprite11\n\nwhen flag clicked\nhide\n\nwhen I receive [layers v]\ngo [backward v] (100) layers\n\nwhen I receive [stop v]\nshow\ngo to x: (206) y: (-48)\nforever\n    if <touching (player v)?> then\n        start sound [pop v]\n        switch costume to (2 v)\n        set [edge v] to [0]\n        wait (0.5) seconds\n        broadcast (slide v)\n        wait (1.5) seconds\n        set [edge v] to [1]\n    else\n        switch costume to (1 v)\n    end\nend\n\n@TN\n\nwhen flag clicked\nhide\n\nwhen I receive [stop v]\ngo to x: (0) y: (0)\nbroadcast (layers v) and wait\nshow\ngo to [front v] layer\nwait (1) seconds\nchange x by (1)\nrepeat (9)\n    change x by (x position)\nend\nhide\n\n@BG\n\nwhen flag clicked\nhide\nforever\n    wait (0.5) seconds\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nshow\ngo to x: (pick random (-240) to (240)) y: (177)\nset [v v] to [0]\nrepeat until <<touching (level v)?> or <touching (_edge_ v)?>>\n    change [v v] by (pick random (-0.1) to (0.1))\n    change x by (v)\n    change y by (-1)\nend\nif <touching (level v)?> then\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\nend\ndelete this clone\n\nwhen I receive [layers v]\ngo to [front v] layer\n\n@level\n\nwhen I receive [next v]\nnext costume\nif <(costume [number v]) = [1]> then\n    broadcast (you won v)\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [stop v]\nshow\ngo to x: (0) y: (0)\nswitch costume to (costume1 v)\n\n@eyes\n\nwhen flag clicked\nhide\n\nwhen I receive [message1 v]\ngo to (player v)\n\nwhen I receive [stop v]\nshow\ngo to [front v] layer\nswitch costume to (1 v)\nset size to (80) %\nforever\n    wait (5) seconds\n    repeat (3)\n        next costume\n    end\n    repeat (3)\n        switch costume to ((costume [number v]) - (1))\n    end\nend\n\nwhen flag clicked\nforever\n    go to [front v] layer\nend\n\n@player\n\nwhen flag clicked\nhide variable [highscore v]\nhide variable [time you took - v]\nhide variable [timer v]\n\ndefine walls\nif <not <(t) = [s]>> then\n    if <<(t) < [4]> and <touching (level v)?>> then\n        change [t v] by (1)\n        change y by (1)\n        walls\n    else\n        if <(t) = [4]> then\n            change y by (-4)\n            change x by ((-1) * (x_vel))\n            set [x_vel v] to [0]\n        end\n        set [t v] to [s]\n    end\nend\n\nwhen flag clicked\n\nwhen I receive [you won v]\nset [time you took - v] to (join (Timer) [ secs])\nshow variable [time you took - v]\nshow variable [highscore v]\nwait (3) seconds\nstop [other scripts in sprite v]\n\nwhen I receive [next v]\ngo to x: (-210) y: (0)\nset [x_vel v] to [0]\nset [y_vel v] to [0]\nbroadcast (platform v)\n\nset [y_vel v] to [8]\n\nwhen I receive [platform v]\nforever\n    if <key (right arrow v) pressed?> then\n        change [x_vel v] by (1)\n    end\n    if <key (left arrow v) pressed?> then\n        change [x_vel v] by (-1)\n    end\n    set [x_vel v] to ((0.9) * (x_vel))\n    change x by (x_vel)\n    set [t v] to [0]\n    walls\n    if <not <(t) = [s]>> then\n        add (t) to [bugs v]\n    end\n    change [y_vel v] by (-0.8)\n    change y by (y_vel)\n    if <touching (level v)?> then\n        change y by ((-1) * (y_vel))\n        if <<key (up arrow v) pressed?> and <(y_vel) < [0]>> then\n            set [y_vel v] to [10]\n        else\n            set [y_vel v] to [0]\n        end\n    end\n    broadcast (message1 v)\n    check\nend\n\nwhen I receive [restart v]\nstop [other scripts in sprite v]\ngo to x: (-210) y: (0)\nset [x_vel v] to [0]\nset [y_vel v] to [0]\nbroadcast (platform v)\n\ndefine check\nif <<touching (not touch v)?> or <<touching (_edge_ v)?> and <(edge) = [1]>>> then\n    broadcast (restart v)\n    wait (0.1) seconds\nend\n\ncheck\n\nset size to (130) %\nset size to (100) %\n\nwhen I receive [stop v]\nset [timer v] to [0]\nset [time you took - v] to [0]\nshow\n\nwhen flag clicked\nhide\n\nwhen I receive [stop v]\nset [edge v] to [1]\ndelete (all) of [bugs v]\nbroadcast (platform v)\n\nwhen I receive [stop v]\ngo to x: (-210) y: (0)\nset [x_vel v] to [0]\nset [y_vel v] to [0]\n\nwhen I receive [stop v]\nforever\n    change [timer v] by (1)\n    wait (1) seconds\nend\n\nwhen I receive [you won v]\nif <(Time you took -) < (Highscore)> then\n    set [highscore v] to (Time you took -)\nend\n\n@Blank\n\n