Journey a platformer 3 The final battle

Instructions: The 3rd Journey game is here!\n\n1st https://scratch.mit.edu/projects/647287990\n\n2nd https://scratch.mit.edu/projects/647289740

@Stage\n\nwhen I receive [end intro v]\nswitch backdrop to (backdrop7 v)\nstop all sounds\nforever\n    play sound [recording1 v] until done\nend\n\nwhen flag clicked\nswitch backdrop to (backdrop1 v)\nplay sound [cool v] until done\n\nwhen I receive [next lv v]\nnext backdrop\n\n@BLANK\n\n@player\n\nwhen flag clicked\nhide\n\nset [playery v] to (y position)\n\nchange [xv v] by (1)\n\ndefine reset\ngo to x: (-195) y: (-92)\n\nwhen flag clicked\nforever\n    if <(x position) > [240]> then\n        broadcast (next lv v)\n        reset\n    else\n        if <<<touching (danger v)?> or <<touching (sprite2 v)?> and <<(ebeny 1 costume) = [1]> or <(ebeny 1 costume) = [3]>>>> or <<touching (sprite3 v)?> and <<(enemy 2 costume) = [1]> or <(enemy 2 costume) = [3]>>>> then\n            reset\n        else\n            if <<touching (sprite6 v)?> or <touching (sword2 v)?>> then\n                reset\n                broadcast (boss reset v)\n            end\n        end\n    end\nend\n\nbroadcast (pick up v)\n\n\n\nset y to (-91)\n\nshow\n\nchange [yv v] by (-1)\n\n\n\nif <(xv) > [0]> then\n    set [xv v] to [-10]\nelse\n    set [xv v] to [10]\nend\nset [yv v] to [12]\n\nwhen I receive [end intro v]\nshow\nset rotation style [left-right v]\nreset\nforever\n    change [yv v] by (-.5)\n    if <<key (left arrow v) pressed?> or <<(x position) > (mouse x)> and <mouse down?>>> then\n        point in direction (-90)\n        change [xv v] by (-.8)\n    end\n    if <<<(mouse x) > (x position)> and <mouse down?>> or <key (right arrow v) pressed?>> then\n        point in direction (90)\n        change [xv v] by (.8)\n    end\n    set [xv v] to ((xv) * (.9))\n    change x by (xv)\n    if <<touching (platforms v)?> or <touching color (#007e12)?>> then\n        change y by (1)\n        if <<touching (platforms v)?> or <touching color (#007e12)?>> then\n            change y by (1)\n            if <<touching (platforms v)?> or <touching color (#007e12)?>> then\n                change y by (1)\n                if <<touching (platforms v)?> or <touching color (#007e12)?>> then\n                    change y by (1)\n                    if <<touching (platforms v)?> or <touching color (#007e12)?>> then\n                        change y by (1)\n                        if <<touching (platforms v)?> or <touching color (#007e12)?>> then\n                            change y by (1)\n                            if <<touching (platforms v)?> or <touching color (#007e12)?>> then\n                                change y by (-6)\n                                change x by ((xv) * (-1))\n                            end\n                            if <<key (up arrow v) pressed?> or <<(mouse y) > (y position)> and <mouse down?>>> then\n                                set [yv v] to [9]\n                                if <(xv) > [0]> then\n                                    set [xv v] to [-10]\n                                else\n                                    set [xv v] to [10]\n                                end\n                            else\n                                set [xv v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    change y by (yv)\n    if <<touching (platforms v)?> or <touching color (#007e12)?>> then\n        change y by ((yv) * (-1))\n        set [yv v] to [0]\n    end\n    change y by (-.5)\n    if <<<touching (platforms v)?> or <touching color (#007e12)?>> and <<key (up arrow v) pressed?> or <<(mouse y) > (y position)> and <mouse down?>>>> then\n        set [yv v] to [10]\n    end\n    change y by (.5)\n    set [player direction v] to (direction)\n    set [playerx v] to (x position)\nend\n\nwhen backdrop switches to [backdrop12 v]\nswitch costume to (costume3 v)\n\nhide\n\nwhen backdrop switches to [backdrop4 v]\nswitch costume to (costume2 v)\n\nhide\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nwhen backdrop switches to [backdrop6 v]\nswitch costume to (costume3 v)\n\nwhen backdrop switches to [backdrop10 v]\nswitch costume to (costume4 v)\n\nwhen I receive [next lv v]\nreset\n\nwhen backdrop switches to [backdrop12 v]\nswitch costume to (costume3 v)\n\nwhen backdrop switches to [backdrop13 v]\nswitch costume to (costume2 v)\n\nwhen backdrop switches to [backdrop14 v]\nswitch costume to (costume1 v)\n\n@Thumbnail\n\nwhen flag clicked\nforever\n    go to x: (0) y: (0)\n    set [ghost v] effect to (100)\n    show\n    go to [front v] layer\n    set [distance to player v] to ((boss x) - (playerx))\nend\n\nbroadcast (no car v)\n\n@Sword\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nforever\n    if <(player direction) = [90]> then\n        go to (player v)\n    else\n        go to (player v)\n        change x by (-20)\n    end\n    if <(player direction) = [90]> then\n        if <(weapon) = [6]> then\n            switch costume to (knight2 v)\n        else\n            switch costume to (knight4 v)\n        end\n    else\n        if <(weapon) = [6]> then\n            switch costume to (knight3 v)\n        else\n            switch costume to (knight5 v)\n        end\n    end\nend\n\nwhen flag clicked\n\nturn left (30) degrees\n\npoint in direction (player direction)\n\n\n\nturn right (30) degrees\n\nwhen I receive [end intro v]\nforever\n    if <key (space v) pressed?> then\n        point in direction (0)\n        go to [front v] layer\n        go [backward v] (3) layers\n        show\n        repeat (weapon)\n            if <(player direction) = [90]> then\n                turn right (30) degrees\n            end\n            if <(player direction) = [-90]> then\n                turn right (30) degrees\n            end\n        end\n        hide\n        wait (.1) seconds\n    end\nend\n\nwhen [1 v] key pressed\nset [weapon v] to [6]\n\nwhen [2 v] key pressed\nset [weapon v] to [3]\n\nwhen flag clicked\nset [weapon v] to [6]\n\nwhen I receive [weapon v]\npoint in direction (0)\ngo to [front v] layer\ngo [backward v] (3) layers\nshow\nrepeat (weapon)\n    if <(player direction) = [90]> then\n        turn right (30) degrees\n    end\n    if <(player direction) = [-90]> then\n        turn right (30) degrees\n    end\nend\nhide\nwait (.1) seconds\n\nwhen I receive [next weapon v]\nif <(weapon) = [3]> then\n    set [weapon v] to [6]\nelse\n    set [weapon v] to [3]\nend\n\n@dialogue\n\nwhen flag clicked\nhide\n\nhide\n\nwait (.25) seconds\n\nswitch costume to (costume16 v)\nwait until <key (c v) pressed?>\n\nwhen I receive [end intro v]\ngo to [front v] layer\nshow\nswitch costume to (costume2 v)\nwait until <<mouse down?> or <key (c v) pressed?>>\nwait (.25) seconds\nswitch costume to (costume3 v)\nwait until <<key (c v) pressed?> or <mouse down?>>\nwait (.25) seconds\nbroadcast (first level v)\nhide\n\nwhen backdrop switches to [backdrop15 v]\ngo to [front v] layer\nshow\nswitch costume to (costume4 v)\nwait until <<key (c v) pressed?> or <mouse down?>>\nwait (.25) seconds\nswitch costume to (costume5 v)\nwait until <<key (c v) pressed?> or <mouse down?>>\nwait (.25) seconds\nhide\n\nbroadcast (first level v)\n\n@platforms\n\nwhen flag clicked\nswitch costume to (costume1 v)\nhide\n\nwhen I receive [end intro v]\nshow\n\nwhen I receive [next lv v]\nnext costume\n\n@intro\n\nwhen flag clicked\nshow\nswitch costume to (costume1 v)\npoint in direction (90)\nrepeat (6)\n    repeat (20)\n        turn right (18) degrees\n    end\n    repeat (5)\n        change size by (10)\n    end\n    repeat (5)\n        change size by (-10)\n    end\nend\nbroadcast (end intro v)\n\nbroadcast (end intro v)\n\nwhen I receive [end intro v]\nhide\n\nwhen I receive [next lv v]\nchange [level v] by (1)\n\n@danger\n\nwhen flag clicked\nswitch costume to (costume1 v)\ngo to [front v] layer\nhide\n\nwhen I receive [end intro v]\nshow\n\nwhen I receive [next lv v]\nchange [level!?!?!?!?!???! v] by (1)\nnext costume\n\n@Sprite1\n\nwhen flag clicked\nswitch costume to (costume1 v)\nhide\nforever\n    go to (player v)\nend\n\nwhen I receive [end intro v]\nshow\n\nwhen backdrop switches to [backdrop4 v]\nswitch costume to (costume2 v)\n\nwhen backdrop switches to [backdrop6 v]\nswitch costume to (costume3 v)\n\nwhen backdrop switches to [backdrop10 v]\nswitch costume to (costume4 v)\n\nwhen backdrop switches to [backdrop12 v]\nswitch costume to (costume3 v)\n\nwhen backdrop switches to [backdrop13 v]\nswitch costume to (costume2 v)\n\nwhen backdrop switches to [backdrop14 v]\nswitch costume to (costume1 v)\n\n@Sprite2\n\nwhen flag clicked\nset rotation style [left-right v]\nset [level v] to [1]\nhide\nforever\n    if <touching (sword v)?> then\n        broadcast (particles v)\n        wait (1) seconds\n    end\n    set [ebeny 1 costume v] to (costume [number v])\nend\n\nwhen flag clicked\n\nwhen backdrop switches to [backdrop2 v]\npoint in direction (-90)\nshow\ngo to x: (0) y: (-30)\nswitch costume to (costume1 v)\nattack 1\n\ndefine attack 1\nrepeat until <(level) = [3]>\n    point in direction (-90)\n    glide (.5) secs to x: (-40) y: (-30)\n    point in direction (90)\n    glide (.5) secs to x: (0) y: (-30)\nend\n\nwhen I receive [particles v]\nhide\nswitch costume to (costume2 v)\nset [ebeny 1 costume v] to [2]\nrepeat (15)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nshow\nswitch costume to (costume2 v)\nchange x by (pick random (-10) to (30))\nchange y by (pick random (-10) to (30))\nwait (pick random (.1) to (.5)) seconds\ndelete this clone\n\npoint in direction (90)\n\nwhen backdrop switches to [backdrop3 v]\npoint in direction (-90)\nshow\ngo to x: (50) y: (-30)\nswitch costume to (costume1 v)\nattack 2\n\nattack 1\n\ndefine attack 2\nrepeat until <(level) = [4]>\n    point in direction (-90)\n    glide (1) secs to x: (-25) y: (-30)\n    point in direction (90)\n    glide (1) secs to x: (50) y: (-30)\nend\n\nattack 2\n\ndefine attack 4\nrepeat until <(level) > [5]>\n    point in direction (-90)\n    glide (1) secs to x: (25) y: (-30)\n    point in direction (90)\n    glide (1) secs to x: (100) y: (-30)\nend\n\nwhen backdrop switches to [backdrop4 v]\npoint in direction (-90)\nshow\ngo to x: (100) y: (-30)\nswitch costume to (costume1 v)\nattack 4\n\nwhen backdrop switches to [backdrop5 v]\nhide\n\npoint in direction (-90)\nshow\ngo to x: (100) y: (-30)\nswitch costume to (costume1 v)\nattack 4\n\ndefine coolll\nrepeat until <(level) > [9]>\n    point in direction (-90)\n    glide (1) secs to x: (60) y: (-100)\n    point in direction (90)\n    glide (1) secs to x: (125) y: (-100)\nend\n\nwhen backdrop switches to [backdrop9 v]\npoint in direction (-90)\nshow\ngo to x: (125) y: (-100)\nswitch costume to (costume1 v)\ncoolll\n\nattack 4\n\nwhen backdrop switches to [backdrop10 v]\nhide\n\nwhen backdrop switches to [backdrop11 v]\npoint in direction (-90)\nshow\ngo to x: (45) y: (100)\nswitch costume to (costume1 v)\nnice\n\ncoolll\n\ndefine nice\nrepeat until <(level) > [11]>\n    point in direction (-90)\n    glide (1) secs to x: (-25) y: (100)\n    point in direction (90)\n    glide (1) secs to x: (45) y: (100)\nend\n\npoint in direction (-90)\nglide (1) secs to x: (60) y: (-100)\npoint in direction (90)\nglide (1) secs to x: (125) y: (-100)\nhide\n\nwhen backdrop switches to [backdrop12 v]\npoint in direction (-90)\nshow\ngo to x: (45) y: (-98)\nswitch costume to (costume1 v)\nbest\n\nnice\n\ndefine best\nrepeat until <(level) = [13]>\n    point in direction (-90)\n    glide (1) secs to x: (50) y: (-98)\n    point in direction (90)\n    glide (1) secs to x: (125) y: (-98)\nend\n\nwhen I receive [next lv v]\nhide\n\n@Sprite3\n\nwhen flag clicked\nhide\n\nwhen I receive [first level v]\nshow\nforever\n    point in direction ((([cos v] of ((timer) * (180)) ) * (15)) + (90))\nend\n\nwhen this sprite clicked\nbroadcast (next lv v)\n\n@Sprite4\n\nwhen flag clicked\nhide\n\nwhen I receive [first level v]\nshow\nforever\n    point in direction ((([cos v] of ((timer) * (180)) ) * (15)) + (90))\nend\n\nwhen this sprite clicked\nbroadcast (weapon v)\n\n@Sprite5\n\nwhen flag clicked\nhide\n\nwhen I receive [first level v]\nshow\nforever\n    point in direction ((([cos v] of ((timer) * (180)) ) * (15)) + (90))\nend\n\nwhen this sprite clicked\nbroadcast (next weapon v)\n\n@Sprite6\n\nwhen backdrop switches to [backdrop15 v]\nset [boss hp v] to [20]\ngo to x: (50) y: (-50)\nset rotation style [left-right v]\nshow\nboss attack!\n\ndefine boss attack!\nforever\n    if <touching (sword v)?> then\n        broadcast (boss reset v)\n        change [boss hp v] by (-1)\n        wait (.25) seconds\n    end\n    if <touching (platforms v)?> then\n        set [bossyv v] to [12]\n    end\n    set [boss xv v] to [10]\nend\n\npoint towards (player v)\nmove (5) steps\nchange y by (1)\n\nboss attack!\n\nwhen I receive [boss reset v]\ngo to x: (50) y: (-50)\nshow\n\nglide (1) secs to (player v)\n\nwhen flag clicked\nhide\n\nchange [bossyv v] by (1)\n\nwhen flag clicked\nset [bossyv v] to [0]\nforever\n    if <[0] > (xv)> then\n        change x by (xv)\n    end\n    change y by (bossyv)\n    set [boss x v] to (x position)\n    if <not <touching (platforms v)?>> then\n        change [bossyv v] by (-1)\n    end\n    if <[1] > (boss hp)> then\n        hide\n    end\nend\n\nrepeat until \nend\n\nchange [bossyv v] by (-1)\n\nset x to (playerx)\n\n@Sword2\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nforever\n    \n        go to (sprite6 v)\n    else\n        go to (sprite6 v)\n        change x by (-20)\n    end\n    if <(player direction) = [90]> then\n        if <(weapon) = [6]> then\n            switch costume to (knight2 v)\n        else\n            switch costume to (knight4 v)\n        end\n    else\n        if <(weapon) = [6]> then\n            switch costume to (knight3 v)\n        else\n            switch costume to (knight5 v)\n        end\n    end\nend\n\nwhen flag clicked\n\nturn left (30) degrees\n\npoint in direction (player direction)\n\n\n\nturn right (30) degrees\n\nwhen I receive [end intro v]\n\nwhen backdrop switches to [backdrop15 v]\nwait (.25) seconds\nrepeat until <[1] > (boss hp)>\n    wait (pick random (1) to (3)) seconds\n    point in direction (0)\n    go to [front v] layer\n    go [backward v] (3) layers\n    show\n    repeat (6)\n        turn right (30) degrees\n    end\n    hide\n    wait (.1) seconds\nend\n\n\n\nforever\n\n\n\n    turn right (30) degrees\nend\n\n@Sprite7\n\nwhen backdrop switches to [backdrop16 v]\ngo to [front v] layer\nshow\n\nwhen flag clicked\nhide\n\n