The Elementals Part 2 - A Platformer

Instructions: This is part 2 of The Elementals series! Arrow Keys/WASD to move, please report any bugs in comments.\n\nLink to original: https://scratch.mit.edu/projects/416200948/\nLink to Part 3: https://scratch.mit.edu/projects/431720849/\nLink to Part 4: https://scratch.mit.edu/projects/436354428\nLink to finale: https://scratch.mit.edu/projects/438117478

@Stage\n\nwhen flag clicked\nswitch backdrop to (outside v)\n\nwhen flag clicked\nforever\n    if <(level) = [9]> then\n        switch backdrop to (outside v)\n        set volume to (0) %\n    end\nend\n\nwhen I receive [gamestart v]\nwait until <(level) = [2]>\nswitch backdrop to (crystals v)\nset volume to (100) %\nrepeat until <(level) = [9]>\n    play sound [27 Underground Sewers \(NSMBWii\) v] until done\nend\n\nwhen I receive [you win v]\nset volume to (0) %\n\n@The Elemental\n\nwhen I receive [end v]\npoint in direction (90)\nstop [other scripts in sprite v]\nswitch costume to (happy v)\ngo to x: (-32) y: (-66)\ngo to [front v] layer\nset size to (150) %\nturn left (15) degrees\n\nwhen flag clicked\ngo to x: (-205) y: (89)\npoint in direction (90)\ngo to [back v] layer\nhide\nset [whirl v] effect to (0)\nswitch costume to (right side - 1 v)\nset size to (100) %\nset [x velocity v] to [0]\nset [y velocity v] to [0]\ngo to x: (-205) y: (89)\n\nwhen I receive [gamestart v]\ngo to x: (-205) y: (89)\ngo to [back v] layer\nbroadcast (animation code v)\nbroadcast (drop code v)\nshow\nforever\n    go to [front v] layer\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        broadcast (drop code v)\n        broadcast (animation code v)\n        change [x velocity v] by (1)\n        switch costume to (right side - 1 v)\n        set [direction v] to [r]\n    end\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        broadcast (drop code v)\n        broadcast (animation code v)\n        change [x velocity v] by (-1)\n        switch costume to (birdman2 v)\n        set [direction v] to [l]\n    end\n    set [x velocity v] to ((x velocity) * (.9))\n    change x by (x velocity)\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 y by (1)\n                        if <touching (level v)?> then\n                            change x by ((x velocity) * (-1))\n                            change y by (-5)\n                            if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                                if <(x velocity) > [0]> then\n                                    set [x velocity v] to [-5]\n                                else\n                                    set [x velocity v] to [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 (level 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 (level v)?> then\n        if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n            change [y velocity v] by (15)\n        end\n    end\n    change y by (1)\n    if <(x position) > [230]> 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: (-205) y: (-120)\n    end\nend\n\nwhen flag clicked\nforever\n    if <(level) = [9]> then\n        repeat (5)\n            go to x: (-205) y: (-80)\n            go to x: (-205) y: (-80)\n        end\n        stop [this script v]\n    end\nend\n\nwhen I receive [animation code v]\nforever\n    if <(direction) = [r]> then\n        switch costume to (right side - 1 v)\n        repeat (14)\n            wait (0.075) seconds\n            next costume\n        end\n    else\n        if <(direction) = [l]> then\n            switch costume to (left side - 1 v)\n            repeat (14)\n                wait (0.075) seconds\n                next costume\n            end\n        end\n    end\nend\n\nwhen I receive [shut down v]\nstop [other scripts in sprite v]\n\nwhen I receive [end v]\nswitch costume to (happy v)\ngo to x: (-32) y: (-66)\ngo to [front v] layer\nset size to (150) %\nturn left (15) degrees\n\nwhen flag clicked\n\nwhen I receive [gamestart v]\nforever\n    if <<(y position) = [-240]> or <(y position) < [-240]>> then\n        go to x: (-205) y: (-120)\n    end\nend\n\nwhen I receive [go to the rigth position v]\ngo to x: (-205) y: (-80)\ngo to x: (-205) y: (-80)\n\n@THEPARAKEET01 intro\n\nwhen flag clicked\npoint in direction (90)\nhide\ngo to [front v] layer\ngo to x: (-677) y: (-10)\nswitch costume to (costume1 v)\nbroadcast (THEPARAKEET01 v)\n\nwhen I receive [theparakeet01 v]\nset [ghost v] effect to (0)\nset size to (500) %\npoint in direction (90)\nswitch costume to (costume1 v)\nhide\nstart sound [stranger things  v]\nset volume to (150) %\nwait (1) seconds\ngo to x: (-677) y: (-10)\nshow\nrepeat (25)\n    go to [front v] layer\n    move (10) steps\n    wait (0.1) seconds\nend\nrepeat (10)\n    change [ghost v] effect by (10)\n    wait (0.1) seconds\nend\nhide\nswitch costume to (costume2 v)\ngo to x: (7) y: (207)\nset [ghost v] effect to (0)\nwait (1) seconds\nshow\nrepeat (25)\n    change y by (-10)\n    wait (0.15) seconds\nend\nrepeat (10)\n    change [ghost v] effect by (10)\n    wait (0.1) seconds\nend\nhide\nswitch costume to (costume3 v)\ngo to x: (362) y: (295)\nset [ghost v] effect to (0)\nwait (1) seconds\nshow\npoint in direction (45)\nrepeat (25)\n    change x by (-10)\n    change y by (-10)\n    wait (0.15) seconds\nend\nrepeat (10)\n    change [ghost v] effect by (10)\n    wait (0.1) seconds\nend\nhide\npoint in direction (90)\nswitch costume to (costume1 v)\ngo to x: (0) y: (-12)\nset [ghost v] effect to (0)\nwait (1) seconds\nshow\nrepeat (60)\n    change [ghost v] effect by (1)\n    change size by (-1)\n    wait (0.09) seconds\nend\nhide\nrepeat (100)\n    change volume by (-1)\nend\nstop all sounds\nset volume to (100) %\nbroadcast (gamestart v)\n\nset size to (150) %\n\nmove (10) steps\n\nwhen I receive [end intro v]\nstop [other scripts in sprite v]\nhide\nrepeat (100)\n    change volume by (-1)\nend\nstop all sounds\nset volume to (100) %\nbroadcast (gamestart v)\n\n@Sprite19\n\nwhen flag clicked\ngo to [front v] layer\nshow\ngo to x: (-144) y: (-138)\nforever\n    go to [front v] layer\n    if <touching (mouse-pointer v)?> then\n        switch costume to (costume2 v)\n    else\n        switch costume to (costume1 v)\n    end\nend\n\nwhen this sprite clicked\nbroadcast (end intro v)\nhide\n\nwhen I receive [gamestart v]\nhide\n\n@level\n\nwhen flag clicked\nset [level v] to [1]\nshow\ngo to [back v] layer\ngo to [back v] layer\nswitch costume to (costume1 v)\nforever\n    switch costume to (level)\nend\n\nset [level v] to (costume [number v])\n\nwhen flag clicked\nforever\n    if <(level) = [9]> then\n        broadcast (go to the rigth position v)\n        stop [this script v]\n    end\nend\n\n@black\n\nwhen flag clicked\nset [ghost v] effect to (0)\nshow\ngo [backward v] (1) layers\ngo to [front v] layer\n\nwhen I receive [gamestart v]\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nhide\n\nwhen I receive [gamestart v]\nwait (0.1) seconds\nset volume to (100) %\nforever\n    play sound [25 Forest Land Overworld \(NSMBWii\) v] until done\nend\n\nwhen I receive [gamestart v]\nforever\n    if <(level) = [2]> then\n        set volume to (0) %\n    else\n        if <(level) = [9]> then\n            set volume to (100) %\n        end\n    end\nend\n\n@light\n\nwhen flag clicked\nhide\nforever\n    if <(level) > [1]> then\n        show\n        go to [front v] layer\n        go to (the elemental v)\n    end\n    if <<(level) = [1]> or <(level) = [9]>> then\n        hide\n    end\nend\n\n@Water elemental crystal\n\nwhen flag clicked\nset size to (100) %\nhide\npoint in direction (90)\ngo to x: (150) y: (75)\nforever\n    switch costume to (costume1 v)\n    wait (1) seconds\n    repeat (14)\n        next costume\n        wait (0.05) seconds\n    end\nend\n\nwhen I receive [gamestart v]\ngo to x: (150) y: (75)\nshow\n\nwhen I receive [gamestart v]\nforever\n    if <(level) = [9]> then\n        show\n        go to [front v] layer\n        go to x: (150) y: (75)\n        show\n        repeat until <touching (the elemental v)?>\n            repeat (5)\n                change y by (2)\n                wait (0.05) seconds\n            end\n            repeat (10)\n                change y by (-2)\n                wait (0.05) seconds\n            end\n            repeat (5)\n                change y by (2)\n                wait (0.05) seconds\n            end\n        end\n        broadcast (you win v)\n        set size to (100) %\n        broadcast (shut down v)\n        broadcast (fly v)\n        set volume to (100) %\n        play sound [51 Bowser Defeated \(NSMBWii\) v] until done\n        broadcast (end v)\n    else\n        hide\n    end\nend\n\nwhen I receive [fly v]\nrepeat (10)\n    change y by (5)\nend\n\nwhen I receive [end v]\nswitch costume to (costume1 v)\npoint in direction (90)\nturn right (15) degrees\nstop [other scripts in sprite v]\ngo to x: (74) y: (-71)\ngo to [front v] layer\nset size to (200) %\nforever\n    stop all sounds\n    stop [all v]\nend\n\n@winner's circle\n\nwhen flag clicked\nhide\nset size to (100) %\n\nwhen I receive [end v]\nswitch costume to (costume1 v)\nshow\ngo to x: (3) y: (2)\n\n@Sprite2\n\nwhen flag clicked\ngo to x: (3) y: (-138)\nhide\n\n