Trapped || A Platformer                                                                 #games

Instructions: Trapped || A Platformer\narrow keys - WASD - mobile\n16 levels\nBeat the boss a the end by dodging his attacks.\n100% possible\n100% by me except for music\nEnjoy!

@Stage\n\nwhen flag clicked\nset [end v] to [0]\nforever\n    if <not <(end) = [1]>> then\n        play sound [Clash Royale Sudden Death v] until done\n    end\nend\n\nwhen flag clicked\nswitch backdrop to (backdrop1 v)\n\nwhen I receive [lol the end v]\nset [end v] to [1]\nswitch backdrop to (backdrop2 v)\nstop all sounds\nplay sound [DEAF KEV - Invincible \[NCS Release\] \[Mpgun v] until done\n\n@Level\n\nwhen flag clicked\nshow\nswitch costume to (1 v)\ngo to [front v] layer\nforever\n    go to x: (0) y: (0)\n    if <([x position v] of [player v]) > [225]> then\n        next costume\n        wait (0.2) seconds\n    end\n    if <(costume [number v]) = [15]> then\n        stop [this script v]\n    end\nend\n\nwhen flag clicked\nwait (1) seconds\nrepeat until <(costume [number v]) = [15]>\n    if <key (n v) pressed?> then\n        next costume\n        wait (0.5) seconds\n    end\nend\n\nwhen I receive [boss end! v]\nwait until <([x position v] of [player v]) > [225]>\nnext costume\n\n@Player\n\nwhen flag clicked\nswitch costume to (ball-a v)\nset [y spawn v] to [-70]\nset [x spawn v] to [-200]\ngo to x: (X Spawn) y: (Y Spawn)\nshow\nset size to (50) %\nset [x v] to [0]\nset [y v] to [0]\nforever\n    Platformer engine\nend\n\ndefine Platformer engine\nif on edge, bounce\nchange [y v] by (-0.5)\nif <<key (left arrow v) pressed?> or <<key (a v) pressed?> or <<mouse down?> and <[0] > (mouse x)>>>> then\n    change [x v] by (-1)\n    point in direction (-90)\nend\nif <<key (right arrow v) pressed?> or <<key (d v) pressed?> or <<mouse down?> and <(mouse x) > [0]>>>> then\n    change [x v] by (1)\n    point in direction (90)\nend\nset [x v] to ((x) * (0.9))\nchange x by (x)\nif <<touching (level v)?> or <touching (moving platforms v)?>> then\n    change y by (1)\n    if <<touching (level v)?> or <touching (moving platforms v)?>> then\n        change y by (1)\n        if <<touching (level v)?> or <touching (moving platforms v)?>> then\n            change y by (1)\n            if <<touching (level v)?> or <touching (moving platforms v)?>> then\n                change y by (1)\n                if <<touching (level v)?> or <touching (moving platforms v)?>> then\n                    change y by (1)\n                    if <<touching (level v)?> or <touching (moving platforms v)?>> then\n                        change y by (1)\n                        if <<touching (level v)?> or <touching (moving platforms v)?>> then\n                            change y by (-6)\n                            change x by ((x) * (-1))\n                            if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                                set [y v] to [10]\n                                if <(x) > [0]> then\n                                    set [x v] to [-3]\n                                else\n                                    set [x v] to [3]\n                                end\n                            else\n                                set [x v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\nchange y by (y)\nif <<touching (level v)?> or <touching (moving platforms v)?>> then\n    change y by ((y) * (-1))\n    set [y v] to [0]\nend\nchange y by (-0.5)\nif <<<touching (level v)?> or <touching (moving platforms v)?>> and <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<mouse down?> and <[0] < (mouse y)>>>>> then\n    set [y v] to [8]\nend\nchange y by (0.5)\nif <<touching (spikes v)?> or <<touching (saws v)?> or <<touching (lava v)?> or <<touching (special moving laser v)?> or <touching (boss v)?>>>>> then\n    go to x: (X Spawn) y: (Y Spawn)\n    if <([costume # v] of [level v]) = [4]> then\n        broadcast (death lvl4 v)\n    end\n    if <([costume # v] of [level v]) = [15]> then\n        broadcast (reset boss v)\n    end\nend\nif <touching (bounce v)?> then\n    set [y v] to [12]\nend\nif <touching (left yeet thingies v)?> then\n    change [x v] by (-4)\nend\nif <touching (right yeet thingies v)?> then\n    change [x v] by (4)\nend\nif <(x position) > [225]> then\n    if <not <[14] < ([costume # v] of [level v])>> then\n        wait (0.01) seconds\n        go to x: (X Spawn) y: (Y Spawn)\n    end\nend\n\nwhen [r v] key pressed\nif <not <([costume # v] of [level v]) = [15]>> then\n    go to x: (X Spawn) y: (Y Spawn)\nend\n\nwhen flag clicked\nwait (1) seconds\nrepeat until <([costume # v] of [level v]) = [15]>\n    if <key (n v) pressed?> then\n        go to x: (X Spawn) y: (Y Spawn)\n        wait (0.5) seconds\n    end\nend\n\nwhen I receive [boss end! v]\nwait until <(x position) > [225]>\ngo to x: (X Spawn) y: (Y Spawn)\nbroadcast (lol the end v)\n\n@Spikes\n\nwhen flag clicked\nshow\nwait (0.000000001) seconds\ngo to [back v] layer\nforever\n    switch costume to ([costume # v] of [level v])\nend\n\n@Trail\n\nwhen flag clicked\nforever\n    hide\n    go to (player v)\n    create clone of (_myself_ v)\n    go to [front v] layer\nend\n\nwhen I start as a clone\nshow\nclear graphic effects\ngo to [back v] layer\ngo [forward v] (1) layers\nrepeat (10)\n    change [ghost v] effect by (10)\n    change size by (-5)\nend\ndelete this clone\n\n@Bounce\n\nwhen flag clicked\nhide\nwait until <([costume # v] of [level v]) = [5]>\nset [last bounce v] to [5]\ngo to x: (-123) y: (-117)\ncreate clone of (_myself_ v)\nwait until <([costume # v] of [level v]) = [7]>\nset [last bounce v] to [7]\ngo to x: (-45) y: (-117)\ncreate clone of (_myself_ v)\nwait until <([costume # v] of [level v]) = [8]>\nwait (0.01) seconds\nset [last bounce v] to [8]\ngo to x: (-130) y: (-117)\ncreate clone of (_myself_ v)\nwait until <([costume # v] of [level v]) = [10]>\nset [last bounce v] to [10]\ngo to x: (-20) y: (-117)\ncreate clone of (_myself_ v)\nwait until <([costume # v] of [level v]) = [12]>\nset [last bounce v] to [12]\ngo to x: (-41) y: (-117)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nshow\ngo to [back v] layer\nforever\n    switch costume to (costume1 v)\n    if <touching (player v)?> then\n        repeat (4)\n            next costume\n        end\n        switch costume to (costume4 v)\n        switch costume to (costume3 v)\n        switch costume to (costume2 v)\n    end\nend\n\nwhen I start as a clone\nwait until <not <([costume # v] of [level v]) = (last bounce)>>\ndelete this clone\n\n@Saws\n\nwhen flag clicked\nhide\nwait until <([costume # v] of [level v]) = [2]>\nset [last saw v] to [2]\nswitch costume to (2 v)\ngo to x: (-113) y: (42)\ncreate clone of (_myself_ v)\nswitch costume to (3 v)\ngo to x: (3) y: (-132)\ncreate clone of (_myself_ v)\nswitch costume to (2 v)\ngo to x: (131) y: (42)\ncreate clone of (_myself_ v)\nwait until <([costume # v] of [level v]) = [6]>\nset [last saw v] to [6]\nswitch costume to (1 v)\ngo to x: (-119) y: (-133)\ncreate clone of (_myself_ v)\nwait until <([costume # v] of [level v]) = [7]>\nwait (0.01) seconds\nset [last saw v] to [7]\nswitch costume to (2 v)\ngo to x: (-132) y: (43)\ncreate clone of (_myself_ v)\nwait until <([costume # v] of [level v]) = [8]>\nwait (0.01) seconds\nset [last saw v] to [8]\nswitch costume to (1 v)\ngo to x: (59) y: (8)\ncreate clone of (_myself_ v)\nwait until <([costume # v] of [level v]) = [9]>\nwait (0.01) seconds\nset [last saw v] to [9]\nswitch costume to (1 v)\ngo to x: (30) y: (33)\ncreate clone of (_myself_ v)\ngo to x: (30) y: (-78)\ncreate clone of (_myself_ v)\nwait until <([costume # v] of [level v]) = [10]>\nwait (0.01) seconds\nset [last saw v] to [10]\nswitch costume to (1 v)\ngo to x: (-119) y: (-133)\ncreate clone of (_myself_ v)\nwait until <([costume # v] of [level v]) = [12]>\nset [last saw v] to [12]\nswitch costume to (1 v)\ngo to x: (-119) y: (-133)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nwait until <not <([costume # v] of [level v]) = (last saw)>>\ndelete this clone\n\nwhen I start as a clone\nshow\ngo to [back v] layer\nforever\n    turn right (3) degrees\nend\n\nwhen I start as a clone\nif <(costume [number v]) = [2]> then\n    forever\n        glide (1) secs to x: (x position) y: ((y position) - (170))\n        wait (0.5) seconds\n        glide (1) secs to x: (x position) y: ((y position) - (-170))\n        wait (0.5) seconds\n    end\nend\n\nwhen I start as a clone\nif <(costume [number v]) = [3]> then\n    forever\n        glide (1) secs to x: (x position) y: ((y position) - (-170))\n        wait (0.5) seconds\n        glide (1) secs to x: (x position) y: ((y position) - (170))\n        wait (0.5) seconds\n    end\nend\n\n@Lava\n\nwhen flag clicked\nshow\ngo to [back v] layer\nforever\n    go to x: (0) y: (0)\n    repeat (10)\n        change y by (1)\n    end\n    repeat (10)\n        change y by (-1)\n    end\nend\n\nwhen flag clicked\nforever\n    switch costume to ([costume # v] of [level v])\nend\n\n@Decorations\n\nwhen flag clicked\ngo to [front v] layer\nforever\n    switch costume to ([costume # v] of [level v])\nend\n\n@Left YEET thingies\n\nwhen flag clicked\ngo to [back v] layer\nforever\n    switch costume to ([costume # v] of [level v])\nend\n\n@Right YEET thingies\n\nwhen flag clicked\ngo to [back v] layer\nforever\n    switch costume to ([costume # v] of [level v])\nend\n\n@Special moving laser\n\nwhen flag clicked\nhide\nwait until <([costume # v] of [level v]) = [4]>\npoint in direction (90)\nshow\ngo to x: (0) y: (0)\nrepeat until <not <([costume # v] of [level v]) = [4]>>\n    turn right (-4) degrees\nend\nhide\n\nwhen I receive [death lvl4 v]\npoint in direction (90)\n\n@Moving platforms\n\nwhen flag clicked\nwait (0.01) seconds\nhide\nwait until <([costume # v] of [level v]) = [8]>\nshow\ngo to x: (-23) y: (-18)\nrepeat until <not <([costume # v] of [level v]) = [8]>>\n    repeat (50)\n        change x by (3.2)\n        if <touching (player v)?> then\n            change [x v] by (3.2)\n        end\n    end\n    wait (0.5) seconds\n    repeat (50)\n        change x by (-3.2)\n        if <touching (player v)?> then\n            change [x v] by (-3.2)\n        end\n    end\n    wait (0.5) seconds\nend\n\nwhen I start as a clone\nwait until <not <([costume # v] of [level v]) = (last saw)>>\ndelete this clone\n\nwhen I start as a clone\n\nwhen I start as a clone\nif <(costume [number v]) = [3]> then\n    forever\n        glide (1) secs to x: (x position) y: ((y position) - (-170))\n        wait (0.5) seconds\n        glide (1) secs to x: (x position) y: ((y position) - (170))\n        wait (0.5) seconds\n    end\nend\n\nwhen flag clicked\nwait (0.01) seconds\nwait until <([costume # v] of [level v]) = [9]>\nstop [other scripts in sprite v]\nbroadcast (MP no lag v)\nshow\ngo to x: (-104) y: (-153)\nrepeat until <not <([costume # v] of [level v]) = [9]>>\n    repeat (42)\n        change y by (5)\n        if <touching (player v)?> then\n            change [y v] by (1)\n        end\n    end\n    wait (1) seconds\n    repeat (42)\n        change y by (-5)\n    end\n    wait (1) seconds\nend\n\nwhen I receive [mp no lag v]\nwait (0.01) seconds\nwait until <([costume # v] of [level v]) = [10]>\nstop [other scripts in sprite v]\nhide\n\n@Overall\n\nwhen flag clicked\nhide\nforever\n    go to x: (0) y: (0)\nend\n\n@BOSS\n\nwhen flag clicked\nset [ghost v] effect to (0)\nhide\ngo to x: (0) y: (-200)\nwait (1) seconds\nwait until <([costume # v] of [level v]) = [15]>\nbroadcast (boss appear v)\n\nwhen I receive [boss appear v]\nshow\ngo to x: (190) y: (-108)\nbroadcast (boss speech v)\n\nwhen I receive [fight v]\nwait (0.5) seconds\nglide (0.5) secs to x: (-190) y: (-108)\nwait (1) seconds\nglide (0.5) secs to x: (190) y: (-108)\nwait (1) seconds\nglide (0.5) secs to x: (-190) y: (-108)\nwait (1) seconds\nglide (0.5) secs to x: (190) y: (-108)\nrepeat (5)\n    wait (0.5) seconds\n    glide (0.2) secs to x: (x position) y: (108)\n    glide (0.5) secs to x: ([x position v] of [player v]) y: (108)\n    wait (0.1) seconds\n    glide (0.2) secs to x: (x position) y: (-108)\nend\nwait (0.5) seconds\nglide (0.5) secs to x: (190) y: (-108)\nwait (0.05) seconds\nSay [Well you’re not bad!] for [2] seconds\nSay [I never saw someone like you!] for [2] seconds\nSay [For this reason I’ll let you go.] for [2] seconds\nrepeat (25)\n    change [ghost v] effect by (4)\nend\nhide\ngo to x: (0) y: (-200)\nbroadcast (BOSS END! v)\n\nwhen I receive [boss speech v]\nSay [You can’t escape.] for [2] seconds\nbroadcast (fight v)\n\nwhen I receive [reset boss v]\nstop [other scripts in sprite v]\nbroadcast (boss appear v)\n\ndefine Say (text) for (time) seconds\nset [digit number v] to [0]\nset [past text v] to []\nset [say v] to []\nrepeat until <(past text) = (text)>\n    change [digit number v] by (1)\n    set [say v] to (join (past text) (letter (digit number) of (text)))\n    say (say)\n    set [past text v] to (say)\n    play note (85) for (0.05) beats\nend\nif <not <(time) = [-]>> then\n    say (text) for (time) seconds\nend\n\n@Thumbnail\n\nwhen flag clicked\nforever\n    set [ghost v] effect to (100)\n    go to [front v] layer\nend\n\n