Legend of Zelda Platformer! (WIP)

Instructions: This is a work in progress. :)\n\nUse arrow keys to move & jump; press space to swing your sword.\n\nUpdates:\n5/2 - Fixed mid-air sword glitch! Although in exchange of a strange, but a lot less noticeable glitch, where Link can sometimes transport up above a ceiling when he jumps and swings his sword at the same time. If anyone knows how to fix this, please suggest any advice!\n\n4/8 - @Burnout5858 made some AMAZING scripts that get rid of the need to have multiple bokoblin and heart sprites! Shoutout to @Burnout5858!!!\n\n4/4 - Added BOKOBLIN ENEMIES! Programmed all by ourselves! + \nAdded HEART METER! + Added cave music + Added one more cave backdrop.\n\n4/4 - Making the rocks so that you can step on them, + added falling spazz.\n\n4/3 - FINALLY got the background count script working!!! Added 4 backgrounds...\n\n4/3 - Added more code, added sprite animation + jumping. Added walking on grass sound effect, added Link's grunts sound effects, spiced up background. Added ability to swing sword.\n\n4/2 - Created project, added Link with basic code, + basic platform obstacles.

@Stage\n\nwhen flag clicked\nset [switched? v] to [0]\nswitch backdrop to (l1 v)\n\nwhen I receive [next v]\nnext backdrop\nwait (0.3) seconds\n\nwhen I receive [overworld v]\nstop all sounds\nstart sound [Zelda Theme v]\n\nwhen I receive [cave v]\nstop all sounds\nstart sound [Cave v]\n\nwhen I receive [forest v]\nstop all sounds\nstart sound [Faron Woods v]\n\n@Link\n\ndefine Set costume\nif <(sword) = [0]> then\n    if <(falling?) < [3]> then\n        if <(frame) = [0]> then\n            switch costume to (1 v)\n        else\n            switch costume to ([floor v] of ((1) + ((frame) mod (7))) )\n        end\n    else\n        if <(velocity) > [0]> then\n            switch costume to (jumping v)\n        else\n            switch costume to (falling v)\n        end\n    end\nend\n\ndefine Touch Ground <>\nchange [falling? v] by (1)\nrepeat until <not <touching (platform 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 [velocity v] to [0]\nend\n\ndefine None\nchange [frame v] by (0.5)\npoint in direction (direction)\nchange x by (speed)\nset [slope v] to [0]\nrepeat until <<(slope) = [8]> or <not <touching (platform 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\n\ndefine Level\nset [switched? v] to [1]\nif <(level) = [1]> then\n    set [x v] to [-65]\n    set [y v] to [208]\n    broadcast (ghost0 v)\n    broadcast (reset v)\nelse\n    if <(level) = [2]> then\n        set [x v] to [-202]\n        set [y v] to [-98]\n        broadcast (ghost0 v)\n        broadcast (reset v)\n    else\n        if <(level) = [3]> then\n            set [x v] to [-208]\n            set [y v] to [-67]\n            broadcast (ghost0 v)\n            broadcast (reset v)\n        else\n            if <(level) = [4]> then\n                set [x v] to [-59]\n                set [y v] to [124]\n                broadcast (ghost100 v)\n                broadcast (reset v)\n                broadcast (CAVE v)\n            else\n                if <(level) = [5]> then\n                    set [x v] to [-207]\n                    set [y v] to [-79]\n                    broadcast (ghost100 v)\n                    broadcast (reset v)\n                else\n                end\n            end\n        end\n    end\nend\nset [switched? v] to [0]\n\nwhen I receive [reset v]\nset [lrecovered? v] to [1]\ngo to [front v] layer\ngo to x: (x) y: (y)\nshow\nset size to (55) %\nset [sword v] to [0]\nset [velocity v] to [0]\nset [sound v] to [0]\npoint in direction (90)\nset rotation style [left-right v]\nforever\n    change [velocity v] by (-1)\n    change y by (velocity)\n    if <(sword) = [0]> then\n        switch costume to (hitbox v)\n    end\n    Touch Ground <(velocity) > [0]>\n    if <(sword) = [0]> then\n        if <key (left arrow v) pressed?> then\n            set [pressing? v] to [1]\n            Walk (-90) (-6)\n            if <(sound) = [0]> then\n                broadcast (walk v)\n            end\n        else\n            if <key (right arrow v) pressed?> then\n                set [pressing? v] to [1]\n                Walk (90) (6)\n                if <(sound) = [0]> then\n                    broadcast (walk v)\n                end\n            else\n                set [frame v] to [0]\n            end\n        end\n        if <key (space v) pressed?> then\n            broadcast (swing v)\n        end\n        if <(x position) > [240]> then\n            if <(switched?) = [0]> then\n                change [level v] by (1)\n                broadcast (next v)\n                Level\n            end\n        end\n        if <(y position) < [-195]> then\n            hide\n            stop all sounds\n            start sound [AAAAAAAAHHH! v]\n            switch backdrop to (\(darkness\) v)\n            switch costume to (falling v)\n            show\n            go to x: (0) y: (0)\n            broadcast (falling v)\n            forever\n                go to x: (pick random (1) to (10)) y: (pick random (1) to (10))\n            end\n        end\n        if <(sword) = [0]> then\n            Set costume\n        end\n    end\nend\n\nwhen I receive [walk v]\nset [sound v] to [1]\nif <([costume # v] of [platform v]) < [4]> then\n    play sound (pick random (1) to (3)) until done\nelse\n    play sound (pick random (9) to (10)) until done\nend\nwait (0.01) seconds\nset [sound v] to [0]\n\nwhen [up arrow v] key pressed\nif <<(falling?) < [3]> and <(sword) = [0]>> then\n    set [velocity v] to [12]\n    play sound (pick random (4) to (6)) until done\nend\n\nwhen I receive [recoverlink v]\nset [lrecovered? v] to [0]\nwait (1) seconds\nset [lrecovered? v] to [1]\n\nwhen flag clicked\nset [reovered? v] to [1]\nset [switched? v] to [0]\nset [level v] to [1]\nset [x v] to [-65]\nset [y v] to [208]\nbroadcast (reset v)\nbroadcast (OVERWORLD v)\n\nwhen I receive [hit link v]\nif <touching color (#7f7f7f)?> then\n    if <(Lrecovered?) = [1]> then\n        start sound (pick random (11) to (13))\n        set [hp change v] to [1]\n        broadcast (decrease hp v)\n        broadcast (recoverLink v)\n        if <(direction) = (Bdirection)> then\n            move (-35) steps\n        else\n            move (35) steps\n        end\n    end\nend\n\nwhen I receive [swing v]\nif <<(falling?) > [6]> or <(falling?) = [0]>> then\n    set [sword v] to [1]\n    switch costume to (0 v)\n    repeat (3)\n        next costume\n    end\n    start sound (pick random (6) to (7))\n    repeat (6)\n        next costume\n    end\n    wait (0.2) seconds\n    repeat (5)\n        next costume\n    end\n    set [sword v] to [0]\nend\n\n@Platform\n\nwhen flag clicked\nshow\nswitch costume to (1 v)\nset [ghost v] effect to (0)\n\nwhen I receive [next v]\nswitch costume to (level)\n\nwhen I receive [ghost100 v]\nset [ghost v] effect to (100)\n\nwhen I receive [falling v]\nhide\n\nwhen I receive [ghost0 v]\nset [ghost v] effect to (0)\n\n@Bokoblin\n\nwhen flag clicked\nhide\nwait (0.1) seconds\nwait until <(level) = [2]>\nSpawnEnemy (182) (-121) (100)\nSpawnEnemy (100) (-125) (100)\nwait until <(level) = [4]>\nSpawnEnemy (160) (-97) (100)\nwait until <(level) = [5]>\nSpawnEnemy (5) (-105) (100)\nSpawnEnemy (187) (-103) (100)\n\nwhen I receive [next v]\ndelete this clone\n\ndefine HitLink\nif <<(Lrecovered?) = [1]> and <<touching (link v)?> and <<(costume [number v]) > [25]> and <(costume [number v]) < [30]>>>> then\n    set [bdirection v] to (direction)\n    broadcast (hit Link v)\nend\n\ndefine Set costume\nif <(frame) = [0]> then\n    switch costume to (0 v)\nelse\n    switch costume to ([floor v] of ((3) + ((frame) mod (4))) )\nend\n\ndefine None\nchange [frame v] by (0.5)\npoint in direction (direction)\nchange x by (speed)\nset [slope v] to [0]\nrepeat until <<(slope) = [8]> or <not <touching (platform 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\n\ndefine Touch Ground <>\nchange [falling? v] by (1)\nrepeat until <not <touching (platform 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 [velocity v] to [0]\nend\n\nwhen I start as a clone\nforever\n    HitLink\nend\n\nwhen I start as a clone\nset [bdirection v] to [0]\nset [health v] to [1]\nset [frame v] to [0]\nset [velocity v] to [0]\nshow\nset rotation style [left-right v]\npoint in direction (90)\nforever\n    change [velocity v] by (-1)\n    change y by (velocity)\n    switch costume to (hitbox v)\n    Touch Ground <(velocity) > [0]>\n    if <((x position) - ([x position v] of [link v])) > [0]> then\n        point in direction (90)\n    else\n        point in direction (-90)\n    end\n    if <(direction) = [90]> then\n        if <<((x position) - ([x position v] of [link v])) < [275]> and <(([y position v] of [link v]) - (y position)) < [80]>> then\n            Walk (90) (-1)\n        else\n            set [frame v] to [0]\n        end\n    else\n        if <<(([x position v] of [link v]) - (x position)) < [275]> and <(([y position v] of [link v]) - (y position)) < [80]>> then\n            Walk (-90) (1)\n        else\n            set [frame v] to [0]\n        end\n    end\n    if <<([direction v] of [link v]) = (direction)> and <<(sword) = [1]> and <<touching (link v)?> and <<touching color (#393939)?> and <<([costume # v] of [link v]) > [16]> and <([costume # v] of [link v]) < [22]>>>>>> then\n        if <(health) > [0]> then\n            start sound (pick random (1) to (2))\n            change [health v] by (-1)\n            move (35) steps\n            broadcast (recover v)\n        else\n            if <(Brecovered?) = [1]> then\n                start sound [recording3 v]\n                set [alive? v] to [0]\n                switch costume to (5 v)\n                repeat (17)\n                    wait (0.01) seconds\n                    next costume\n                end\n                hide\n                stop [other scripts in sprite v]\n                delete this clone\n            end\n        end\n    end\n    Set costume\n    if <(direction) = [90]> then\n        if <(([x position v] of [link v]) - (x position)) > [-49]> then\n            switch costume to (23 v)\n            start sound [recording1 v]\n            repeat (2)\n                wait (0.01) seconds\n                next costume\n            end\n            wait (0.1) seconds\n            repeat (3)\n                wait (0.01) seconds\n                next costume\n            end\n        end\n    else\n        if <((x position) - ([x position v] of [link v])) > [-49]> then\n            switch costume to (23 v)\n            start sound [recording1 v]\n            repeat (2)\n                wait (0.01) seconds\n                next costume\n            end\n            wait (0.1) seconds\n            repeat (3)\n                wait (0.01) seconds\n                next costume\n            end\n        end\n    end\nend\n\ndefine None\ngo to x: (x) y: (y)\nset size to (100) %\ncreate clone of (_myself_ v)\nhide\n\nwhen I receive [brecover v]\nset [brecovered? v] to [0]\nwait (0.7) seconds\nset [brecovered? v] to [1]\n\n@Heart Life :)\n\nwhen flag clicked\ngo to x: (0) y: (0)\nswitch costume to (costume2 v)\n\nwhen I receive [decrease hp v]\nrepeat (hp change)\n    switch costume to ((costume [number v]) + (1))\nend\n\nwhen I receive [increase hp v]\nstart sound [recording1 v]\nrepeat (hp change)\n    switch costume to ((costume [number v]) - (1))\n    if <(costume [number v]) = [12]> then\n        switch costume to (costume2 v)\n    end\nend\n\n@Heart\n\nwhen flag clicked\nhide\ngo to x: (0) y: (0)\nswitch costume to (costume2 v)\nwait (0.1) seconds\nwait until <(level) = [3]>\nCreateHeart (78) (111)\nwait until <(level) = [5]>\nCreateHeart (-94) (-107)\nCreateHeart (93) (-116)\n\ndefine None\ngo to x: (x) y: (y)\nshow\ncreate clone of (_myself_ v)\nhide\n\nwhen I receive [next v]\ndelete this clone\n\nwhen I start as a clone\nshow\nforever\n    if <touching (link v)?> then\n        set [hp change v] to [4]\n        broadcast (increase hp v)\n        hide\n        delete this clone\n    end\nend\n\n