Emergency City | Scrolling Platformer
@Stage\n\nwhen flag clicked\nforever\n    play sound [Fade \(Alan Walker\) v] until done\nend\n\n@Player\n\ndefine None\nswitch costume to (hitbox v)\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    change [xv v] by (speed)\n    point in direction (90)\nend\nif <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n    change [xv v] by ((speed) * (-1))\n    point in direction (-90)\nend\nset [xv v] to ((XV) * (friction))\nchange x by (XV)\nif <touching (scrolling level hitbox v)?> then\n    set [slope v] to [0]\n    repeat until <<(Slope) = [8]> or <not <touching (scrolling level hitbox v)?>>>\n        change [slope v] by (1)\n        change y by (1)\n    end\n    if <touching (scrolling level hitbox v)?> then\n        change y by ((Slope) * (-1))\n        repeat ([ceiling v] of ([abs v] of (XV) ) )\n            if <touching (scrolling level hitbox v)?> then\n                change x by ((([abs v] of (XV) ) / (XV)) * (-1))\n            end\n        end\n    end\n    set [xv v] to [0]\nend\nchange y by (YV)\nif <touching (scrolling level hitbox v)?> then\n    repeat ([ceiling v] of ([abs v] of (YV) ) )\n        if <touching (scrolling level hitbox v)?> then\n            change y by ((([abs v] of (YV) ) / (YV)) * (-1))\n        end\n    end\n    if <<(YV) < [1]> and <<key (space v) pressed?> or <<key (up arrow v) pressed?> or <key (w v) pressed?>>>> then\n        set [yv v] to (jump)\n    else\n        set [yv v] to [0]\n    end\nelse\n    change [yv v] by (gravity)\nend\nif <key (r v) pressed?> then\n    Reset\nend\nswitch costume to (join [Player] (Player))\nchange [scrollx v] by (x position)\nset x to (0)\n\nwhen I receive [player loop v]\nforever\n    Platform (12) (-1) (0.85) (1.05)\n    Player Change\n    set [scrollx v] to (round (ScrollX))\nend\n\nset [scrollx v] to [15000]\n\ndefine None\nset [scrollx v] to (scroll x)\nset y to (y)\n\ndefine Reset\nGo To (280) (-100)\nset [player v] to [0]\nset [xv v] to [0]\nset [yv v] to [0]\npoint in direction (90)\ndelete (all) of [emergency status v]\nrepeat (8)\n    add [false] to [emergency status v]\nend\n\ndefine Player Change\nchange y by (-2)\nif <<touching (scrolling level hitbox v)?> and <<(YV) < [0.1]> and <(YV) > [-1.1]>>> then\n    if <key (3 v) pressed?> then\n        set [player v] to [3]\n    end\n    if <key (0 v) pressed?> then\n        set [player v] to [0]\n    end\n    if <key (1 v) pressed?> then\n        set [player v] to [1]\n    end\n    if <key (2 v) pressed?> then\n        set [player v] to [2]\n    end\nend\nchange y by (2)\n\nwhen I receive [play v]\nshow\nReset\nbroadcast (player loop v)\nbroadcast (camera loop v)\nbroadcast (BG loop v)\n\nwhen flag clicked\nhide\n\n@Scrolling Level HitBox\n\ndefine None\ngo to x: (0) y: (0)\nswitch costume to (costume0 v)\nset [levelx_ v] to [0]\nrepeat (level length)\n    create clone of (_myself_ v)\n    next costume\n    change [levelx_ v] by (480)\nend\n\nwhen flag clicked\nhide\ngo to x: (0) y: (0)\n\nwhen I receive [setup v]\nCreate Level HitBox (33)\n\nwhen I receive [bg loop v]\nforever\n    set x to ((LevelX_) - (ScrollX))\n    if <([abs v] of ((LevelX_) - (ScrollX)) ) > [480]> then\n        hide\n    else\n        show\n    end\nend\n\n@Scrolling Level Emergencies\n\ndefine None\ngo to x: (0) y: (0)\nswitch costume to (costume0 v)\nset [levelx_ v] to [0]\nrepeat (level length2)\n    create clone of (_myself_ v)\n    next costume\n    change [levelx_ v] by (480)\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\n\nwhen I receive [bg loop v]\nforever\n    set x to ((LevelX_) - (ScrollX))\n    if <([abs v] of ((LevelX_) - (ScrollX)) ) > [480]> then\n        hide\n    else\n        show\n    end\nend\n\nwhen I receive [setup v]\nCreate Level Emergency (33)\n\n@Message\n\nwhen flag clicked\ngo to x: (0) y: (0)\npoint in direction (90)\nswitch costume to (costume1 v)\nclear graphic effects\nshow\nforever\n    if <<(ScrollX) > [15260]> and <[emergency status v] contains [false]?>> then\n        set [scrollx v] to [15260]\n        switch costume to (costume2 v)\n    end\n    if <(ScrollX) < [15160]> then\n        switch costume to (costume1 v)\n    end\nend\n\nwhen I receive [end v]\nhide\ngo to [front v] layer\nswitch costume to (costume3 v)\nclear graphic effects\nset [ghost v] effect to (100)\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nshow\nclear graphic effects\nforever\n    point in direction ((([sin v] of ((timer) * (150)) ) * (10)) + (90))\nend\n\n@NPC1 (Police)\n\nwhen flag clicked\nswitch costume to (costume1 v)\nset y to (-131)\nset [npc x v] to [2500]\nset [click amount v] to [0]\nforever\n    if <([abs v] of ((NPC X) - (ScrollX)) ) > [240]> then\n        hide\n        Delete All Clones\n    else\n        show\n        if <(Player) = [1]> then\n            if <touching (mouse-pointer v)?> then\n                if <mouse down?> then\n                    if <([abs v] of (distance to [player v]) ) < [125]> then\n                        if <(Click Amount) < [10]> then\n                            change [click amount v] by (1)\n                            wait until <not <mouse down?>>\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine Delete All Clones\ndelete this clone\n\nwhen I start as a clone\nswitch costume to (costume2 v)\npoint in direction (pick random (-89) to (89))\nrepeat (10)\n    move (3) steps\n    change [ghost v] effect by (7)\nend\ndelete this clone\n\nwhen flag clicked\nforever\n    if <(Click Amount) < [10]> then\n        if <not <([abs v] of ((NPC X) - (ScrollX)) ) > [240]>> then\n            repeat (6)\n                create clone of (_myself_ v)\n            end\n        end\n        wait (0.5) seconds\n    else\n        Delete All Clones\n        switch costume to (costume3 v)\n        replace item (1) of [emergency status v] with [true]\n        wait (2) seconds\n        stop [other scripts in sprite v]\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    set x to ((NPC X) - (ScrollX))\nend\n\n@NPC2 (Nurse)\n\nwhen flag clicked\nset [click amount v] to [0]\nforever\n    if <(Click Amount) < [10]> then\n        if <not <([abs v] of ((NPC X) - (ScrollX)) ) > [240]>> then\n            switch costume to (costume1 v)\n            wait (2) seconds\n            switch costume to (costume2 v)\n            wait (0.3) seconds\n        end\n    else\n        if <(Click Amount) > [9]> then\n            switch costume to (costume3 v)\n            replace item (2) of [emergency status v] with [true]\n            wait (2.5) seconds\n            hide\n            stop [other scripts in sprite v]\n        end\n    end\nend\n\nwhen flag clicked\nset y to (-131)\nset [npc x v] to [4840]\nforever\n    set x to ((NPC X) - (ScrollX))\n    if <([abs v] of ((NPC X) - (ScrollX)) ) > [240]> then\n        hide\n    else\n        show\n        if <(Player) = [2]> then\n            if <touching (mouse-pointer v)?> then\n                if <mouse down?> then\n                    if <([abs v] of (distance to [player v]) ) < [125]> then\n                        if <(Click Amount) < [10]> then\n                            change [click amount v] by (1)\n                            wait until <not <mouse down?>>\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    set x to ((NPC X) - (ScrollX))\nend\n\n@NPC3 (FireFighter)\n\nwhen flag clicked\nset y to (100)\nset [npc x v] to [6390]\npoint in direction (105)\nforever\n    set x to ((NPC X) - (ScrollX))\n    if <([abs v] of ((NPC X) - (ScrollX)) ) > [240]> then\n        hide\n    else\n        show\n        if <(Player) = [3]> then\n            if <touching (mouse-pointer v)?> then\n                if <mouse down?> then\n                    if <([abs v] of ((ScrollX) - (NPC X)) ) < [100]> then\n                        if <(Click Amount) > [0]> then\n                            change [click amount v] by (-1)\n                            wait until <not <mouse down?>>\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nset [click amount v] to [10]\nforever\n    if <(Click Amount) > [0]> then\n        if <not <([abs v] of ((NPC X) - (ScrollX)) ) > [240]>> then\n            switch costume to (costume2 v)\n            wait (0.05) seconds\n            repeat (3)\n                next costume\n                wait (0.05) seconds\n            end\n        end\n    else\n        if <(Click Amount) < [1]> then\n            hide\n            replace item (3) of [emergency status v] with [true]\n            stop [other scripts in sprite v]\n            stop [this script v]\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    set x to ((NPC X) - (ScrollX))\nend\n\n@NPC4 (FireFighter)\n\nwhen flag clicked\nset y to (100)\nset [npc x v] to [6560]\npoint in direction (65)\nforever\n    set x to ((NPC X) - (ScrollX))\n    if <([abs v] of ((NPC X) - (ScrollX)) ) > [240]> then\n        hide\n    else\n        show\n        if <(Player) = [3]> then\n            if <touching (mouse-pointer v)?> then\n                if <mouse down?> then\n                    if <([abs v] of ((ScrollX) - (NPC X)) ) < [100]> then\n                        if <(Click Amount) > [0]> then\n                            change [click amount v] by (-1)\n                            wait until <not <mouse down?>>\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nset [click amount v] to [10]\nforever\n    if <(Click Amount) > [0]> then\n        if <not <([abs v] of ((NPC X) - (ScrollX)) ) > [240]>> then\n            switch costume to (costume2 v)\n            wait (0.05) seconds\n            repeat (3)\n                next costume\n                wait (0.05) seconds\n            end\n        end\n    else\n        if <(Click Amount) < [1]> then\n            hide\n            replace item (4) of [emergency status v] with [true]\n            stop [other scripts in sprite v]\n            stop [this script v]\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    set x to ((NPC X) - (ScrollX))\nend\n\n@NPC5 (Police)\n\nwhen flag clicked\nswitch costume to (costume1 v)\nset y to (-131)\nset [npc x v] to [9650]\nset [click amount v] to [0]\nforever\n    set x to ((NPC X) - (ScrollX))\n    if <([abs v] of ((NPC X) - (ScrollX)) ) > [240]> then\n        hide\n        Delete All Clones\n    else\n        show\n        if <(Player) = [1]> then\n            if <touching (mouse-pointer v)?> then\n                if <mouse down?> then\n                    if <([abs v] of (distance to [player v]) ) < [125]> then\n                        if <(Click Amount) < [10]> then\n                            change [click amount v] by (1)\n                            wait until <not <mouse down?>>\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine Delete All Clones\ndelete this clone\n\nwhen I start as a clone\nswitch costume to (costume2 v)\npoint in direction (pick random (-89) to (89))\nrepeat (10)\n    move (3) steps\n    change [ghost v] effect by (7)\nend\ndelete this clone\n\nwhen flag clicked\nforever\n    if <(Click Amount) < [10]> then\n        if <not <([abs v] of ((NPC X) - (ScrollX)) ) > [240]>> then\n            repeat (3)\n                create clone of (_myself_ v)\n            end\n        end\n        wait (0.5) seconds\n    else\n        Delete All Clones\n        switch costume to (costume3 v)\n        replace item (5) of [emergency status v] with [true]\n        wait (2) seconds\n        stop [other scripts in sprite v]\n        hide\n    end\nend\n\nset [npc x v] to [9650]\n\nwhen flag clicked\nforever\n    set x to ((NPC X) - (ScrollX))\nend\n\n@NPC6 (FireFighter)\n\nwhen flag clicked\nset y to (10)\nset [npc x v] to [12025]\npoint in direction (90)\nforever\n    set x to ((NPC X) - (ScrollX))\n    if <([abs v] of ((NPC X) - (ScrollX)) ) > [240]> then\n        hide\n    else\n        show\n        if <(Player) = [3]> then\n            if <touching (mouse-pointer v)?> then\n                if <mouse down?> then\n                    if <([abs v] of ((ScrollX) - (NPC X)) ) < [100]> then\n                        if <(Click Amount) > [0]> then\n                            change [click amount v] by (-1)\n                            wait until <not <mouse down?>>\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nset [click amount v] to [10]\nforever\n    if <(Click Amount) > [0]> then\n        if <not <([abs v] of ((NPC X) - (ScrollX)) ) > [240]>> then\n            switch costume to (costume2 v)\n            wait (0.05) seconds\n            repeat (3)\n                next costume\n                wait (0.05) seconds\n            end\n        end\n    else\n        if <(Click Amount) < [1]> then\n            hide\n            replace item (6) of [emergency status v] with [true]\n            stop [other scripts in sprite v]\n            stop [this script v]\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    set x to ((NPC X) - (ScrollX))\nend\n\n@NPC7 (Nurse)\n\nwhen flag clicked\nset [click amount v] to [0]\nforever\n    if <(Click Amount) < [10]> then\n        if <not <([abs v] of ((NPC X) - (ScrollX)) ) > [240]>> then\n            switch costume to (costume1 v)\n            wait (2) seconds\n            switch costume to (costume2 v)\n            wait (0.3) seconds\n        end\n    else\n        if <(Click Amount) > [9]> then\n            switch costume to (costume3 v)\n            replace item (7) of [emergency status v] with [true]\n            wait (2.5) seconds\n            hide\n            stop [other scripts in sprite v]\n        end\n    end\nend\n\nwhen flag clicked\nset y to (-131)\nset [npc x v] to [13475]\nforever\n    set x to ((NPC X) - (ScrollX))\n    if <([abs v] of ((NPC X) - (ScrollX)) ) > [240]> then\n        hide\n    else\n        show\n        if <(Player) = [2]> then\n            if <touching (mouse-pointer v)?> then\n                if <mouse down?> then\n                    if <([abs v] of (distance to [player v]) ) < [125]> then\n                        if <(Click Amount) < [10]> then\n                            change [click amount v] by (1)\n                            wait until <not <mouse down?>>\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    set x to ((NPC X) - (ScrollX))\nend\n\n@NPC8 (Nurse)\n\nwhen flag clicked\nset [click amount v] to [0]\nforever\n    if <(Click Amount) < [10]> then\n        if <not <([abs v] of ((NPC X) - (ScrollX)) ) > [240]>> then\n            switch costume to (costume1 v)\n            wait (2) seconds\n            switch costume to (costume2 v)\n            wait (0.3) seconds\n        end\n    else\n        if <(Click Amount) > [9]> then\n            switch costume to (costume3 v)\n            replace item (8) of [emergency status v] with [true]\n            wait (2.5) seconds\n            hide\n            stop [other scripts in sprite v]\n        end\n    end\nend\n\nwhen flag clicked\nset y to (-131)\nset [npc x v] to [14850]\nforever\n    set x to ((NPC X) - (ScrollX))\n    if <([abs v] of ((NPC X) - (ScrollX)) ) > [240]> then\n        hide\n    else\n        show\n        if <(Player) = [2]> then\n            if <touching (mouse-pointer v)?> then\n                if <mouse down?> then\n                    if <([abs v] of (distance to [player v]) ) < [125]> then\n                        if <(Click Amount) < [10]> then\n                            change [click amount v] by (1)\n                            wait until <not <mouse down?>>\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    set x to ((NPC X) - (ScrollX))\nend\n\n@NPC8 (Nurse)2\n\nwhen flag clicked\nset y to (-50)\nset [npc x v] to [15375]\nhide\nwait (1) seconds\nforever\n    set x to ((NPC X) - (ScrollX))\n    if <<<not <[emergency status v] contains [false]?>> and <touching (player v)?>> and <(Player) = [0]>> then\n        broadcast (end v)\n        stop [this script v]\n    end\n    if <([abs v] of ((NPC X) - (ScrollX)) ) > [240]> then\n        hide\n    else\n        show\n    end\nend\n\nwhen flag clicked\nforever\n    set x to ((NPC X) - (ScrollX))\nend\n\n\n\n@Title Card\n\nwhen flag clicked\ngo to [front v] layer\nshow\ngo to x: (0) y: (50)\npoint in direction (90)\nset size to (100) %\nforever\n    point in direction ((([sin v] of ((timer) * (150)) ) * (10)) + (90))\n    set size to ((([cos v] of ((timer) * (150)) ) * (10)) + (90)) %\nend\n\nwhen I receive [play v]\nstop [other scripts in sprite v]\nhide\n\n@Play Button\n\nwhen flag clicked\nshow\ngo to x: (0) y: (-50)\npoint in direction (90)\nset size to (80) %\nforever\n    if <touching (mouse-pointer v)?> then\n        set size to (100) %\n        if <mouse down?> then\n            wait until <not <mouse down?>>\n            broadcast (Fade In v) and wait\n            broadcast (setup v) and wait\n            broadcast (Play v)\n            hide\n            broadcast (Fade Out v) and wait\n            stop [this script v]\n        end\n    else\n        set size to (80) %\n    end\nend\n\n@Fade In/Out\n\nwhen flag clicked\ngo to x: (0) y: (0)\ngo to [front v] layer\nhide\n\nwhen I receive [fade in v]\nhide\ngo to [front v] layer\nclear graphic effects\nset [ghost v] effect to (100)\nshow\nrepeat (12)\n    change [ghost v] effect by ((100) / (-12))\nend\nclear graphic effects\nset [ghost v] effect to (0)\nshow\n\nwhen I receive [fade out v]\nshow\ngo to [front v] layer\nclear graphic effects\nset [ghost v] effect to (0)\nshow\nrepeat (12)\n    change [ghost v] effect by ((100) / (12))\nend\nclear graphic effects\nset [ghost v] effect to (100)\nhide\n\n@Thumbnail\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\n\ngo to [front v] layer\nshow\n\n