Platformer Part-6 (Enemy)

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/   Part-11 - https://scratch.mit.edu/projects/540774309/\nPart-12 - https://scratch.mit.edu/projects/542317456/\n  ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧\n                               INSTRUCTIONS\nPress WASD or arrow buttons to move.\nAvoid lava (white), saws (Red and white), and spikes (grey).\nSince many of you have been asking me to add enemies, I have done so. They are red and big and you an't touch them.\nThere are 9 levels.\nEvery level is possible.\n     ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧ - - - - ✧\n                                    UPDATES\n13th 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\nwhen flag clicked\nforever\n    if <(Level) = [9]> then\n        switch backdrop to (backdrop3 v)\n    end\nend\n\n@Player\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    go [backward v] (9) layers\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 (lava v)?>> or <<touching (saws v)?> or <touching (enemy 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 (speed ups v)?> then\n        set [xs v] to [20]\n    end\nend\n\nwhen flag clicked\nset [level v] to [1]\ngo to [front v] layer\nhide\n\nwhen I receive [start v]\nforever\n    play sound [Vexento-Pollen v] until done\nend\n\n@Shine\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nshow\nforever\n    go to [back v] layer\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    switch costume to (Level)\nend\n\nwhen flag clicked\nhide\n\n@Saws\n\nwhen I receive [start v]\nswitch costume to (1 v)\nshow\ngo to [back v] layer\nforever\n    switch costume to (Level)\n    turn right (5) degrees\nend\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nforever\n    if <(Level) = [2]> then\n        go to x: (191) y: (83)\n    end\n    if <(Level) = [3]> then\n        go to x: (128) y: (136)\n    end\n    if <(Level) = [7]> then\n        go to x: (150) y: (31)\n    end\n    if <(Level) = [8]> then\n        go to x: (-130) y: (73)\n    end\nend\n\n@Lava\n\nwhen flag clicked\ngo to x: (0) y: (0)\nforever\n    repeat (30)\n        change y by (-0.4)\n    end\n    repeat (30)\n        change y by (0.4)\n    end\nend\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@Enemy\n\nwhen flag clicked\nset [level v] to [1]\nhide\n\nwhen flag clicked\nforever\n    if <(Level) = [6]> then\n        switch costume to (forward v)\n        show\n        go to x: (-46) y: (-50)\n        glide (1.5) secs to x: (53) y: (-50)\n        switch costume to (backward v)\n        glide (1.5) secs to x: (-46) y: (-50)\n    end\nend\n\nset [level v] to [7]\n\nif <(Level) = [6]> then\nif <(Level) = [7]> then\n\nwhen flag clicked\nforever\n    if <(Level) = [7]> then\n        switch costume to (forward v)\n        show\n        go to x: (61) y: (117)\n        glide (1.5) secs to x: (212) y: (117)\n        switch costume to (backward v)\n        glide (1.5) secs to x: (61) y: (117)\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [8]> then\n        switch costume to (forward v)\n        show\n        go to x: (3) y: (-49)\n        glide (1.5) secs to x: (175) y: (-48)\n        switch costume to (backward v)\n        glide (1.5) secs to x: (3) y: (-49)\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [9]> then\n        switch costume to (forward v)\n        show\n        go to x: (-127) y: (120)\n        glide (1.5) secs to x: (7) y: (121)\n        switch costume to (backward v)\n        glide (1.5) secs to x: (-127) y: (120)\n    end\nend\n\n@Spikes\n\nwait (0.5) seconds\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@Trampoline\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@Speed Ups\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@Intro\n\nwhen I start as a clone\nif <(Clone ID) = [Pinwheel]> then\n    show\n    repeat until <(timer) > [12]>\n        go to [back v] layer\n        switch costume to (hack v)\n        go [forward v] (1) layers\n        turn right (2) degrees\n        change size by (((120) - (size)) / (3))\n        switch costume to (pinwheel yellow v)\n    end\n    repeat (15)\n        turn right (2) degrees\n        change [ghost v] effect by (3)\n    end\n    delete this clone\nend\n\nwhen I start as a clone\nif <(Clone ID) = [8]> then\n    wait until <(timer) > [3]>\n    Shake2 X [0] Y [0] Size [90] repeat [9]\n    Shake2 X [0] Y [0] Size [120] repeat [9]\n    repeat (3)\n        Shake2 X [0] Y [0] Size [200] repeat [20]\n    end\n    Shake2 X [0] Y [0] Size [250] repeat [9]\n    Shake2 X [0] Y [0] Size [200] repeat [9]\n    repeat (3)\n        Shake2 X [0] Y [0] Size [300] repeat [20]\n    end\n    Shake2 X [0] Y [0] Size [200] repeat [9]\n    Shake2 X [0] Y [0] Size [120] repeat [9]\n    repeat (3)\n        Shake2 X [0] Y [0] Size [200] repeat [20]\n    end\nend\n\nwhen I start as a clone\nif <(Clone ID) = [I]> then\n    set [val2 v] to [50]\n    point in direction (90)\n    go to [front v] layer\n    go [backward v] (4) layers\n    set size to (0) %\n    go to x: (0) y: (0)\n    show\n    switch costume to (chevron2 v)\n    wait (8) seconds\n    delete this clone\nend\nif <(Clone ID) = [8]> then\n    wait until <(timer) > [3]>\n    point in direction (90)\n    go to [front v] layer\n    go to x: (0) y: (0)\n    show\n    switch costume to (name v)\n    set size to (0) %\n    point in direction (-90)\n    wait until <(timer) > [3]>\n    repeat (2)\n        set [var1 v] to [1]\n        repeat (20)\n            go to [front v] layer\n            turn right (var1) degrees\n            change [var1 v] by ((var1) / (5))\n        end\n        set [var1 v] to [1]\n        repeat (80)\n            turn right (((90) - (direction)) / (8)) degrees\n        end\n        wait (1) seconds\n    end\n    wait until <(timer) > [8]>\n    delete this clone\nend\nif <(Clone ID) = [Chevron]> then\n    set [val2 v] to [50]\n    point in direction (90)\n    go to [front v] layer\n    go [backward v] (4) layers\n    set size to (0) %\n    go to x: (0) y: (0)\n    show\n    switch costume to (chevron2 v)\n    repeat until <(size) > [100]>\n        change size by (val2)\n        change [val2 v] by (((50) - (val2)) / (5))\n    end\n    repeat until <(size) > [2500]>\n        switch costume to (hack v)\n        change size by (val2)\n        change [val2 v] by (((80) - (val2)) / (5))\n        switch costume to (chevron2 v)\n    end\n    delete this clone\nend\nif <(Clone ID) = [8]> then\n    wait until <(timer) > [3]>\n    point in direction (90)\n    go to [front v] layer\n    go to x: (0) y: (0)\n    show\n    switch costume to (name v)\n    set size to (0) %\n    point in direction (-90)\n    wait until <(timer) > [3]>\n    repeat (2)\n        set [var1 v] to [1]\n        repeat (20)\n            go to [front v] layer\n            turn right (var1) degrees\n            change [var1 v] by ((var1) / (5))\n        end\n        set [var1 v] to [1]\n        repeat (80)\n            turn right (((90) - (direction)) / (8)) degrees\n        end\n        wait (1) seconds\n    end\n    wait until <(timer) > [8]>\n    delete this clone\nend\n\nwhen I start as a clone\nif <(Clone ID) = [Chevron]> then\n    forever\n        go to x: (item (1) of [cams v]) y: (item (2) of [cams v])\n        point in direction (item (3) of [cams v])\n    end\nend\n\nwhen flag clicked\nwait (2) seconds\nstart sound [Meric - Take Off v]\nwait until <(timer) > [3]>\nrepeat (30)\n    set [clone id v] to [bg chev]\n    create clone of (_myself_ v)\n    set [clone id v] to [Chevron]\n    create clone of (_myself_ v)\n    wait (0.2) seconds\nend\n\ndefine Shake2 X (x) Y (y) Size (size) repeat (#)\nshow\ngo to x: ((([sin v] of ((timer) * (1000)) ) * (((100) - (size)) / (2))) + (x)) y: ((([cos v] of ((timer) * (800)) ) * (((100) - (size)) / (2))) + (y))\nset size to (size) %\nrepeat (#)\n    go to [front v] layer\n    change size by (((100) - (size)) / (8))\n    replace item (3) of [cams v] with (direction)\n    go to x: ((([sin v] of ((timer) * (1000)) ) * (((100) - (size)) / (2))) + (x)) y: ((([cos v] of ((timer) * (800)) ) * (((100) - (size)) / (2))) + (y))\n    replace item (1) of [cams v] with (x position)\n    replace item (2) of [cams v] with (y position)\nend\n\nwhen flag clicked\nswitch costume to (circle v)\nreset timer\nset [clone id v] to [0]\nhide\nclear graphic effects\nrepeat (30)\n    create clone of (_myself_ v)\n    change [clone id v] by (1)\nend\nwait until <(timer) > [2]>\n\nwhen I start as a clone\nif <(Clone ID) = [splines]> then\n    switch costume to (spline v)\n    set size to (120) %\n    go to [front v] layer\n    set [brightness v] effect to (-5)\n    set [ghost v] effect to (-20)\n    go to [front v] layer\n    point in direction (90)\n    go [backward v] (3) layers\n    go to x: (250) y: (80)\n    show\n    repeat (40)\n        move (-7) steps\n        clear graphic effects\n    end\n    repeat (20)\n        move (-7) steps\n        turn right (-1) degrees\n        clear graphic effects\n    end\n    repeat (12)\n        move (-7) steps\n        turn right (-1) degrees\n        clear graphic effects\n    end\n    hide\n    delete this clone\nend\nif <(Clone ID) = [splines2]> then\n    switch costume to (spline v)\n    set size to (120) %\n    go to [front v] layer\n    set [brightness v] effect to (-5)\n    set [ghost v] effect to (-20)\n    point in direction (90)\n    go [backward v] (3) layers\n    go to x: (-250) y: (-80)\n    show\n    repeat (40)\n        move (7) steps\n        clear graphic effects\n    end\n    repeat (20)\n        move (7) steps\n        turn right (-1) degrees\n        clear graphic effects\n    end\n    repeat (12)\n        move (7) steps\n        turn left (-1) degrees\n        clear graphic effects\n    end\n    hide\n    delete this clone\nend\n\nwhen flag clicked\nwait (3.3) seconds\nrepeat (10)\n    Clone [Splines]\n    Clone [Splines2]\n    wait (0) seconds\nend\n\ndefine Clone (id)\nset [clone id v] to (id)\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nwait (7.4) seconds\nClone [Spin]\n\nwhen I start as a clone\nif <(Clone ID) = [Spin]> then\n    clear graphic effects\n    set [brightness v] effect to (100)\n    go to x: (0) y: (0)\n    switch costume to (blank v)\n    set size to (140) %\n    switch costume to (spin1 v)\n    show\n    set [turn v] to [0]\n    repeat (6)\n        next costume\n        turn right (Turn) degrees\n        change [turn v] by (1.5)\n    end\n    repeat (12)\n        turn right (Turn) degrees\n        change [turn v] by (2)\n    end\n    repeat (15)\n        turn right (Turn) degrees\n        change [turn v] by (-2)\n    end\n    repeat (6)\n        turn right (6) degrees\n        switch costume to ((costume [number v]) - (1))\n        change [ghost v] effect by (15)\n    end\n    delete this clone\nend\n\nwhen I start as a clone\nif <(Clone ID) = [Spin]> then\n    forever\n        go to [front v] layer\n    end\nend\n\nwhen flag clicked\nwait (3) seconds\nClone [Pinwheel]\n\nwhen I start as a clone\nif <(Clone ID) = [splines]> then\n    forever\n        go to [front v] layer\n    end\nend\nif <(Clone ID) = [splines2]> then\n    forever\n        go to [front v] layer\n    end\nend\n\nwhen flag clicked\nwait (3) seconds\nrepeat (2)\n    wait (0.7) seconds\n    Dot explosion [0] [0] [0] [0] [320]\n    wait (2) seconds\nend\n\ndefine Dot explosion (x) (y) (c) (b) (s)\npoint in direction (90)\nset size to (s) %\ngo to x: (x) y: (y)\nset [color v] effect to (c)\nset [brightness v] effect to (b)\nset [clone id v] to [Dots]\nrepeat (20)\n    turn right (18) degrees\n    create clone of (_myself_ v)\nend\ngo to x: (0) y: (0)\nclear graphic effects\n\nwhen I start as a clone\nif <(Clone ID) = [Dots]> then\n    show\n    go to [front v] layer\n    turn right (90) degrees\n    switch costume to (dot v)\n    repeat (10)\n        go to [front v] layer\n        move (12) steps\n        change size by (((10) - (size)) / (5))\n        turn right (5) degrees\n        if <touching (_edge_ v)?> then\n            delete this clone\n        end\n    end\n    repeat (10)\n        go to [front v] layer\n        move (7) steps\n        change [ghost v] effect by (10)\n        change size by (((10) - (size)) / (5))\n        turn right (8) degrees\n        if <touching (_edge_ v)?> then\n            delete this clone\n        end\n    end\n    delete this clone\nend\n\nwhen flag clicked\nwait (10.5) seconds\nset [clone id v] to [Ending1]\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nif <(Clone ID) = [Ending1]> then\n    clear graphic effects\n    switch costume to (blank v)\n    set size to (1000) %\n    go to x: (1000) y: (-1000)\n    set size to (300) %\n    switch costume to (end v)\n    show\n    start sound [Slice v]\n    repeat (30)\n        go to [front v] layer\n        switch costume to (blank v)\n        set size to (1000) %\n        change x by (((-100) - (x position)) / (10))\n        change y by (((100) - (y position)) / (10))\n        set size to (300) %\n        switch costume to (end v)\n    end\n    repeat (100)\n        go to [front v] layer\n        switch costume to (blank v)\n        set size to (1000) %\n        change x by (((-100) - (x position)) / (10))\n        change y by (((100) - (y position)) / (10))\n        set size to (300) %\n        switch costume to (end v)\n    end\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\n    delete this clone\nend\n\nwhen flag clicked\nwait (4) seconds\nClone Arrows\nwait (3) seconds\nClone Arrows\n\nwhen I start as a clone\nif <(Clone ID) = [Arrows]> then\n    show\n    set [ghost v] effect to (0)\n    switch costume to (arrows v)\n    go to x: (0) y: (0)\n    point in direction ((direction) - (30))\n    go to [front v] layer\n    go [forward v] (4) layers\n    set size to (100) %\n    set [intro: velocity v] to [0]\n    repeat until <touching (_edge_ v)?>\n        change [intro: velocity v] by (1)\n        turn right (3) degrees\n        move (Intro: Velocity) steps\n    end\n    delete this clone\nend\n\ndefine Clone Arrows\nset [clone id v] to [Arrows]\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\nturn right (18) degrees\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nforever\n    hide\n    clear graphic effects\nend\n\nwhen I start as a clone\nif <(Clone ID) = [Arrows]> then\n    forever\n        \n            repeat (10)\n                go to [front v] layer\n            end\n        end\n    end\nend\n\ndefine Clone ID (id)\nwait () seconds\nset [clone id v] to (id)\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nReset\nClone ID [BG]\nwait until <[5] < (timer)>\nGhost Shockwave at: [-250] [-180]\nGhost Shockwave at: [250] [180]\nwait until <[6] < (timer)>\nGhost Shockwave at: [-250] [180]\nGhost Shockwave at: [250] [-180]\n\nwhen I start as a clone\nif <(Clone ID) = [Ghost SW]> then\n    show\n    clear graphic effects\n    set size to (0) %\n    go to [front v] layer\n    switch costume to (shockwave ghost v)\n    repeat (25)\n        show\n        go to [front v] layer\n        Size: [300] Speed: [5]\n        change [ghost v] effect by (4)\n    end\n    delete this clone\nend\n\ndefine Reset\nhide\nreset timer\nclear graphic effects\nset size to (100) %\ngo to [front v] layer\npoint in direction (90)\ngo to x: (0) y: (0)\nswitch costume to (username v)\nstart sound [Illenium - Let You Go \[@-Xaf- Remix\] v]\n\ndefine Size: (size) Speed: (speed)\nchange size by (((size) - (size)) / (speed))\n\ndefine Ghost Shockwave at: (x) (y)\ngo to x: (x) y: (y)\nClone ID [Ghost SW]\n\nwhen flag clicked\nwait (14) 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@Skip\n\n