Blue's Escape - a platformer

Instructions: This is the sequel to Searching for Blue. If you haven't already played Searching for Blue, I suggest you do so - it will make things a lot clearer! It can be found here: https://scratch.mit.edu/projects/362568623\n\nIn this platformer, Mum has just found Blue - and a mysterious letter claiming that the writer is able to heal Vanishing Disease - when the wolves find them. They are imprisoned, but Blue manages to escape and start on a dangerous quest through Shadow Forest to find the cure for Vanishing Disease.\n\nPrevious platformer: It was just an ordinary day for the Blue family. That was until Dad disappeared, having caught Vanishing Disease, and Blue ran off into the dangerous Shadow Forest. Mum had to find him, leaving her other child at home, before anything happened to him as well.\n\nSpace to skip the story at the beginning, M to mute the music.

@Stage\n\nwhen [m v] key pressed\nif <(music) = [1]> then\n    set [music v] to [0]\n    stop all sounds\nelse\n    broadcast (music v)\nend\n\nwhen I receive [music v]\nset [music v] to [1]\nrepeat until <(music) = [0]>\n    play sound [Grieg ~ In the Hall of the Mountain King v] until done\nend\n\nwhen [m v] key pressed\nif <(username) = [AnnaHannah]> then\n    set [mouse v] to (join ((mouse x) + (SCROLL X)) (join [, ] ((mouse y) + (SCROLL Y))))\n    show variable [mouse v]\nend\n\n@Player\n\nwhen flag clicked\nbroadcast (Green Flag v) and wait\nbroadcast (Play Game v) and wait\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\ngo [backward v] (1) layers\n\nwhen I receive [play game v]\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 [x v] to [0]\nset [y v] to [0]\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nset [sy v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nset size to (100) %\nset [ghost v] effect to (0)\nshow\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)?>>\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 Tick\nif <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n    Change Player x by [-8]\nend\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    Change Player x by [8]\nend\nif <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n    if <(in air) < [4]> then\n        set [sy v] to [16]\n    end\nend\nchange [sy v] by (-2)\nChange Player y by (sy)\nTest - Die\nset [scroll x v] to (x)\nif <(SCROLL X) < [0]> then\n    set [scroll x v] to [0]\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\n\ndefine Change Player x by (sx)\nchange [x v] by (sx)\nPosition\nif <touching (platforms v)?> then\n    repeat (12)\n        change [y v] by (1)\n        Position\n        if <not <touching (platforms v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    repeat until <not <touching (platforms 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\nstart sound [Cymbal v]\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\n\ndefine Test - Die\nif <touching (danger v)?> then\n    set [exit v] to [die]\nend\n\ndefine Game - Win\nrepeat (50)\n    point towards (exit v)\n    turn right (65) degrees\n    move ((distance to [exit v]) / (2)) steps\n    change size by (-1)\n    change [ghost v] effect by (2)\nend\nhide\nchange [level v] by (1)\nwait (1) seconds\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 (level 1.1 v)\n    Clone at x: [360] y: [0]\n    Clone at x: [-360] y: [300]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2.1 v)\n        Clone at x: [500] y: [50]\n        Clone at x: [500] y: [0]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (level 3.1 v)\n            Clone at x: [500] y: [0]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (level 4.1 v)\n                Clone at x: [360] y: [0]\n                Clone at x: [350] y: [300]\n            else\n                if <(LEVEL) = [5]> then\n                    switch costume to (level 5.1 v)\n                    Clone at x: [550 ] y: [0]\n                    Clone at x: [0] y: [400]\n                else\n                    switch costume to (level 6 v)\n                end\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)\nnext costume\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]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1.1 v)\n    Clone at x: [360] y: [0]\n    Clone at x: [-360] y: [300]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2.1 v)\n        Clone at x: [500] y: [50]\n        Clone at x: [500] y: [0]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (level 3.1 v)\n            Clone at x: [500] y: [0]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (level 4.1 v)\n                Clone at x: [360] y: [0]\n                Clone at x: [350] y: [300]\n            else\n                if <(LEVEL) = [5]> then\n                    switch costume to (level 5.1 v)\n                    Clone at x: [550 ] y: [0]\n                    Clone at x: [0] y: [400]\n                else\n                    switch costume to (level 6 v)\n                end\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)\nnext costume\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 <<(costume [name v]) = [open]> and <touching (player v)?>> then\n    set [exit v] to [win]\nend\n\nwhen I receive [setup v]\nhide\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (closed v)\n    Clone at x: [280] y: [325]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (closed v)\n        Clone at x: [1240] y: [315]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (closed v)\n            Clone at x: [715] y: [260]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (closed v)\n                Clone at x: [-200] y: [270]\n            else\n                if <(LEVEL) = [5]> then\n                    switch costume to (closed v)\n                    Clone at x: [550] y: [500]\n                else\n                    go to x: (9999999) y: (9999999)\n                    Clone at x: [-999999999] y: [9999999]\n                    hide\n                end\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)\n\nwhen I receive [open portal v]\nswitch costume to (open v)\n\nClone at x: [-360] y: [300]\n\n@Collectibles\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    start sound [coin v]\n    change [collected v] by (1)\n    if <(COLLECTED) = (COLLECTED MAX)> then\n        start sound [1 v]\n        broadcast (Open Portal v)\n    end\n    delete this clone\nend\n\nwhen I receive [setup v]\nhide\nset [collected v] to [0]\nset [collected max v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (costume v)\n    Clone at x: [-100] y: [10]\n    Clone at x: [365] y: [-85]\n    Clone at x: [-230] y: [360]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (costume v)\n        Clone at x: [-175] y: [87]\n        Clone at x: [-235] y: [160]\n        Clone at x: [690] y: [0]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (costume v)\n            Clone at x: [570] y: [90]\n            Clone at x: [180] y: [-150]\n            Clone at x: [-140] y: [200]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (costume v)\n                Clone at x: [-95] y: [-95]\n                Clone at x: [930] y: [225]\n                Clone at x: [-105] y: [185]\n            else\n                if <(LEVEL) = [5]> then\n                    switch costume to (costume v)\n                    Clone at x: [-140] y: [-150]\n                    Clone at x: [-50] y: [260]\n                    Clone at x: [-235] y: [410]\n                end\n            end\n        end\n    end\nend\nset [x v] to [9999999999]\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)\nchange [collected max v] by (1)\ncreate clone of (_myself_ v)\n\n@Story\n\nwhen flag clicked\ngo to x: (0) y: (0)\nshow\n\nwhen flag clicked\nforever\n    if <(LEVEL) < [6]> then\n        if <key (space v) pressed?> then\n            stop [other scripts in sprite v]\n            hide\n            broadcast (flag v)\n            broadcast (music v)\n        end\n    end\nend\n\nwhen flag clicked\nshow\ngo to [front v] layer\nswitch costume to (1.1 v)\nrepeat (11)\n    wait (3.5) seconds\n    next costume\nend\nwait (1) seconds\nwait (3) seconds\nhide\nbroadcast (music v)\n\nwhen I receive [tick v]\nif <(LEVEL) = [6]> then\n    show\n    switch costume to (ending v)\n    start sound [Wolf Howl v]\n    wait (3.5) seconds\n    switch costume to (ending2 v)\n    wait (3.5) seconds\n    switch costume to (ending3 v)\n    wait (5) seconds\nend\n\nwhen flag clicked\nwait (19) seconds\nplay sound [Wolf Howl v] until done\n\n@thumbnail\n\nwhen flag clicked\nhide\nhide variable [mouse v]\n\ngo to [front v] layer\nshow\nhide variable [mouse v]\n\n