A mushroomy problem - Scrolling Platformer
@Stage\n\nwhen I receive [green flag v]\nhide variable [mouse v]\n\nwhen I receive [green flag v]\nrepeat until <(LEVEL) = [5]>\n    play sound [Woods v] until done\nend\n\n    play sound [Boss v] until done\nend\n\nwhen I receive [boss v]\nstop all sounds\n\n@Player\n\nwhen flag clicked\nbroadcast (Green Flag v)\nbroadcast (Play Game v)\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\n\nwhen I receive [play game v]\nshow\nset [level v] to [1]\nforever\n    broadcast (Reset v) and wait\n    broadcast (Setup v) and wait\n    Game On\n    repeat until <(EXIT) > []>\n        Tick\n        broadcast (Tick v) and wait\n    end\n    if <(EXIT) = [win]> then\n        Game - Win\n    else\n        Game - Die\n    end\nend\n\ndefine Game On\nset [climbing v] to [0]\nset [attack? v] to [0]\nset [bounce? v] to [0]\nset [sx v] to [0]\nset [sy v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nset size to (100) %\nset rotation style [left-right v]\n\ndefine Tick\nswitch costume to (hitbox v)\nif <(attack?) = [0]> then\n    if <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n        point in direction (-90)\n        change [sx v] by (-2)\n        if <(CLIMBING) = [0]> then\n            change [frame v] by (0.5)\n        end\n    else\n        if <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n            point in direction (90)\n            change [sx v] by (2)\n            if <(CLIMBING) = [0]> then\n                change [frame v] by (0.5)\n            end\n        else\n            set [frame v] to [0]\n        end\n    end\nend\nset [sx v] to ((sx) * (0.8))\nif <([abs v] of (sx) ) > [0.9]> then\n    Change Player x by (round (sx))\nend\nif <touching (mushrooms v)?> then\n    set [sy v] to [30]\n    broadcast (jump v)\nend\nif <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n    if <<(in air) < [4]> or <touching (mushrooms v)?>> then\n        set [sy v] to [16]\n    end\nend\nchange [sy v] by (-2)\nif <<key (space v) pressed?> and <touching (vines v)?>> then\n    set [sy v] to [-2]\n    set [climbing v] to [1]\nelse\n    set [climbing v] to [0]\nend\nif <<<key (w v) pressed?> or <key (up arrow v) pressed?>> and <(CLIMBING) = [1]>> then\n    Change player y by [5]\nend\nif <<<key (s v) pressed?> or <key (down arrow v) pressed?>> and <(CLIMBING) = [1]>> then\n    Change player y by [-5]\nend\nChange player y by (sy)\nTest - Die\nchange [scroll x v] by (round (((x) - (SCROLL X)) / (10)))\nif <(SCROLL X) < [-400]> then\n    set [scroll x v] to [-400]\nend\nchange [scroll y v] by (round (((y) - (SCROLL Y)) / (10)))\nif <(SCROLL Y) < [0]> then\n    set [scroll y v] to [0]\nend\nPosition\nif <(y) < [-180]> then\n    set [exit v] to [die]\nend\nSet costume\n\ndefine Change player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nPosition\nrepeat until <not <<touching (platforms v)?> or <touching (blockage v)?>>>\n    if <(sy) > [0]> then\n        change [y v] by (-1)\n    else\n        change [y v] by (1)\n        set [in air v] to [0]\n    end\n    Position\n    set [sy v] to [0]\nend\n\ndefine Position\ngo to x: ((x) - (SCROLL X)) y: ((y) - (SCROLL Y))\n\ndefine Change Player x by (sx)\nchange [x v] by (sx)\nPosition\nif <<touching (platforms v)?> or <touching (blockage v)?>> then\n    repeat (12)\n        change [y v] by (1)\n        Position\n        if <touching (blockage v)?> then\n            if <(direction) = [90]> then\n                set [sx v] to [-20]\n            else\n                set [sx v] to [20]\n            end\n            broadcast (back v)\n        end\n        if <not <<touching (platforms v)?> or <touching (blockage v)?>>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    repeat until <not <<touching (platforms v)?> or <touching (blockage v)?>>>\n        if <(sx) > [0]> then\n            change [x v] by (-1)\n        else\n            change [x v] by (1)\n        end\n        Position\n    end\nend\n\ndefine Game - Die\nset [exit v] to []\nrepeat (5)\n    hide\n    wait (0.1) seconds\n    show\n    wait (0.1) seconds\nend\nhide\nwait (0.5) seconds\nshow\n\ndefine Test - Die\nif <<touching (danger v)?> or <touching (toxic stuff v)?>> then\n    set [exit v] to [die]\nend\n\ndefine Game - Win\nrepeat (50)\n    change [ghost v] effect by (2)\nend\nhide\nchange [level v] by (1)\nwait (1) seconds\nshow\nclear graphic effects\n\nwhen I receive [green flag v]\nforever\n    if <<<<<key (a v) pressed?> or <key (d v) pressed?>> or <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>>> and <(in air) < [4]>> and <(attack?) = [0]>> then\n        start sound [Step v]\n        wait (0.3) seconds\n    end\nend\n\ndefine Set costume\nif <(CLIMBING) = [0]> then\n    if <(attack?) = [0]> then\n        if <(bounce?) = [0]> then\n            if <(in air) = [0]> then\n                if <(frame) = [0]> then\n                    switch costume to (idle v)\n                else\n                    switch costume to ([floor v] of ((4) + ((frame) mod (5))) )\n                end\n            else\n                if <(sy) > [0]> then\n                    switch costume to (jump v)\n                else\n                    switch costume to (fall v)\n                end\n            end\n        else\n            switch costume to (bounce v)\n        end\n    else\n        if <(attack?) = [1]> then\n            switch costume to (attack v)\n        else\n            switch costume to (pre-attack v)\n        end\n    end\nelse\n    switch costume to (climb v)\nend\n\nwhen [0 v] key pressed\nwait until <not <key (0 v) pressed?>>\nchange [level v] by (1)\nset [x v] to [0]\nset [y v] to [0]\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nbroadcast (Reset v) and wait\nbroadcast (Setup v) and wait\n\nwhen flag clicked\nset [level v] to [1]\nwait until <(LEVEL) = [5]>\nbroadcast (boss v)\nhide\nstop [other scripts in sprite v]\n\nwhen [m v] key pressed\n\nshow variable [mouse v]\nset [mouse v] to (join ((mouse x) + (SCROLL X)) (join [, ] ((mouse y) + (SCROLL Y))))\n\nwhen I receive [jump v]\nrepeat until <(sy) < [1]>\n    set [bounce? v] to [1]\nend\nset [bounce? v] to [0]\n\nwhen [space v] key pressed\nif <not <(LEVEL) = [5]>> then\n    if <(in air) < [4]> then\n        set [attack? v] to [2]\n        wait until <not <key (space v) pressed?>>\n        start sound [High Whoosh v]\n        repeat (10)\n            set [attack? v] to [1]\n        end\n        set [attack? v] to [0]\n    else\n        set [attack? v] to [0]\n    end\nend\n\nwhen [r v] key pressed\nbroadcast (Reset v)\nbroadcast (Setup v)\nGame On\n\nwhen [z v] key pressed\nif <(username) = [zelfen]> then\n    set [sy v] to [20]\nend\n\n@Platforms\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (1-1 v)\n    Clone at x [0] y [0]\n    Clone at x [450] y [0]\n    switch costume to (1-2 v)\n    Clone at x [500] y [0]\n    switch costume to (1-3 v)\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (2-1 v)\n        Clone at x [0] y [0]\n        Clone at x [600] y [0]\n        switch costume to (2-2 v)\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (3-1 v)\n            Clone at x [0] y [0]\n            Clone at x [600] y [375]\n            switch costume to (3-2 v)\n            Clone at x [360] y [300]\n            switch costume to (3-2 v)\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (4-1 v)\n                Clone at x [0] y [0]\n                Clone at x [400] y [0]\n                switch costume to (4-2 v)\n            else\n                set [x v] to [99999999]\n            end\n        end\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\n\nwhen I receive [boss v]\nhide\nstop [other scripts in sprite v]\n\n@Exit\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <touching (player v)?> then\n    set [exit v] to [win]\nend\n\nwhen I receive [setup v]\nswitch costume to (closed v)\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    Clone at x [607] y [546]\nelse\n    if <(LEVEL) = [2]> then\n        Clone at x [-159] y [197]\n    else\n        if <(LEVEL) = [3]> then\n            Clone at x [1083] y [841]\n        else\n            if <(LEVEL) = [4]> then\n                Clone at x [-446] y [251]\n            end\n        end\n    end\nend\nset [x v] to [-99999]\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen I receive [end v]\nstop [other scripts in sprite v]\nhide\n\nwhen I receive [tick v]\nturn right (15) degrees\n\n@Overlay\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (1-1 v)\n    Clone at x [0] y [0]\n    Clone at x [450] y [0]\n    switch costume to (1-2 v)\n    Clone at x [500] y [0]\n    switch costume to (1-3 v)\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (2-1 v)\n        Clone at x [0] y [0]\n        Clone at x [600] y [0]\n        switch costume to (2-2 v)\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (3-1 v)\n            Clone at x [0] y [0]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (4-1 v)\n                Clone at x [0] y [0]\n                Clone at x [400] y [0]\n                switch costume to (4-2 v)\n            else\n                set [x v] to [99999999]\n            end\n        end\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\n\nwhen I receive [boss v]\nstop [other scripts in sprite v]\nhide\n\n@Danger\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nclear graphic effects\ngo to [front v] layer\nhide\nif <(LEVEL) = [1]> then\n    set [x v] to [99999999999]\n    switch costume to (1 v)\n    Clone at x [429] y [115]\n    Clone at x [454] y [115]\n    Clone at x [481] y [115]\nelse\n    if <(LEVEL) = [2]> then\n        set [x v] to [99999999999]\n        switch costume to (1 v)\n        Clone at x [112] y [-41]\n        Clone at x [218] y [-41]\n        switch costume to (2 v)\n        Clone at x [464] y [251]\n        Clone at x [511] y [247]\n        Clone at x [548] y [239]\n    else\n        set [x v] to [99999999999]\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\n@Mushrooms\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (mushroom1 v)\n    Clone at x [250] y [-180]\n    Clone at x [1179] y [140]\n    set [x v] to [9999999999]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (mushroom1 v)\n        Clone at x [506] y [-45]\n        Clone at x [902] y [84]\n        set [x v] to [9999999999]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (mushroom1 v)\n            Clone at x [395] y [154]\n            Clone at x [696] y [465]\n            set [x v] to [9999999999]\n        else\n            set [x v] to [9999999999]\n        end\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen I receive [jump v]\nstart sound [sm64_impact v]\nswitch costume to (mushroom1 v)\nrepeat (6)\n    next costume\nend\nswitch costume to (mushroom1 v)\n\n@Blockage\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <<touching (player v)?> and <([costume # v] of [player v]) = [12]>> then\n    start sound [sm64_kill_enemy2 v]\n    repeat (10)\n        change size by (-10)\n        turn right (5) degrees\n    end\n    delete this clone\nend\n\nwhen I receive [setup v]\nset size to (100) %\nhide\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    point in direction (90)\n    switch costume to (blockage1 v)\n    Clone at x [763] y [212]\n    set [x v] to [9999999999]\nelse\n    if <(LEVEL) = [2]> then\n        point in direction (90)\n        switch costume to (blockage1 v)\n        Clone at x [339] y [17]\n        point in direction (-90)\n        Clone at x [-59] y [208]\n        set [x v] to [9999999999]\n    else\n        if <(LEVEL) = [3]> then\n            point in direction (90)\n            switch costume to (blockage1 v)\n            Clone at x [128] y [234]\n            set [x v] to [9999999999]\n        else\n            if <(LEVEL) = [4]> then\n                point in direction (90)\n                switch costume to (blockage1 v)\n                Clone at x [227] y [130]\n                point in direction (-90)\n                Clone at x [-205] y [127]\n                Clone at x [267] y [235]\n                Clone at x [267] y [342]\n                set [x v] to [9999999999]\n            else\n                set [x v] to [9999999999]\n            end\n        end\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen I receive [back v]\nstart sound [sm64_impact v]\nswitch costume to (blockage1 v)\nrepeat (6)\n    next costume\nend\nswitch costume to (blockage6 v)\n\n@Parallax fore\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition (((x) - (SCROLL X)) / (2)) (((y) - (SCROLL Y)) / (2))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (1-1 v)\nrepeat (10)\n    Clone at x [1000] y [0]\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\n\nwhen I receive [boss v]\nstop [other scripts in sprite v]\nhide\n\n@Parallax mid\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition (((x) - (SCROLL X)) / (3)) (((y) - (SCROLL Y)) / (3))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (1-1 v)\nrepeat (10)\n    Clone at x [1000] y [0]\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\n\nwhen I receive [boss v]\nstop [other scripts in sprite v]\nhide\n\n@Parallax Back\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition (((x) - (SCROLL X)) / (6)) (((y) - (SCROLL Y)) / (6))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (1-1 v)\nrepeat (10)\n    Clone at x [1000] y [0]\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\n\nwhen I receive [boss v]\nstop [other scripts in sprite v]\nhide\n\n@Parallax Far Back\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition (((x) - (SCROLL X)) / (12)) (((y) - (SCROLL Y)) / (12))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (1-1 v)\nrepeat (10)\n    Clone at x [5000] y [0]\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\n\nwhen I receive [boss v]\nstop [other scripts in sprite v]\nhide\n\n@Vines\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\npoint in direction ((([cos v] of ((timer) * (100)) ) * (5)) + (90))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nset [x v] to [9999999999]\nif <(LEVEL) = [2]> then\n    switch costume to (vine v)\n    Clone at x [746] y [226]\nelse\n    if <(LEVEL) = [3]> then\n        switch costume to (vine v)\n        Clone at x [-45] y [304]\n    else\n        set [x v] to [9999999999]\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen I receive [tick v]\n\n@Player (Boss)\n\nwhen I receive [boss v]\nshow\nset rotation style [left-right v]\ngo to x: (-126) y: (0)\nset [speedy v] to [0]\nset [falling? v] to [10]\nforever\n    switch costume to (hitbox v)\n    change [speedy v] by (-1)\n    change y by (SpeedY)\n    Touch Ground <(SpeedY) > [0]>\n    if <(walljump) > [0]> then\n        change [walljump v] by (-1)\n    else\n        set [speedx v] to ((SpeedX) * (0.7))\n        if <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n            change [speedx v] by (-1.5)\n        end\n        if <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n            change [speedx v] by (1.5)\n        end\n        if <(SpeedX) < [-0.5]> then\n            Walk [-90] (SpeedX)\n        else\n            if <(SpeedX) > [0.5]> then\n                Walk [90] (SpeedX)\n            else\n                set [frame v] to [0]\n            end\n        end\n        if <<<key (w v) pressed?> or <key (up arrow v) pressed?>> and <(falling?) < [3]>> then\n            set [speedy v] to [12]\n        end\n    end\n    Set costume\nend\n\nwhen I receive [boss v]\nforever\n    if <<<<key (a v) pressed?> or <key (d v) pressed?>> or <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>>> and <(falling?) < [3]>> then\n        wait (0.25) seconds\n        start sound [Step v]\n    end\nend\n\nwhen flag clicked\nset [kick v] to [0]\nhide\n\ndefine Touch Ground <up?>\nchange [falling? v] by (1)\nrepeat until <not <touching (boss arena v)?>>\n    if <up?> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling? v] to [0]\n    end\n    set [speedy v] to [0]\nend\n\ndefine Walk (direction) (speed)\npoint in direction (direction)\nchange x by (speed)\nset [slope v] to [0]\nrepeat until <<(slope) = [8]> or <not <touching (boss arena v)?>>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <(slope) = [8]> then\n    change x by ((0) - (speed))\n    change y by ((0) - (slope))\nend\nif <(speed) < [0]> then\n    change [frame v] by ((speed) / (-10))\nelse\n    change [frame v] by ((speed) / (10))\nend\n\ndefine Set costume\nif <(KICK) = [0]> then\n    if <(falling?) < [3]> then\n        if <(frame) = [0]> then\n            switch costume to (idle v)\n        else\n            switch costume to ([floor v] of ((4) + ((frame) mod (5))) )\n        end\n    else\n        if <(SpeedY) > [0]> then\n            switch costume to (jump v)\n        else\n            switch costume to (fall v)\n        end\n    end\nelse\n    switch costume to (kick v)\nend\n\nwhen [space v] key pressed\nif <(LEVEL) = [5]> then\n    start sound [High Whoosh v]\n    repeat (5)\n        set [kick v] to [1]\n    end\n    set [kick v] to [0]\n    wait until <not <key (space v) pressed?>>\nend\n\nwhen I receive [boss reset v]\nshow\nset rotation style [left-right v]\ngo to x: (-126) y: (0)\n\n@Boss arena\n\nwhen flag clicked\nhide\n\nwhen I receive [boss v]\nshow\n\n@Boss arena overlay\n\nwhen flag clicked\nswitch costume to (costume1 v)\ngo to [back v] layer\nhide\n\nwhen I receive [boss v]\nshow\n\nwhen I receive [win v]\nswitch costume to (costume2 v)\n\n@Boss\n\nwhen flag clicked\nswitch costume to (idle v)\nhide\ngo to x: (129) y: (215)\n\nwhen I receive [boss v]\nwait (1) seconds\nshow\nset [sy v] to [0]\nrepeat until <(y position) < [0]>\n    change y by (sy)\n    change [sy v] by (-1)\nend\nset [sy v] to [0]\ngo to x: (129) y: (0)\nwait (1) seconds\nswitch costume to (roar v)\nstart sound [recording1 v]\nrepeat (50)\n    go to x: (pick random (119) to (139)) y: (pick random (-10) to (10))\nend\ngo to x: (129) y: (0)\nswitch costume to (idle v)\nrepeat until <(Boss health) = [2]>\n    wait (pick random (1.) to (2.)) seconds\n    switch costume to (attack1 v)\n    wait (0.5) seconds\n    switch costume to (attack2 v)\n    broadcast (attack1 v) and wait\n    switch costume to (idle v)\nend\n\nwhen I receive [ouch v]\nif <not <(Boss health) < [0]>> then\n    switch costume to (hurt v)\n    stop [other scripts in sprite v]\n    wait (1) seconds\n    switch costume to (idle v)\n    wait (1) seconds\n    switch costume to (roar v)\n    start sound [recording1 v]\n    repeat (50)\n        go to x: (pick random (119) to (139)) y: (pick random (-10) to (10))\n    end\n    go to x: (129) y: (0)\n    if <(Boss health) = [2]> then\n        repeat until <(Boss health) = [1]>\n            wait (pick random (0.5) to (1.)) seconds\n            switch costume to (attack1 v)\n            wait (0.25) seconds\n            switch costume to (attack2 v)\n            broadcast (attack1 v) and wait\n            switch costume to (idle v)\n        end\n    else\n        repeat until <(Boss health) < [0]>\n            wait (pick random (0.25) to (0.5)) seconds\n            switch costume to (attack1 v)\n            wait (0.125) seconds\n            switch costume to (attack2 v)\n            broadcast (attack1 v) and wait\n            switch costume to (idle v)\n        end\n    end\nelse\n    start sound [Crunch v]\n    switch costume to (dead v)\n    repeat (5)\n        hide\n        wait (0.1) seconds\n        show\n        wait (0.1) seconds\n    end\n    hide\n    broadcast (win v)\nend\n\nwhen I receive [boss reset v]\nstop [other scripts in sprite v]\nwait (1) seconds\nshow\nset [sy v] to [0]\nrepeat until <(y position) < [0]>\n    change y by (sy)\n    change [sy v] by (-1)\nend\nset [sy v] to [0]\ngo to x: (129) y: (0)\nwait (1) seconds\nswitch costume to (roar v)\nstart sound [recording1 v]\nrepeat (50)\n    go to x: (pick random (119) to (139)) y: (pick random (-10) to (10))\nend\ngo to x: (129) y: (0)\nswitch costume to (idle v)\nrepeat until <(Boss health) = [2]>\n    wait (pick random (1.) to (2.)) seconds\n    switch costume to (attack1 v)\n    wait (0.5) seconds\n    switch costume to (attack2 v)\n    broadcast (attack1 v) and wait\n    switch costume to (idle v)\nend\n\n@Boss2\n\nwhen I receive [boss v]\nwait (2) seconds\nshow\nwait (2) seconds\nhide\n\nwhen flag clicked\nhide\n\n@Boss attacks\n\nwhen flag clicked\nset [boss health v] to [3]\nset [attack v] to [0]\nhide\n\nwhen I receive [attack1 v]\nset [attack v] to [1]\npoint in direction (0)\nrepeat (3)\n    turn right (45) degrees\n    create clone of (_myself_ v)\n    start sound [pop v]\n    wait (0.1) seconds\nend\n\nwhen I start as a clone\nshow\nif <(attack) = [1]> then\n    go to (boss v)\n    switch costume to (costume1 v)\n    repeat until <touching (_edge_ v)?>\n        move (-10) steps\n    end\n    delete this clone\nend\n\nwhen I start as a clone\nforever\n    if <<touching (player \(boss\) v)?> and <(KICK) = [1]>> then\n        turn right (180) degrees\n        stop [this script v]\n    end\nend\n\nwhen I start as a clone\nwait (1) seconds\nforever\n    if <touching (boss v)?> then\n        broadcast (OuCh v)\n        change [boss health v] by (-1)\n        start sound [sm64_impact v]\n        delete this clone\n    end\nend\n\nwhen I start as a clone\nforever\n    if <<touching (player \(boss\) v)?> and <(KICK) = [0]>> then\n        broadcast (boss reset v)\n        set [boss health v] to [3]\n        start sound [sm64_impact v]\n        delete this clone\n    end\nend\n\n@Thumbnail\n\nwhen flag clicked\nhide\n\n