Pencil Player (Platformer)

Instructions: Working on boss fight. Spam green flag \n-----\nWASD or Arrow keys to move. Avoid spikes and grey colored lava.\n-----\n

@Stage\n\nwhen flag clicked\nforever\n    play sound [Popsicle v] until done\nend\n\nwhen I receive [mute v]\nset volume to (0) %\n\nwhen I receive [unmute v]\nset volume to (100) %\n\n@player\n\nwhen flag clicked\nshow\ngo to x: (-205) y: (-125)\nset [player x v] to [0]\nset [player y v] to [0]\nforever\n    if <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(mouse x) > (x position)>>> then\n        change [player x v] by (1)\n    end\n    if <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(mouse x) < (x position)>>> then\n        change [player x v] by (-1)\n    end\n    set [player x v] to ((Player X) * (0.9))\n    change x by (Player X)\n    if <touching (level v)?> then\n        change y by (1)\n        if <touching (level v)?> then\n            change y by (1)\n            if <touching (level v)?> then\n                change y by (1)\n                if <touching (level v)?> then\n                    change y by (1)\n                    if <touching (level v)?> then\n                        change x by ((Player X) * (-1))\n                        change y by (-4)\n                        if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>> then\n                            if <(Player X) > [0]> then\n                                set [player x v] to [-5]\n                            else\n                                set [player x v] to [5]\n                            end\n                            set [player y v] to [12]\n                        else\n                            set [player x v] to [0]\n                        end\n                    end\n                end\n            end\n        end\n    end\n    change [player y v] by (-1)\n    change y by (Player Y)\n    if <touching (level v)?> then\n        change y by ((Player Y) * (-1))\n        set [player y v] to [0]\n    end\n    change y by (-1)\n    if <<touching (level v)?> and <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>>> then\n        set [player y v] to [12]\n    end\n    change y by (1)\nend\n\nwhen flag clicked\nforever\n    if <touching (--- v)?> then\n        play sound [hurt v] until done\n    end\nend\n\nwhen flag clicked\nforever\n    if <(x position) > [235]> then\n        go to x: (-205) y: (-125)\n        change [level v] by (1)\n        broadcast (Next Level v)\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (--- v)?> then\n        go to x: (-205) y: (-125)\n    end\nend\n\n@level\n\nwhen flag clicked\nset [level v] to [1]\nswitch costume to (1 v)\nshow\ngo to x: (0) y: (0)\n\nwhen I receive [next level v]\nnext costume\n\n@---\n\nwhen flag clicked\nset [level v] to [1]\nswitch costume to (1 v)\nshow\ngo to x: (0) y: (0)\n\nwhen I receive [next level v]\nnext costume\n\nwhen flag clicked\nforever\n    if <(costume [number v]) = [4]> then\n        go to [front v] layer\n    else\n        go to [back v] layer\n    end\nend\n\n@text\n\nwhen I receive [next level v]\nnext costume\n\nwhen flag clicked\ngo to [front v] layer\nset [level v] to [1]\nswitch costume to (1 v)\nshow\ngo to x: (0) y: (0)\n\n@tb\n\nwhen flag clicked\nshow\nset [color v] effect to (0)\ngo to x: (0) y: (0)\nwait (.5) seconds\nrepeat (40)\n    change [ghost v] effect by (5)\nend\nhide\n\nwhen flag clicked\nforever\n    go to [front v] layer\nend\n\n@Sprite1\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nwhen this sprite clicked\nnext costume\n\nwhen flag clicked\ngo to x: (-204) y: (150)\nforever\n    if <(costume [number v]) = [1]> then\n        broadcast (unmute v)\n    else\n        broadcast (mute v)\n    end\nend\n\n@Sprite2\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nwhen flag clicked\ngo to x: (-160) y: (150)\n\nwhen this sprite clicked\nbroadcast (Next Level v)\n\n