Halloween Treats <a platformer>

Instructions: WASD or arrow keys to move. ( NOT mobile friendly.)\nMouse down to shoot.\nCollect all the treats\nBeat the boss.\nIf you have any problems, tell me in the comments. 

@Stage\n\nwhen I receive [next level v]\nif <(Level) = [8]> then\n    create clone of (half trans ghost v)\nend\n\n@player\n\nwhen flag clicked\nforever\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> and <<key (right arrow v) pressed?> or <key (d v) pressed?>>> then\n        switch costume to (right v)\n    else\n        if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> and <<key (left arrow v) pressed?> or <key (a v) pressed?>>> then\n            switch costume to (left v)\n        else\n            if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                switch costume to (up v)\n            else\n                if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n                    switch costume to (right v)\n                else\n                    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n                        switch costume to (left v)\n                    else\n                        switch costume to (middle v)\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nset [level v] to [1]\n\nhide\n\nwhen I start as a clone\nrepeat (7)\n    switch costume to (trail v)\n    change size by (-4)\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nwhen flag clicked\ngo to [front v] layer\ngo [backward v] (3) layers\nshow\nset size to (45) %\nswitch costume to (middle v)\ngo to x: (-190) y: (50)\nset drag mode [not draggable v]\npoint in direction (90)\nforever\n    set rotation style [left-right v]\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        change [x v] by (-1)\n    end\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        change [x v] by (1)\n    end\n    set [x v] to ((X) * (0.9))\n    change x by (X)\n    Check touching solid\n    if <(touching) > [0]> then\n        change y by (1)\n        Check touching solid\n        if <(touching) > [0]> then\n            change y by (1)\n            Check touching solid\n            if <(touching) > [0]> then\n                change y by (1)\n                Check touching solid\n                if <(touching) > [0]> then\n                    change y by (1)\n                    Check touching solid\n                    if <(touching) > [0]> then\n                        change y by (1)\n                        Check touching solid\n                        if <(touching) > [0]> then\n                            change x by ((X) * (-1))\n                            change y by (-5)\n                            if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                                if <(X) > [0]> then\n                                    set [x v] to [-7]\n                                else\n                                    set [x v] to [7]\n                                end\n                                set [y v] to [14]\n                            else\n                                set [x v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    change y by (-1)\n    Check touching solid\n    if <(touching) > [0]> then\n        if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n            set [y v] to [13]\n            point in direction ((Y) * (0.5))\n        end\n    end\n    change y by (1)\n    change [y v] by (-1)\n    change y by (Y)\n    Check touching solid\n    if <(touching) > [0]> then\n        change y by ((Y) * (-1))\n        set [y v] to [0]\n    end\n    hide variable [x v]\n    if <<(x position) > [230]> and <not <(Level) = [11]>>> then\n        broadcast (next level v)\n        change [level v] by (1)\n        set [y v] to [0]\n        set [x v] to [0]\n        go to x: (-190) y: (-80)\n    end\n    if <(y position) < [-170]> then\n        set [collect v] to [0]\n        broadcast (Death v)\n    end\n    if <<touching (spike v)?> or <touching (lava v)?>> then\n        set [collect v] to [0]\n        broadcast (Death v)\n    end\nend\n\nwhen flag clicked\nforever\n    set [x v] to (x position)\n    set [y v] to (y position)\nend\n\ngo to x: (-190) y: (-24)\ngo to x: (-201) y: (14)\n\ndefine Check touching solid\nif <<touching (ground v)?> or <touching (pumpkin v)?>> then\n    set [touching v] to [1]\nelse\n    set [touching v] to [0]\nend\n\nwhen I receive [death v]\nset [x v] to [0]\nset [y v] to [0]\ngo to x: (-190) y: (-50)\n\nwhen flag clicked\nforever\n    play sound [darren-curtis-i-am-not-what-i-thought v] until done\nend\n\n@ground\n\nwhen flag clicked\ngo to x: (0) y: (0)\nswitch costume to (level1 v)\n\nwhen I receive [next level v]\nnext costume\n\n@pumpkin\n\nwhen I receive [next level v]\nif <(Level) = [6]> then\n    hide\nend\n\nwhen flag clicked\nset [collect v] to [0]\nhide\n\nwait (0.5) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\nstop [this script v]\n\nwhen I receive [next level v]\nset [collect v] to [0]\n\nwhen I receive [next level v]\nif <<(Level) = [2]> or <(Level) = [5]>> then\n    Check L2,5\nend\nif <(Level) = [3]> then\n    Check L3\nend\nif <(Level) = [4]> then\n    Check L4\nend\n\nwhen I receive [death v]\nset [collect v] to [0]\nshow\nif <(Level) = [3]> then\n    Check L3\nend\nif <(Level) = [4]> then\n    Check L4\nend\nif <(Level) = [5]> then\n    Check L2,5\nend\nif <(Level) = [9]> then\n    hide\nend\n\ndefine Check L3\nshow\ngo to x: (213) y: (102)\nforever\n    if <(Collect) = [3]> then\n        repeat (10)\n            wait (0) seconds\n        end\n        if <not <(Collect) = [0]>> then\n            wait (0.5) seconds\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            clear graphic effects\n            stop [this script v]\n        end\n    end\nend\n\ndefine Check L4\nshow\ngo to x: (212) y: (149)\nforever\n    if <(Collect) = [4]> then\n        wait (0.5) seconds\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n        hide\n        clear graphic effects\n        stop [this script v]\n    end\nend\n\ndefine Check L2,5\nshow\nif <(Level) = [2]> then\n    go to x: (199) y: (-78)\nelse\n    go to x: (213) y: (139)\nend\nforever\n    if <(Collect) = [1]> then\n        repeat (10)\n            wait (0) seconds\n        end\n        if <not <(Collect) = [0]>> then\n            wait (0.5) seconds\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            clear graphic effects\n            stop [this script v]\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [8]> then\n    show\n    go to x: (213) y: (139)\n    forever\n        if <(Collect) = [2]> then\n            repeat (10)\n                wait (0) seconds\n            end\n            if <not <(Collect) = [0]>> then\n                wait (0.5) seconds\n                repeat (10)\n                    change [ghost v] effect by (10)\n                end\n                hide\n                clear graphic effects\n                stop [this script v]\n            end\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [10]> then\n    show\n    go to x: (92) y: (-80)\nend\n\n@candy\n\nwhen I receive [next level v]\nif <(Level) = [2]> then\n    show\n    go to x: (-23) y: (-6)\n    forever\n        if <touching (player v)?> then\n            change [collect v] by (1)\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            clear graphic effects\n        end\n    end\nend\n\ngo to x: (-23) y: (-6)\n\nwhen flag clicked\nhide\n\ndelete this clone\n\nwhen I receive [next level v]\nif <(Level) = [3]> then\n    show\n    go to x: (-77) y: (-27)\n    forever\n        if <touching (player v)?> then\n            change [collect v] by (1)\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            clear graphic effects\n        end\n    end\nend\n\nwhen I receive [death v]\nif <not <<(Level) = [7]> or <(Level) = [9]>>> then\n    repeat (5)\n        wait (0) seconds\n    end\n    show\nend\n\nwhen I receive [next level v]\nif <(Level) = [4]> then\n    show\n    go to x: (-96) y: (-58)\n    forever\n        if <touching (player v)?> then\n            change [collect v] by (1)\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            clear graphic effects\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [5]> then\n    show\n    go to x: (136) y: (51)\n    forever\n        if <touching (player v)?> then\n            change [collect v] by (1)\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            clear graphic effects\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [8]> then\n    show\n    go to [back v] layer\n    go to x: (6) y: (-100)\n    forever\n        if <touching (player v)?> then\n            change [collect v] by (1)\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            clear graphic effects\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [10]> then\n    hide\nend\n\n@candy3\n\nwhen I receive [next level v]\nif <(Level) = [3]> then\n    show\n    go to x: (123) y: (-20)\n    forever\n        if <touching (player v)?> then\n            change [collect v] by (1)\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            clear graphic effects\n        end\n    end\nend\n\ngo to x: (-23) y: (-6)\n\ngo to x: (-23) y: (-6)\nshow\n\nwhen flag clicked\nhide\n\nwhen I receive [death v]\nclear graphic effects\nif <<(Level) = [3]> or <(Level) = [4]>> then\n    wait (0) seconds\n    wait (0) seconds\n    wait (0) seconds\n    wait (0) seconds\n    wait (0) seconds\n    wait (0) seconds\n    wait (0) seconds\n    wait (0) seconds\n    show\n    show\nend\n\nshow\nshow\n\nwhen I receive [next level v]\nif <(Level) = [4]> then\n    show\n    go to x: (178) y: (-94)\n    forever\n        if <touching (player v)?> then\n            change [collect v] by (1)\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            clear graphic effects\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [10]> then\n    hide\nend\n\n@candy4\n\ngo to x: (-23) y: (-6)\n\ngo to x: (-23) y: (-6)\nshow\n\nwhen flag clicked\nhide\n\nwhen I receive [death v]\nif <(Level) = [4]> then\n    clear graphic effects\n    wait (0) seconds\n    wait (0) seconds\n    wait (0) seconds\n    wait (0) seconds\n    show\nend\n\nshow\nshow\n\nwhen I receive [next level v]\nif <(Level) = [4]> then\n    show\n    go to x: (85) y: (38)\n    forever\n        if <touching (player v)?> then\n            change [collect v] by (1)\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            clear graphic effects\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [10]> then\n    hide\nend\n\n@Health\n\nwhen I receive [next level v]\nif <(Level) = [9]> then\n    show variable [health v]\n    set [health v] to [100]\nend\n\nwhen flag clicked\nhide variable [health v]\nhide\n\nwhen I receive [death v]\nif <(Level) = [9]> then\n    show variable [health v]\n    set [health v] to [100]\nend\n\n@Spike\n\nwhen I receive [next level v]\nif <(Level) = [3]> then\n    switch costume to (costume1 v)\n    show\nelse\n    if <(Level) = [7]> then\n        switch costume to (costume2 v)\n        show\n    else\n        hide\n    end\nend\n\nhide\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\n\n@Lava\n\ngo to [back v] layer\n\nwhen I receive [next level v]\nif <(Level) = [4]> then\n    switch costume to (costume1 v)\n    go to x: (0) y: (0)\n    forever\n        repeat (20)\n            change y by (0.5)\n        end\n        repeat (20)\n            change y by (-0.5)\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [8]> then\n    switch costume to (costume2 v)\n    go to x: (0) y: (0)\n    forever\n        repeat (20)\n            change y by (0.5)\n        end\n        repeat (20)\n            change y by (-0.5)\n        end\n    end\nend\n\n@Ghost\n\nwhen I receive [next level v]\nif <(Level) = [5]> then\n    show\n    go to x: (110) y: (16)\n    forever\n        point in direction (-90)\n        glide (1) secs to x: (-40) y: (16)\n        wait (0.5) seconds\n        point in direction (90)\n        glide (1) secs to x: (110) y: (16)\n        wait (0.5) seconds\n    end\nend\n\nwhen flag clicked\nhide\nforever\n    if <touching (player v)?> then\n        broadcast (Death v)\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [6]> then\n    hide\nend\n\nwhen I receive [next level v]\nif <(Level) = [7]> then\n    show\n    go to x: (-47) y: (-7)\n    forever\n        point in direction (90)\n        glide (1) secs to x: (133) y: (-7)\n        wait (0.5) seconds\n        point in direction (-90)\n        glide (1) secs to x: (-47) y: (-7)\n        wait (0.5) seconds\n    end\nend\n\nwhen I receive [next level v]\nforever\n    if <touching (laser v)?> then\n        repeat (5)\n            change [ghost v] effect by (20)\n        end\n        hide\n        clear graphic effects\n    end\nend\n\nwhen I start as a clone\nshow\ngo to x: (pick random (100) to (180)) y: (pick random (70) to (-40))\nforever\n    glide (2) secs to (player v)\nend\n\nwhen I start as a clone\nforever\n    if <touching (laser v)?> then\n        hide\n        delete this clone\n    end\nend\n\nwhen I start as a clone\nforever\n    if <touching (player v)?> then\n        broadcast (Death v)\n        delete this clone\n    end\nend\n\n@wand\n\nwhen flag clicked\nhide\nset [wand v] to [0]\ngo to [back v] layer\nforever\n    if <(Wand) = [1]> then\n        forever\n            show\n            go to (player v)\n            point towards (mouse-pointer v)\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [6]> then\n    show\n    go to x: (0) y: (-61)\n    forever\n        if <touching (player v)?> then\n            set [wand v] to [1]\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Shoot rate) > [0]> then\n        change [shoot rate v] by (-1)\n    else\n        if <<mouse down?> and <(Wand) = [1]>> then\n            create clone of (laser v)\n            if <(Level) = [9]> then\n                set [shoot rate v] to [5]\n            else\n                set [shoot rate v] to [40]\n            end\n        end\n    end\nend\n\nif  then\nend\n\nwhen flag clicked\nforever\n    go to [back v] layer\nend\n\n@Laser\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nshow\ngo to (wand v)\npoint in direction ([direction v] of [wand v])\nrepeat until <<<touching (_edge_ v)?> or <<touching (ground v)?> or <touching (ghost v)?>>> or <touching (ghost king v)?>>\n    move (30) steps\nend\ndelete this clone\n\nwhen flag clicked\nforever\n    if <[] = [0]> then\n        wait (4) seconds\n    end\nend\n\nif <[] = [1]> then\nend\n\n@Sprite1\n\nwhen flag clicked\ngo to x: (0) y: (0)\nswitch costume to (costume1 v)\ngo to [front v] layer\n\nwhen I receive [next level v]\nnext costume\n\nforever\nend\n\n@Sprite2\n\nwhen flag clicked\nhide\n\nshow\nshow\ngo to [front v] layer\n\n@Ghost King\n\nwhen flag clicked\nhide\nforever\n    if <touching (player v)?> then\n        broadcast (Death v)\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [9]> then\n    show\n    go to x: (133) y: (16)\n    forever\n        wait (1) seconds\n        repeat (8)\n            create clone of (ghost v)\n        end\n    end\nend\n\nwhen I receive [next level v]\nforever\n    if <touching (laser v)?> then\n        change [health v] by (-1)\n        if <(HEALTH) < [1]> then\n            repeat (5)\n                change [ghost v] effect by (20)\n            end\n            hide\n            stop [other scripts in sprite v]\n            hide variable [health v]\n            clear graphic effects\n        end\n    end\nend\n\n@Half trans Ghost\n\nwhen I receive [next level v]\nif <(Level) = [8]> then\n    show\n    go to x: (110) y: (-95)\n    forever\n        point in direction (-90)\n        glide (1) secs to x: (0) y: (-95)\n        wait (0.5) seconds\n        point in direction (90)\n        glide (1) secs to x: (110) y: (-95)\n        wait (0.5) seconds\n    end\nend\n\nwhen flag clicked\nset [ghost v] effect to (50)\nhide\nforever\n    if <touching (player v)?> then\n        broadcast (Death v)\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [9]> then\n    hide\n    delete this clone\nend\n\nif <touching (laser v)?> then\n    repeat (5)\n        change [ghost v] effect by (20)\n    end\n    hide\n    clear graphic effects\nend\n\nwhen I receive [next level v]\nif <(Level) = [6]> then\n    hide\nend\n\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\ngo to x: (-5) y: (53)\nrepeat until <(Level) = [9]>\n    point in direction (-90)\n    glide (1) secs to x: (-220) y: (53)\n    wait (0.5) seconds\n    point in direction (90)\n    glide (1) secs to x: (-5) y: (53)\n    wait (0.5) seconds\nend\ndelete this clone\n\nwhen I start as a clone\nforever\n    if <touching (player v)?> then\n        broadcast (Death v)\n    end\nend\n\n@Hat\n\nwhen flag clicked\nforever\n    go to x: ([x position v] of [player v]) y: ([y position v] of [player v])\nend\n\n@candy2\n\nwhen I receive [next level v]\nif <(Level) = [3]> then\n    show\n    go to x: (-171) y: (71)\n    forever\n        if <touching (player v)?> then\n            change [collect v] by (1)\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            clear graphic effects\n        end\n    end\nend\n\nshow\n\ngo to x: (-23) y: (-6)\n\ngo to x: (-23) y: (-6)\nshow\n\nwhen flag clicked\nhide\n\nwhen I receive [death v]\nif <<<(Level) = [3]> or <(Level) = [4]>> or <(Level) = [8]>> then\n    wait (0) seconds\n    wait (0) seconds\n    wait (0) seconds\n    wait (0) seconds\n    show\nend\n\nwhen I receive [next level v]\nif <(Level) = [4]> then\n    show\n    go to x: (-6) y: (10)\n    forever\n        if <touching (player v)?> then\n            change [collect v] by (1)\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            clear graphic effects\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [8]> then\n    show\n    go to x: (-91) y: (56)\n    forever\n        if <touching (player v)?> then\n            change [collect v] by (1)\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            clear graphic effects\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [10]> then\n    hide\nend\n\n@black\n\ngo to [back v] layer\n\nwhen flag clicked\nforever\n    go to (pumpkin v)\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [next level v]\nclear graphic effects\nshow\nswitch costume to (blank v)\nif <<(Level) = [2]> or <(Level) = [5]>> then\n    Check 1\nend\nif <(Level) = [3]> then\n    Check 3\nend\nif <(Level) = [4]> then\n    Check 4\nend\nif <(Level) = [8]> then\n    Check 2\nend\n\nwhen I receive [next level v]\nclear graphic effects\nshow\nswitch costume to (blank v)\n\nwhen I receive [death v]\nswitch costume to (blank v)\nclear graphic effects\nshow\nif <(Level) = [9]> then\n    hide\nend\nif <<(Level) = [2]> or <(Level) = [5]>> then\n    Check 1\nend\nif <(Level) = [3]> then\n    Check 3\nend\nif <(Level) = [4]> then\n    Check 4\nend\n\ndefine Check 3\nif <(Level) = [3]> then\n    show\n    forever\n        if <(Collect) = [1]> then\n            switch costume to (3-1 v)\n        end\n        if <(Collect) = [2]> then\n            switch costume to (3-2 v)\n        end\n        if <(Collect) = [3]> then\n            switch costume to (full v)\n            repeat (10)\n                wait (0) seconds\n            end\n            if <not <(Collect) = [0]>> then\n                wait (0.5) seconds\n                repeat (10)\n                    change [ghost v] effect by (10)\n                end\n                hide\n                stop [this script v]\n            end\n        end\n    end\nend\n\ndefine Check 4\nif <(Level) = [4]> then\n    show\n    forever\n        if <(Collect) = [1]> then\n            switch costume to (4-1 v)\n        end\n        if <(Collect) = [2]> then\n            switch costume to (4-2 v)\n        end\n        if <(Collect) = [3]> then\n            switch costume to (4-3 v)\n        end\n        if <(Collect) = [4]> then\n            switch costume to (full v)\n            wait (0.5) seconds\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            stop [this script v]\n        end\n    end\nend\n\ndefine Check 1\nshow\nforever\n    if <(Collect) = [1]> then\n        switch costume to (full v)\n        repeat (10)\n            wait (0) seconds\n        end\n        if <not <(Collect) = [0]>> then\n            wait (0.5) seconds\n            repeat (10)\n                change [ghost v] effect by (10)\n            end\n            hide\n            stop [this script v]\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [6]> then\n    hide\nend\n\ndefine Check 2\nif <(Level) = [8]> then\n    show\n    forever\n        if <(Collect) = [1]> then\n            switch costume to (2-1 v)\n        end\n        if <(Collect) = [2]> then\n            switch costume to (full v)\n            repeat (10)\n                wait (0) seconds\n            end\n            if <not <(Collect) = [0]>> then\n                wait (0.5) seconds\n                repeat (10)\n                    change [ghost v] effect by (10)\n                end\n                hide\n                stop [this script v]\n            end\n        end\n    end\nend\n\nswitch costume to (3-2 v)\n\nwhen I receive [next level v]\nif <(Level) = [9]> then\n    hide\nend\n\n