Chocolate! - Platformer

Instructions: This is my first platformer!\n\nIf there any glitches click the green flag again.\n\nUse the arrows to move the chocolate bar but the dark spikes are dark chocolate and nobody likes dark chocolate so be careful and there are some tools to help you but you have to figure out which ones. :D\n

@Stage\n\nwhen stage clicked\nswitch backdrop to (chocolate v)\n\n@Chocolate\n\nwhen backdrop switches to [chhhhh v]\nhide\n\nwhen flag clicked\nswitch backdrop to (chhhhh v)\n\nwhen backdrop switches to [chocolate v]\nshow\n\nwhen flag clicked\nforever\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nswitch costume to (costume2 v)\nrepeat (7)\n    change size by (-4)\n    change [ghost v] effect by (15)\nend\ndelete this clone\n\nwhen flag clicked\nforever\n    if <(backdrop [number v]) = [2]> then\n        go to x: (-205) y: (-44)\n        switch backdrop to (chocolate v)\n        show\n        set [level v] to [1]\n        set [x velocity v] to [0]\n        set [y velocity v] to [0]\n        wait (1) seconds\n        forever\n            if <key (right arrow v) pressed?> then\n                change [x velocity v] by (1)\n            end\n            if <key (left arrow v) pressed?> then\n                change [x velocity v] by (-1)\n            end\n            set [x velocity v] to ((X velocity) * (.9))\n            change x by (X velocity)\n            if <touching (sprite1 v)?> then\n                change y by (1)\n                if <touching (sprite1 v)?> then\n                    change y by (1)\n                    if <touching (sprite1 v)?> then\n                        change y by (1)\n                        if <touching (sprite1 v)?> then\n                            change y by (1)\n                            if <touching (sprite1 v)?> then\n                                change y by (1)\n                                if <touching (sprite1 v)?> then\n                                    change x by ((X velocity) * (-1))\n                                    change y by (-5)\n                                    if <key (up arrow v) pressed?> then\n                                        if <(X velocity) > [0]> then\n                                            change [x velocity v] by (-5)\n                                        else\n                                            change [x velocity v] by (5)\n                                        end\n                                        set [y velocity v] to [10]\n                                    else\n                                        set [x velocity v] to [0]\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n            change [y velocity v] by (-1)\n            change y by (Y velocity)\n            if <touching (sprite1 v)?> then\n                change y by ((Y velocity) * (-1))\n                set [y velocity v] to [0]\n            end\n            change y by (-1)\n            if <touching (sprite1 v)?> then\n                if <key (up arrow v) pressed?> then\n                    change [y velocity v] by (15)\n                end\n            end\n            change y by (1)\n            if <(x position) > [200]> then\n                change [level v] by (1)\n                set [x velocity v] to [0]\n                set [y velocity v] to [0]\n                go to x: (-199) y: (-36)\n            end\n            if <touching color (#4d3500)?> then\n                repeat (4)\n                    change [brightness v] effect by (25)\n                end\n                go to x: (-205) y: (-44)\n                set [y velocity v] to [0]\n                repeat (4)\n                    change [brightness v] effect by (-25)\n                end\n            end\n            if <touching color (#ff0000)?> then\n                change [y velocity v] by (22)\n            end\n        end\n    end\nend\n\nwhen flag clicked\nhide variable [level v]\n\nwhen [r v] key pressed\ngo to x: (-205) y: (-44)\nset [x velocity v] to [0]\nset [y velocity v] to [0]\n\nwhen flag clicked\nforever\n    if <<(Level) = [8]> and <touching color (#ff00e7)?>> then\n        change size by (-20)\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [9]> then\n        set size to (30) %\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [10]> then\n        switch costume to (costume1 v)\n    end\nend\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nwhen flag clicked\nforever\n    if <<(Level) = [9]> and <touching color (#ff00e7)?>> then\n        add [key 1] to [tools v]\n    end\nend\n\nwhen flag clicked\nforever\n    if <<(Level) = [10]> and <touching color (#ff00e7)?>> then\n        add [key 1] to [tools v]\n        broadcast (passage v)\n        stop [this script v]\n    end\nend\n\nwhen backdrop switches to [chocolate2 v]\nhide\n\nwhen flag clicked\nforever\n    if <<<(Level) = [10]> and <(x position) > [200]>> or <(Level) = [11]>> then\n        switch backdrop to (chocolate2 v)\n    end\nend\n\ndefine change level by 1\nchange [level v] by (1)\n\nwhen [space v] key pressed\nchange level by 1\n\n@Sprite1\n\nwhen backdrop switches to [chhhhh v]\nhide\n\nwhen backdrop switches to [chocolate v]\nshow\n\nwhen flag clicked\nforever\n    switch costume to (Level)\nend\n\nwhen I receive [passage v]\nforever\n    switch costume to (costume11 v)\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [10]> then\n        delete all of [tools v]\n        delete all of [tools v]\n        delete all of [tools v]\n        stop [this script v]\n    end\nend\n\nwhen backdrop switches to [chocolate2 v]\nhide\n\n@Sprite2\n\nwhen flag clicked\nforever\n    switch costume to (Level)\nend\n\nwhen backdrop switches to [chhhhh v]\nhide\n\nwhen backdrop switches to [chocolate v]\nshow\n\nwhen backdrop switches to [chocolate v]\ngo to x: (9) y: (-43)\n\nwhen flag clicked\nforever\n    if <(Level) = [8]> then\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [9]> then\n        show\n    end\nend\n\nwhen flag clicked\nforever\n    if <<(Level) = [9]> and <[tools v] contains [key 1]?>> then\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [10]> then\n        show\n        go to x: (-176) y: (98)\n    end\nend\n\nwhen flag clicked\nif <(Level) = [10]> then\n    delete all of [tools v]\nend\n\nwhen backdrop switches to [chocolate2 v]\nhide\n\n@Sprite3\n\nwhen flag clicked\nforever\n    if <(Level) = [3]> then\n        switch costume to (costume1 v)\n        show\n        go to x: (40) y: (42)\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [4]> then\n        hide\n    end\nend\n\nwhen backdrop switches to [chhhhh v]\nhide\n\nwhen flag clicked\nforever\n    if <(Level) = [5]> then\n        go to x: (40) y: (42)\n        switch costume to (costume2 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\nforever\n    if <(Level) = [7]> then\n        go to x: (40) y: (42)\n        switch costume to (costume3 v)\n        show\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [8]> then\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [11]> then\n        hide\n    end\nend\n\nwhen I receive [2 v]\nhide\n\nwhen backdrop switches to [chocolate2 v]\nhide\n\n@Sprite4\n\nwhen flag clicked\nhide\nforever\n    if <(Level) = [8]> then\n        switch costume to (costume1 v)\n        show\n        go to x: (-2) y: (18)\n    end\nend\n\nwhen flag clicked\nforever\n    if <(backdrop [number v]) = [1]> then\n        repeat until <(Level) = [8]>\n            hide\n        end\n    end\nend\n\nwhen backdrop switches to [chhhhh v]\nset [level v] to [0]\nhide\n\nwhen flag clicked\nhide\nforever\n    if <(Level) = [9]> then\n        switch costume to (costume2 v)\n        show\n        repeat until <not <(Level) = [9]>>\n            glide (1) secs to x: (-34) y: (80)\n            glide (1) secs to x: (127) y: (80)\n        end\n    end\nend\n\nwhen flag clicked\ndelete all of [tools v]\n\nwhen flag clicked\nhide\nforever\n    if <(Level) = [10]> then\n        switch costume to (costume1 v)\n        delete all of [tools v]\n        stop [this script v]\n    end\nend\n\nwhen flag clicked\nhide\nforever\n    if <(Level) = [10]> then\n        switch costume to (costume1 v)\n        delete all of [tools v]\n        stop [this script v]\n    end\nend\n\nwhen flag clicked\nhide\nforever\n    if <(Level) = [10]> then\n        switch costume to (costume2 v)\n        go to x: (-32) y: (59)\n        show\n    end\nend\n\nwhen backdrop switches to [chocolate2 v]\nhide\n\n@Sprite5\n\nwhen flag clicked\nhide\n\nwhen flag clicked\ngo to x: (31) y: (-36)\nforever\n    if <(Level) = [8]> then\n        show\n        repeat until <not <(Level) = [8]>>\n            glide (0.5) secs to x: (31) y: (-36)\n            glide (1) secs to x: (31) y: (-93)\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [9]> then\n        hide\n    end\nend\n\nwhen backdrop switches to [chhhhh v]\nhide\n\nwhen backdrop switches to [chocolate2 v]\nhide\n\n