Jail Break Platformer

Instructions: WASD/ arrow keys to move.\nAvoid dangers.\nThere is a bug where you die when jumping on the door to open it. If you know how to fix it please tell me.\nThe game has 15 levels and a boss room.\nFor the boss room, collect the key and touch the gate to open it. If you die, you lose your key.

@Stage\n\nwhen flag clicked\nforever\n    if <(level) = [16]> then\n        switch backdrop to (backdrop2 v)\n    else\n        switch backdrop to (backdrop1 v)\n    end\nend\n\n@Character\n\nwhen flag clicked\nset [level v] to [1]\nhide variable [level v]\nhide variable [lock v]\nhide variable [speed x v]\nhide variable [speed y v]\ngo to x: (-180) y: (-120)\nswitch costume to (apple v)\nshow\nforever\n    if <not <(level) = [15]>> then\n        if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n            change [speed x v] by (1.5)\n            switch costume to (apple v)\n        end\n        if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n            change [speed x v] by (-1.5)\n            switch costume to (apple2 v)\n        end\n        change x by (speed x)\n        if <<touching (platform v)?> or <touching color (#808080)?>> then\n            set [speed x v] to [0]\n        else\n            set [speed x v] to ((speed x) * (0.8))\n        end\n        change y by (speed y)\n        if <touching (platform v)?> then\n            change y by ((speed y) * (-1))\n            set [speed y v] to [0]\n            if <(lock) = [0]> then\n                if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                    set [speed y v] to [12]\n                    set [lock v] to [1]\n                end\n            end\n        else\n            change [speed y v] by (-1)\n            set [lock v] to [0]\n        end\n    else\n        if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n            change [speed x v] by (1.5)\n            switch costume to (apple v)\n        end\n        if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n            change [speed x v] by (-1.5)\n            switch costume to (apple2 v)\n        end\n        change x by (speed x)\n        if <<<touching (platform v)?> or <touching color (#808080)?>> or <touching (gate v)?>> then\n            change x by ((speed x) * (-1))\n            set [speed x v] to [0]\n        else\n            set [speed x v] to ((speed x) * (0.8))\n        end\n        change y by (speed y)\n        if <touching (platform v)?> then\n            change y by ((speed y) * (-1))\n            set [speed y v] to [0]\n            if <(lock) = [0]> then\n                if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                    set [speed y v] to [15]\n                    set [lock v] to [1]\n                end\n            end\n        else\n            change [speed y v] by (-1)\n            set [lock v] to [0]\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (door v)?> then\n        wait (0.1) seconds\n        change [level v] by (1)\n        broadcast (new level v)\n        go to x: (-180) y: (-120)\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching color (#ff0000)?> then\n        go to x: (-180) y: (-120)\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (bullet v)?> then\n        go to x: (-180) y: (-120)\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching color (#737373)?> then\n        go to x: (-180) y: (-120)\n        broadcast (new level v)\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching color (#0035ff)?> then\n        go to x: (-180) y: (-120)\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (bullet2 v)?> then\n        go to x: (-180) y: (-120)\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (bullet3 v)?> then\n        go to x: (-180) y: (-120)\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching color (#565656)?> then\n        go to x: (-180) y: (-120)\n        broadcast (new level v)\n    end\nend\n\n@Platform\n\nwhen flag clicked\ngo to x: (0) y: (0)\nshow\n\nwhen flag clicked\nforever\n    if <(level) = [15]> then\n        switch costume to (apple2 v)\n    else\n        if <(level) = [16]> then\n            switch costume to (apple3 v)\n        else\n            switch costume to (apple v)\n        end\n    end\nend\n\n@Door\n\nwhen flag clicked\ngo to x: (0) y: (0)\nshow\nforever\n    if <(level) = [16]> then\n        hide\n    else\n        show\n    end\nend\n\n@Laser\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nforever\n    next costume\n    wait (1) seconds\nend\n\nwhen flag clicked\nforever\n    if <(level) = [2]> then\n        show\n    else\n        hide\n    end\nend\n\n@Laser2\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nforever\n    next costume\n    wait (1) seconds\nend\n\nwhen flag clicked\nforever\n    if <(level) = [3]> then\n        show\n    else\n        hide\n    end\nend\n\n@Turret\n\nwhen flag clicked\nforever\n    if <(level) = [4]> then\n        show\n        forever\n            create clone of (bullet v)\n            wait (1) seconds\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\ngo to x: (221) y: (158)\nhide\nforever\n    point towards (character v)\nend\n\nshow\n\nwhen flag clicked\nforever\n    if <(level) = [5]> then\n        hide\n    end\nend\n\n@Bullet\n\nwhen flag clicked\ngo [backward v] (3) layers\ngo to (turret v)\nhide\n\nwhen I start as a clone\nif <(level) = [4]> then\n    show\nelse\n    hide\nend\nset size to (100) %\nswitch costume to (apple v)\npoint towards (character v)\nrepeat until <<<touching (_edge_ v)?> or <touching (platform v)?>> or <<touching (door v)?> or <touching (character v)?>>>\n    move (10) steps\nend\nswitch costume to (apple2 v)\nrepeat (5)\n    change size by (10)\nend\ndelete this clone\n\n@Character2\n\nwhen flag clicked\nhide\nforever\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nset size to (150) %\ngo to (character v)\ngo [backward v] (1) layers\nshow\nrepeat (5)\n    change [ghost v] effect by (10)\n    change size by (-20)\nend\ndelete this clone\n\n@Laser3\n\nwhen flag clicked\ngo to x: (150) y: (0)\nhide\nforever\n    next costume\n    wait (1) seconds\nend\n\nwhen flag clicked\nforever\n    if <(level) = [5]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    repeat (80)\n        change x by (-3)\n    end\n    repeat (80)\n        change x by (3)\n    end\nend\n\n@Crusher\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\n\nwhen flag clicked\nforever\n    if <(level) = [6]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen I receive [new level v]\ngo to x: (0) y: (0)\nwait (1.5) seconds\nrepeat (36)\n    change y by (-8)\nend\n\n@Alarm\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nforever\n    next costume\n    wait (1) seconds\nend\n\nwhen flag clicked\nforever\n    if <(level) = [7]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <(level) = [8]> then\n        hide\n        stop all sounds\n    end\nend\n\nwhen flag clicked\nforever\n    if <(level) = [7]> then\n        next costume\n        wait (0.1) seconds\n    end\nend\n\n@Text\n\nwhen flag clicked\nswitch costume to (apple v)\ngo to x: (0) y: (0)\nshow\n\nwhen flag clicked\nforever\n    if <(level) = [1]> then\n        switch costume to (apple v)\n    end\n    if <(level) = [2]> then\n        switch costume to (apple2 v)\n    end\n    if <(level) = [3]> then\n        switch costume to (apple3 v)\n    end\n    if <(level) = [4]> then\n        switch costume to (apple4 v)\n    end\n    if <(level) = [5]> then\n        switch costume to (apple5 v)\n    end\n    if <(level) = [6]> then\n        switch costume to (apple6 v)\n    end\n    if <(level) = [7]> then\n        switch costume to (apple7 v)\n    end\n    if <(level) = [8]> then\n        switch costume to (apple8 v)\n    end\n    if <(level) = [9]> then\n        switch costume to (apple9 v)\n    end\n    if <(level) = [10]> then\n        switch costume to (apple10 v)\n    end\n    if <(level) = [11]> then\n        switch costume to (apple11 v)\n    end\n    if <(level) = [12]> then\n        switch costume to (apple12 v)\n    end\n    if <(level) = [13]> then\n        switch costume to (apple13 v)\n    end\n    if <(level) = [14]> then\n        switch costume to (apple14 v)\n    end\n    if <(level) = [15]> then\n        switch costume to (apple15 v)\n    end\n    if <(level) = [16]> then\n        switch costume to (apple16 v)\n    end\nend\n\n@Guards\n\nwhen flag clicked\nforever\n    if <<(level) = [8]> or <(level) = [9]>> then\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    switch costume to (apple2 v)\n    repeat (80)\n        change x by (-3)\n    end\n    switch costume to (apple v)\n    repeat (80)\n        change x by (3)\n    end\nend\n\nwhen flag clicked\ngo to x: (150) y: (-120)\nhide\n\n@Guards2\n\nwhen flag clicked\nforever\n    if <(level) = [8]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    switch costume to (apple v)\n    repeat (80)\n        change x by (3)\n    end\n    switch costume to (apple2 v)\n    repeat (80)\n        change x by (-3)\n    end\nend\n\nwhen flag clicked\ngo to x: (-150) y: (-120)\nhide\n\n@Laser4\n\nwhen flag clicked\ngo to x: (0) y: (-5)\nhide\nforever\n    next costume\n    wait (1) seconds\nend\n\nwhen flag clicked\nforever\n    if <(level) = [9]> then\n        show\n    else\n        hide\n    end\nend\n\n@Spikeball\n\nwhen flag clicked\ngo to x: (0) y: (178)\nhide\nforever\n    if <(level) = [15]> then\n        turn right (2.5) degrees\n    else\n        turn right (11) degrees\n    end\nend\n\nwhen flag clicked\nforever\n    if <<(level) = [10]> or <(level) = [15]>> then\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <(level) = [15]> then\n        set size to (60) %\n        go to x: (0) y: (30)\n    else\n        set size to (100) %\n        go to x: (0) y: (178)\n    end\nend\n\n@Turret2\n\nwhen flag clicked\nforever\n    if <(level) = [11]> then\n        show\n        forever\n            create clone of (bullet2 v)\n            wait (1) seconds\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\ngo to x: (221) y: (158)\nhide\nforever\n    point towards (character v)\nend\n\nshow\n\nwhen flag clicked\nforever\n    if <(level) = [12]> then\n        hide\n    end\nend\n\n@Turret3\n\nwhen flag clicked\nforever\n    if <(level) = [11]> then\n        show\n        forever\n            create clone of (bullet3 v)\n            wait (1) seconds\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\ngo to x: (-221) y: (158)\nhide\nforever\n    point towards (character v)\nend\n\nshow\n\nwhen flag clicked\nforever\n    if <(level) = [12]> then\n        hide\n    end\nend\n\n@Bullet2\n\nwhen flag clicked\ngo [backward v] (3) layers\ngo to (turret2 v)\nhide\n\nwhen I start as a clone\nif <(level) = [11]> then\n    show\nelse\n    hide\nend\nset size to (100) %\nswitch costume to (apple v)\npoint towards (character v)\nrepeat until <<<touching (_edge_ v)?> or <touching (platform v)?>> or <<touching (door v)?> or <touching (character v)?>>>\n    move (10) steps\nend\nswitch costume to (apple2 v)\nrepeat (5)\n    change size by (10)\nend\ndelete this clone\n\nshow\n\n@Bullet3\n\nwhen flag clicked\ngo [backward v] (3) layers\ngo to (turret3 v)\nhide\n\nwhen I start as a clone\nif <(level) = [11]> then\n    show\nelse\n    hide\nend\nset size to (100) %\nswitch costume to (apple v)\npoint towards (character v)\nrepeat until <<<touching (_edge_ v)?> or <touching (platform v)?>> or <<touching (door v)?> or <touching (character v)?>>>\n    move (10) steps\nend\nswitch costume to (apple2 v)\nrepeat (5)\n    change size by (10)\nend\ndelete this clone\n\nshow\n\n@Thumbnail\n\nwhen flag clicked\nhide\n\nshow\n\n@Guards3\n\nwhen flag clicked\nforever\n    if <(level) = [12]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\ngo to x: (0) y: (-120)\nhide\n\n@Sleep\n\nwhen flag clicked\nforever\n    if <(level) = [12]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\ngo to x: (0) y: (-120)\nhide\n\n@Laser5\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nforever\n    next costume\n    wait (1) seconds\nend\n\nwhen flag clicked\nforever\n    if <(level) = [14]> then\n        show\n    else\n        hide\n    end\nend\n\n@Guards4\n\nwhen flag clicked\nforever\n    if <<(level) = [14]> or <(level) = [15]>> then\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    switch costume to (apple2 v)\n    repeat (80)\n        change x by (-3)\n    end\n    switch costume to (apple v)\n    repeat (80)\n        change x by (3)\n    end\nend\n\nwhen flag clicked\ngo to x: (110) y: (-120)\nhide\n\n@Turret4\n\nwhen flag clicked\ngo [forward v] (1) layers\nforever\n    if <(level) = [15]> then\n        show\n        forever\n            repeat (2)\n                create clone of (bullet4 v)\n                wait (0.3) seconds\n            end\n            wait (2) seconds\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\ngo to x: (-210) y: (140)\nhide\nforever\n    point towards (character v)\nend\n\nshow\n\nwhen flag clicked\nforever\n    if <(level) = [16]> then\n        hide\n    end\nend\n\n@Handle\n\nwhen flag clicked\ngo to x: (-210) y: (140)\nhide\n\nwhen flag clicked\nforever\n    if <(level) = [15]> then\n        show\n    else\n        hide\n    end\nend\n\n@Bullet4\n\nwhen flag clicked\ngo [backward v] (3) layers\ngo to (turret4 v)\nhide\n\nwhen I start as a clone\nif <(level) = [15]> then\n    show\nelse\n    hide\nend\nset size to (100) %\nswitch costume to (apple v)\npoint towards (character v)\nrepeat until <<<touching (_edge_ v)?> or <touching (platform v)?>> or <<touching (door v)?> or <touching (character v)?>>>\n    move (10) steps\nend\ndelete this clone\n\nshow\n\n@Handle2\n\nwhen flag clicked\ngo to x: (210) y: (140)\nhide\n\nwhen flag clicked\nforever\n    if <(level) = [15]> then\n        show\n    else\n        hide\n    end\nend\n\n@Bullet5\n\nwhen flag clicked\ngo [backward v] (3) layers\ngo to (turret5 v)\nhide\n\nwhen I start as a clone\nif <(level) = [15]> then\n    show\nelse\n    hide\nend\nset size to (100) %\nswitch costume to (apple v)\npoint towards (character v)\nrepeat until <<<touching (_edge_ v)?> or <touching (platform v)?>> or <<touching (door v)?> or <touching (character v)?>>>\n    move (10) steps\nend\ndelete this clone\n\nshow\n\n@Turret5\n\nwhen flag clicked\ngo [forward v] (1) layers\nforever\n    if <(level) = [15]> then\n        show\n        forever\n            repeat (2)\n                create clone of (bullet5 v)\n                wait (0.3) seconds\n            end\n            wait (2) seconds\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\ngo to x: (210) y: (140)\nhide\nforever\n    point towards (character v)\nend\n\nshow\n\nwhen flag clicked\nforever\n    if <(level) = [16]> then\n        hide\n    end\nend\n\n@Gate\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\n\nwhen flag clicked\nforever\n    if <(level) = [15]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <<(have key?) = [1]> and <<touching (character v)?> or <touching color (#ff6e00)?>>> then\n        repeat (100)\n            change y by (1)\n        end\n    end\nend\n\n@Key\n\nwhen flag clicked\ngo to x: (-45) y: (90)\nhide\n\nwhen flag clicked\nhide variable [have key? v]\nset [have key? v] to [0]\nforever\n    if <(level) = [15]> then\n        show\n        wait (10000) seconds\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (character v)?> then\n        set [have key? v] to [1]\n        hide\n    end\nend\n\nwhen I receive [new level v]\nif <(level) = [15]> then\n    set [have key? v] to [0]\n    show\nend\n\nwhen flag clicked\nforever\n    if <(level) = [16]> then\n        hide\n    end\nend\n\n@Spikes\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\n\nwhen flag clicked\nforever\n    if <(level) = [13]> then\n        show\n        forever\n            wait (1) seconds\n            repeat (10)\n                change y by (5)\n            end\n            repeat (10)\n                change y by (-5)\n            end\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <(level) = [14]> then\n        hide\n    end\nend\n\n