Platformer Part-9 (Underwater)

Instructions: ╔∘ ★ ∘══════╗\n::PLATFORMER::\n╚══════∘ ★ ∘╝\n@jindalsargun\nLove, fav, remix, and follow! \nPart-01 - https://scratch.mit.edu/projects/511930996/\nPart-02 - https://scratch.mit.edu/projects/520595337/\nPart-03 - https://scratch.mit.edu/projects/524135352/\nPart-04 - https://scratch.mit.edu/projects/526959655/\nPart-05 - https://scratch.mit.edu/projects/528697474/\nPart-06 - https://scratch.mit.edu/projects/529835140/\nPart-07 - https://scratch.mit.edu/projects/530465929/\nPart-08 - https://scratch.mit.edu/projects/532679243/\nPart-09 - https://scratch.mit.edu/projects/535570060/\nPart-10 - https://scratch.mit.edu/projects/538021056/     \nPart-12 - https://scratch.mit.edu/projects/542317456/\n✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧\n                               INSTRUCTIONS\nPress WASD or arrow buttons to move.\nAvoid spikes (grey), holes and arrows kinda things (red).\nThere are 9 levels.\nEvery level is possible.\n     ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧\n                                    UPDATES\n28th May 2021 - shared\n     ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧

@Stage\n\nwhen flag clicked\nswitch backdrop to (backdrop2 v)\n\nwhen I receive [start v]\nswitch backdrop to (backdrop1 v)\n\n@Player\n\nwhen flag clicked\nset [level v] to [1]\ngo to [front v] layer\nhide\n\nwhen I receive [start v]\nshow\nset [signal v] to [disactivated]\npoint in direction (90)\ngo to x: (-190) y: (20)\nset [xs v] to [0]\nset [ys 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 [xs v] by (1.5)\n        switch costume to (right v)\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 [xs v] by (-1.5)\n        switch costume to (left v)\n    end\n    if <<<key (right arrow v) pressed?> or <<key (d v) pressed?> or <<mouse down?> and <(mouse x) > (x position)>>>> and <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>>>> then\n        switch costume to (upright v)\n    end\n    if <<<key (left arrow v) pressed?> or <<key (a v) pressed?> or <<mouse down?> and <(mouse x) < (x position)>>>> and <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>>>> then\n        switch costume to (upleft v)\n    end\n    if <not <<key (right arrow v) pressed?> or <<key (left arrow v) pressed?> or <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<key (a v) pressed?> or <<key (d v) pressed?> or <<<mouse down?> and <(mouse x) > (x position)>> or <<mouse down?> and <(mouse x) < (x position)>>>>>>>>>> then\n        switch costume to (normal v)\n    end\n    if <<key (down arrow v) pressed?> or <<key (s v) pressed?> or <<mouse down?> and <(mouse y) < (y position)>>>> then\n        switch costume to (down v)\n    end\n    change x by (Xs)\n    if <touching (ground v)?> then\n        change x by ((Xs) * (-1))\n        if <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>>> then\n            if <(Xs) > [0]> then\n                set [xs v] to [-15]\n                set [ys v] to [10]\n            else\n                set [xs v] to [15]\n                set [ys v] to [10]\n            end\n        else\n            set [xs v] to [0]\n        end\n    else\n        set [xs v] to ((Xs) * (0.8))\n    end\n    change y by (Ys)\n    if <touching (ground v)?> then\n        change y by ((Ys) * (-1))\n        set [ys v] to [0]\n        if <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>>> then\n            switch costume to (player - up v)\n            if <(Jumping) = [yes]> then\n                set [ys v] to [12]\n                set [jumping v] to [no]\n            end\n        end\n    else\n        change [ys v] by (-1)\n        set [jumping v] to [yes]\n    end\n    if <(x position) > [239]> then\n        change [level v] by (1)\n        go to x: (-190) y: (20)\n        set [xs v] to [0]\n        set [ys v] to [0]\n    end\n    if <<<touching (spikes v)?> or <(y position) < [-178]>> or <touching (spikes 0.2 v)?>> then\n        go to x: (-190) y: (50)\n        set [xs v] to [0]\n        set [ys v] to [0]\n    end\n    if <touching (trampoline v)?> then\n        set [ys v] to [20]\n    end\n    if <touching (water v)?> then\n        set [ys v] to [-1]\n        if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>> then\n            set [ys v] to [5]\n        end\n        if <<<key (down arrow v) pressed?> or <key (s v) pressed?>> or <<mouse down?> and <(y position) > (mouse y)>>> then\n            set [ys v] to [-5]\n        end\n    end\n    if <touching (speed ups v)?> then\n        set [xs v] to [20]\n    end\nend\n\nwhen I receive [start v]\nforever\n    play sound [bensound-creativeminds2 v] until done\nend\n\nset [level v] to [8]\n\nwhen flag clicked\nwait (10) seconds\nbroadcast (Start v)\n\n@Shine\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nshow\ngo to [back v] layer\nforever\n    go to (player v)\nend\n\n@Ground\n\nwhen I receive [start v]\ngo to x: (0) y: (0)\nshow\nswitch costume to (1 v)\nforever\n    go to [front v] layer\n    switch costume to (Level)\nend\n\nwhen flag clicked\nhide\n\n@Spikes\n\nwait (0.5) seconds\n\nwhen I receive [start v]\ngo to x: (0) y: (0)\nshow\nswitch costume to (1 v)\nforever\n    switch costume to (Level)\nend\n\nwhen flag clicked\nhide\n\n@Spikes 0.2\n\nwhen I receive [start v]\ngo to x: (0) y: (0)\nshow\nswitch costume to (1 v)\nforever\n    switch costume to (Level)\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nforever\n    glide (1) secs to x: (0) y: ((y position) + (50))\n    glide (1) secs to x: (0) y: ((y position) + (-50))\nend\n\nchange [level v] by (1)\n\n@Trampoline\n\nwhen I receive [start v]\ngo to [front v] layer\ngo to x: (0) y: (0)\nshow\nswitch costume to (1 v)\nforever\n    switch costume to (Level)\nend\n\nwhen flag clicked\nhide\n\n@Speed Ups\n\nwhen I receive [start v]\ngo to [front v] layer\ngo to x: (0) y: (0)\nshow\nswitch costume to (1 v)\nforever\n    switch costume to (Level)\nend\n\nwhen flag clicked\nhide\n\nchange [level v] by (1)\n\n@Plants\n\nwhen I receive [start v]\ngo to [back v] layer\ngo to x: (0) y: (0)\nshow\nswitch costume to (1 v)\nforever\n    switch costume to (Level)\nend\n\nwhen flag clicked\nhide\n\n@intro\n\nwhen flag clicked\nshow\nif <(intro played?) = [0]> then\n    set [id v] to [5]\n    create clone of (_myself_ v)\n    set [id v] to [6]\n    create clone of (_myself_ v)\n    set [intro end animation? v] to [0]\n    set volume to (100) %\n    set [brightness v] effect to (-100)\n    go to x: (0) y: (0)\n    set size to (87) %\n    switch costume to (bg v)\n    point in direction (90)\n    show\n    go to [front v] layer\n    repeat (75)\n        change size by (((125) - (size)) / (50))\n        change [brightness v] effect by (1)\n        float\n    end\n    forever\n        float\n        change size by (((100) - (size)) / (25))\n    end\nelse\n    set [brightness v] effect to (-100)\n    wait (0.15) seconds\n    hide\n    broadcast (end intro v)\n    set [intro played? v] to [0]\nend\n\nwhen flag clicked\nset [intro: x v] to (mouse x)\nset [intro: y v] to (mouse y)\nwait until <not <mouse down?>>\nif <(mouse y) > [179]> then\n    wait until <not <(mouse x) = (Intro: x)>>\n    wait until <not <(mouse y) = (Intro: y)>>\nend\nforever\n    if <<touching (mouse-pointer v)?> and <mouse down?>> then\n        wait until <<not <mouse down?>> or <touching (mouse-pointer v)?>>\n        if <<touching (mouse-pointer v)?> and <(intro end animation?) = [0]>> then\n            set [intro end animation? v] to [1]\n            set [id v] to [3]\n            start sound [Hit_Hurt4 v]\n            broadcast (z intro fade v)\n            create clone of (_myself_ v)\n            wait (0.15) seconds\n            set [id v] to [4]\n            create clone of (_myself_ v)\n            repeat (15)\n                change volume by (-7.5)\n            end\n            wait (0.5) seconds\n            broadcast (end intro v)\n            stop [this script v]\n        end\n    end\nend\n\nwhen flag clicked\nwait (2.5) seconds\nif <(intro end animation?) = [0]> then\n    set [id v] to [1]\n    create clone of (_myself_ v)\n    change [id v] by (1)\n    create clone of (_myself_ v)\nend\nset [brightness v] effect to (20)\nrepeat (20)\n    change [brightness v] effect by (-1)\nend\nwait (0.6) seconds\nset size to (150) %\nset [brightness v] effect to (20)\nrepeat (20)\n    change [brightness v] effect by (-1)\nend\nwait (0.45) seconds\nrepeat (4)\n    set size to (150) %\n    set [brightness v] effect to (20)\n    repeat (5)\n        change [brightness v] effect by (-1)\n    end\nend\nrepeat (15)\n    change [brightness v] effect by (-1.5)\nend\nwait (0.675) seconds\nset size to (150) %\nset [brightness v] effect to (20)\nrepeat (20)\n    change [brightness v] effect by (-1)\nend\n\nwhen I start as a clone\nset [brightness v] effect to (0)\nif <(id) = [1]> then\n    point in direction (80)\n    switch costume to (logo bg v)\n    show\n    set size to (50) %\n    go to [front v] layer\n    repeat (25)\n        change size by (((100) - (size)) / (3))\n        turn right (((90) - (direction)) / (3)) degrees\n    end\n    wait (44) seconds\n    repeat (4)\n        change size by (((-15) - (size)) / (3))\n    end\n    hide\n    delete this clone\nelse\n    if <(id) = [2]> then\n        change y by (-5)\n        point in direction (65)\n        switch costume to (logo v)\n        show\n        set size to (0) %\n        go to [front v] layer\n        repeat (25)\n            change size by (((100) - (size)) / (3))\n            turn right (((90) - (direction)) / (3)) degrees\n        end\n        wait (44) seconds\n        repeat (6)\n            change size by (((-8) - (size)) / (3))\n        end\n        hide\n        delete this clone\n    else\n        if <<(id) = [3]> or <(id) = [4]>> then\n            go to [front v] layer\n            set size to (100) %\n            go to x: (0) y: (0)\n            repeat (40)\n                switch costume to (costume2 v)\n                change size by (((2750) - (size)) / (8))\n                if <(id) = [3]> then\n                    switch costume to (costume3 v)\n                else\n                    change [brightness v] effect by (-4)\n                    switch costume to (costume1 v)\n                end\n            end\n        else\n            hide\n            set volume to (75) %\n            if <(id) = [5]> then\n                set [pan left/right v] effect to (-100)\n                play sound [monodyL v] until done\n                delete this clone\n            else\n                set [pan left/right v] effect to (100)\n                play sound [monodyR v] until done\n                delete this clone\n            end\n        end\n    end\nend\n\nwhen flag clicked\nwait (7.2) seconds\nif <(intro end animation?) = [0]> then\n    set [intro end animation? v] to [1]\n    set [id v] to [3]\n    start sound [Hit_Hurt4 v]\n    create clone of (_myself_ v)\n    wait (0.15) seconds\n    set [id v] to [4]\n    create clone of (_myself_ v)\n    wait (1) seconds\n    broadcast (end intro v)\nend\n\nwhen I start as a clone\nset [float v] to [0]\nwait (0.25) seconds\nif <(id) = [1]> then\n    repeat (27)\n        float\n    end\n    repeat (5)\n        change x by (50)\n        float\n    end\n    set x to ((x position) * (-1))\n    repeat (32)\n        change x by (((0) - (x position)) / (2))\n        float\n    end\n    set x to (0)\n    repeat (2)\n        repeat (5)\n            change y by (((25) - (y position)) / (2))\n            float\n        end\n        repeat (5)\n            change y by (((-25) - (y position)) / (2))\n            float\n        end\n    end\n    repeat (5)\n        change y by (((25) - (y position)) / (2))\n        float\n    end\n    set [spin! v] to [90]\n    repeat (15)\n        change y by (((0) - (y position)) / (2))\n        change [spin! v] by (((135) - (spin!)) / (8))\n        point in direction (spin!)\n    end\n    repeat (20)\n        change y by (((0) - (y position)) / (2))\n        change [spin! v] by (((45) - (spin!)) / (8))\n        point in direction (spin!)\n    end\n    set [zoom v] to [0]\n    repeat (100)\n        change y by (((0) - (y position)) / (2))\n        change [spin! v] by (((90) - (spin!)) / (8))\n        point in direction (spin!)\n        change [zoom v] by (-2)\n        change size by (zoom)\n    end\nelse\n    if <(id) = [2]> then\n        repeat (27)\n            float\n        end\n        repeat (5)\n            change x by (-50)\n            float\n        end\n        set x to ((x position) * (-1))\n        repeat (32)\n            change x by (((0) - (x position)) / (2))\n            float\n        end\n        set x to (0)\n        repeat (2)\n            repeat (5)\n                change y by (((-25) - (y position)) / (2))\n                float\n            end\n            repeat (5)\n                change y by (((25) - (y position)) / (2))\n                float\n            end\n        end\n        repeat (5)\n            change y by (((-25) - (y position)) / (2))\n            float\n        end\n        set [spin! v] to [90]\n        repeat (15)\n            change y by (((0) - (y position)) / (2))\n            change [spin! v] by (((45) - (spin!)) / (8))\n            point in direction (spin!)\n        end\n        repeat (20)\n            change y by (((0) - (y position)) / (2))\n            change [spin! v] by (((135) - (spin!)) / (8))\n            point in direction (spin!)\n        end\n        set [zoom v] to [0]\n        repeat (100)\n            change y by (((0) - (y position)) / (2))\n            change [spin! v] by (((90) - (spin!)) / (8))\n            point in direction (spin!)\n            change [zoom v] by (-2)\n            change size by (zoom)\n        end\n    end\nend\n\ndefine float\nif <(costume [number v]) = [1]> then\n    change [float v] by (3)\n    change y by (([sin v] of (float) ) / (4))\nelse\n    if <(costume [number v]) = [3]> then\n        change [float v] by (6)\n    else\n        change [float v] by (-6)\n    end\n    change y by (([sin v] of (float) ) / (3))\n    change size by (([sin v] of (float) ) / (4))\n    turn right (([sin v] of (float) ) / (5)) degrees\nend\n\nwhen I receive [end intro v]\nstop [other scripts in sprite v]\nif <(costume [number v]) = [1]> then\n    set [intro played? v] to [0]\n    go to x: (0) y: (0)\n    switch costume to (bg2 v)\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\n    set [ghost v] effect to (0)\n    hide\nelse\n    delete this clone\nend\n\nwhen I receive [z intro fade v]\nif <(id) > [4]> then\n    repeat (15)\n        change volume by (-7.5)\n    end\nend\n\nwhen flag clicked\nwait (7.2) seconds\nif <(intro end animation?) = [0]> then\n    set [intro end animation? v] to [1]\n    set [id v] to [3]\n    start sound [Hit_Hurt4 v]\n    create clone of (_myself_ v)\n    wait (0.15) seconds\n    set [id v] to [4]\n    create clone of (_myself_ v)\n    wait (1) seconds\n    broadcast (end intro v)\nend\n\nwhen flag clicked\nset [intro played? v] to [1]\n\nwhen flag clicked\nwait (13) seconds\nbroadcast (Start v)\n\n@Tn\n\nwhen flag clicked\nshow\nset [ghost v] effect to (100)\ngo to [front v] layer\ngo to x: (0) y: (0)\nset volume to (100) %\n\n