Moonlight - Scrolling Platformer #games

Instructions: W-A-S-D to move,\nPurchase upgrades from the shop,\nHave fun!

@Stage\n\n@Shop\n\nwhen flag clicked\nhide\nforever\n    go to x: (0) y: (0)\n    switch costume to (1 v)\n    go to [front v] layer\nend\n\nwhen I receive [shop v]\nshow\nset [clone# v] to [1]\ncreate clone of (_myself_ v)\nset [clone# v] to [2]\ncreate clone of (_myself_ v)\n\nwhen I receive [no shop v]\nhide\ndelete this clone\n\nwhen I start as a clone\nforever\n    go to [front v] layer\n    if <(clone#) = [1]> then\n        go to x: (90) y: (-5)\n        if <(Speed x) = [2]> then\n            switch costume to (bougth v)\n        else\n            switch costume to (buy v)\n        end\n    end\n    if <(clone#) = [2]> then\n        go to x: (90) y: (-85)\n        if <(Speed y) = [18]> then\n            switch costume to (bougth v)\n        else\n            switch costume to (buy v)\n        end\n    end\nend\n\nwhen I start as a clone\nset size to (90) %\nshow\nforever\n    if <touching (mouse-pointer v)?> then\n        repeat until <(size) > [95]>\n            change size by (2)\n        end\n        if <mouse down?> then\n            if <<(clone#) = [1]> and <(costume [number v]) = [2]>> then\n                if <(Coins) > [44]> then\n                    set [speed x v] to [2]\n                    change [coins v] by (-45)\n                    switch costume to (bougth v)\n                end\n            end\n            if <<(clone#) = [2]> and <(costume [number v]) = [2]>> then\n                if <(Coins) > [39]> then\n                    set [speed y v] to [18]\n                    change [coins v] by (-40)\n                    switch costume to (bougth v)\n                end\n            end\n            wait until <not <mouse down?>>\n        end\n    else\n        repeat until <(size) < [92]>\n            change size by (-2)\n        end\n    end\nend\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@Buttons\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nswitch costume to (shop v)\nset [shop v] to [No]\nshow\nforever\n    go to x: (-198) y: (-162)\n    if <touching (mouse-pointer v)?> then\n        repeat until <(size) > [95]>\n            change size by (2)\n        end\n        if <mouse down?> then\n            if <(Shop) = [No]> then\n                set [shop v] to [Yes]\n                broadcast (Shop v)\n                create clone of (_myself_ v)\n            end\n            wait until <not <mouse down?>>\n        end\n    else\n        repeat until <(size) < [92]>\n            change size by (-2)\n        end\n    end\nend\n\nwhen I receive [start v]\ngo to [front v] layer\n\nwhen I start as a clone\nforever\n    go to [front v] layer\nend\n\nwhen I start as a clone\nswitch costume to (close v)\nshow\nforever\n    go to x: (111) y: (98)\n    if <touching (mouse-pointer v)?> then\n        repeat until <(size) > [95]>\n            change size by (2)\n        end\n        if <mouse down?> then\n            if <(Shop) = [Yes]> then\n                set [shop v] to [No]\n                broadcast (No Shop v)\n                delete this clone\n            end\n            wait until <not <mouse down?>>\n        end\n    else\n        repeat until <(size) < [92]>\n            change size by (-2)\n        end\n    end\nend\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@Thumbnail\n\nwhen [timer v] > (0.05)\ngo to [front v] layer\nset [ghost v] effect to (100)\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\ngo to [front v] layer\nset [ghost v] effect to (100)\nforever\n    reset timer\nend\n\n@Numbers\n\nwhen flag clicked\nset [digits v] to [1]\nrepeat (30)\n    create clone of (_myself_ v)\n    change [digits v] by (1)\nend\nhide\n\nwhen flag clicked\nforever\n    set size to (0) %\nend\n\nwhen I receive [time v]\nset [digits v] to [1]\nrepeat (30)\n    create clone of (_myself_ v)\n    change [digits v] by (1)\nend\nhide\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nshow\ngo to [front v] layer\nforever\n    set size to (45) %\n    go to x: (((digits) * (16)) - (225)) y: (146)\n    if <(length of (Coins)) < (digits)> then\n        hide\n    else\n        show\n        switch costume to (letter (digits) of (Coins))\n    end\nend\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\nwhen I receive [win v]\n\n@Checkpoint\n\nwhen I receive [tick v]\nposition ((x) - (Scroll x)) ((y) - (Scroll y))\nif <touching (player v)?> then\n    if <(checkpoint#) = [1]> then\n        if <not <(costume [number v]) = [2]>> then\n            broadcast (Checkpoint v)\n        end\n        switch costume to (checked v)\n        set [checkpoint x v] to [1383]\n        set [checkpoint y v] to [-95]\n    end\n    if <(checkpoint#) = [2]> then\n        if <not <(costume [number v]) = [2]>> then\n            broadcast (Checkpoint v)\n        end\n        switch costume to (checked v)\n        set [checkpoint x v] to [4606]\n        set [checkpoint y v] to [140]\n    end\n    if <(checkpoint#) = [3]> then\n        if <not <(costume [number v]) = [2]>> then\n            broadcast (Checkpoint v)\n        end\n        switch costume to (checked v)\n        set [checkpoint x v] to [2450]\n        set [checkpoint y v] to [-65]\n    end\n    if <(checkpoint#) = [4]> then\n        if <not <(costume [number v]) = [2]>> then\n            broadcast (Checkpoint v)\n        end\n        switch costume to (checked v)\n        set [checkpoint x v] to [3653]\n        set [checkpoint y v] to [-65]\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\ndefine Clone at x: (x) y: (y)\nset [x v] to (x)\nset [y v] to (y)\ngo to [back v] layer\ncreate clone of (_myself_ v)\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nset [checkpoint# v] to [1]\nClone at x: [1381] y: [-95]\nset [checkpoint# v] to [2]\nClone at x: [4606] y: [140]\nset [checkpoint# v] to [3]\nClone at x: [2450] y: [-65]\nset [checkpoint# v] to [4]\nClone at x: [3653] y: [-65]\nset [x v] to [-99999]\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen flag clicked\nswitch costume to (not checked v)\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@Coin\n\nwhen flag clicked\nshow\nswitch costume to (coin1 v)\nforever\n    next costume\n    wait (0.05) seconds\nend\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@Deco\n\nwhen flag clicked\nhide\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\nwhen I receive [green flag v]\nshow\n\nwhen I receive [tick v]\nPosition ((x) - (Scroll x)) ((y) - (Scroll y))\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\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\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (1 v)\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\n\nwhen I receive [reset v]\ndelete this clone\n\n@Collectables\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 [coins v] by (1)\n    delete this clone\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\ndefine Clone at x: (x) y: (y)\nset [x v] to (x)\nset [y v] to (y)\nswitch costume to (1/2)\ncreate clone of (_myself_ v)\nset [x v] to [-99999]\n\nwhen I receive [createclone v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nClone at x: [-112] y: [-99]\nClone at x: [-57] y: [-99]\nClone at x: [-84] y: [-54]\nClone at x: [112] y: [-99]\nClone at x: [57] y: [-99]\nClone at x: [86] y: [-54]\nClone at x: [486] y: [187]\nClone at x: [551] y: [187]\nClone at x: [757] y: [187]\nClone at x: [616] y: [187]\nClone at x: [687] y: [187]\nClone at x: [1024] y: [-52]\nClone at x: [1024] y: [-92]\nClone at x: [1118] y: [-52]\nClone at x: [1118] y: [-92]\nClone at x: [1210] y: [-52]\nClone at x: [1210] y: [-92]\nClone at x: [1575] y: [83]\nClone at x: [1621] y: [83]\nClone at x: [1665] y: [83]\nClone at x: [1575] y: [44]\nClone at x: [1621] y: [44]\nClone at x: [1665] y: [44]\nClone at x: [2278] y: [68]\nClone at x: [2311] y: [68]\nClone at x: [2346] y: [68]\nClone at x: [2378] y: [68]\nClone at x: [3878] y: [54]\nClone at x: [3878] y: [30]\nClone at x: [3878] y: [5]\nClone at x: [3923] y: [54]\nClone at x: [3923] y: [30]\nClone at x: [3923] y: [5]\nClone at x: [3968] y: [54]\nClone at x: [3968] y: [30]\nClone at x: [3968] y: [5]\nClone at x: [4030] y: [54]\nClone at x: [4030] y: [30]\nClone at x: [4030] y: [5]\nClone at x: [4071] y: [54]\nClone at x: [4071] y: [30]\nClone at x: [4071] y: [5]\nClone at x: [4107] y: [54]\nClone at x: [4107] y: [30]\nClone at x: [4107] y: [5]\n\nwhen I receive [deleteclone v]\ndelete this clone\n\nwhen flag clicked\nset volume to (10) %\nset [coins v] to [0]\nhide\n\nwhen I start as a clone\nset [sine v] to [0]\nforever\n    change [sine v] by (7.5)\n    set size to ((([sin v] of ((sine) * (2)) ) * (3)) + (50)) %\nend\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@Danger\n\nwhen flag clicked\nhide\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\nwhen I receive [green flag v]\nshow\n\nwhen I receive [green flag v]\nshow\n\nwhen I receive [tick v]\nPosition ((x) - (Scroll x)) ((y) - (Scroll y))\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\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\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (1 v)\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\n\nwhen I receive [reset v]\ndelete this clone\n\n@Enemy\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nhide\n\ndefine Clone at x: (x) y: (y) Change: (change) Side: (side)\nset [change v] to (change)\nset [x v] to (x)\nset [y v] to (y)\nset [side v] to (side)\nswitch costume to (1 v)\ncreate clone of (_myself_ v)\nset [x v] to [-99999]\n\nwhen I receive [tick v]\nPosition (((x) - (Scroll x)) + (offset)) ((y) - (Scroll y))\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<([abs v] of (x position) ) < [250]> and <([abs v] of (y position) ) < [190]>> then\n    show\nelse\n    hide\nend\nif <(die) = [0]> then\n    if <(timer) > [25]> then\n        set [offset v] to ((((((100) - ((timer) * (side))) * ((change) / (50))) - (offset)) / (7)) + (offset))\n    end\n    if <(timer) < [26]> then\n        set [offset v] to ((offset) + (((((timer) * (side)) * ((change) / (50))) - (offset)) / (7)))\n    end\nend\n\nwhen I start as a clone\nset [die v] to [0]\ngo to [front v] layer\ngo [backward v] (2) layers\nset size to (50) %\nset rotation style [left-right v]\nwait (1) seconds\nforever\n    if <touching (player v)?> then\n        if <<([y position v] of [player v]) > (y position)> and <([sy v] of [player v]) < [-1]>> then\n            start sound [Death v]\n            set [die v] to [2]\n            stop [other scripts in sprite v]\n            broadcast (Bounce v)\n            repeat (5)\n                broadcast (Bounce v)\n                change [ghost v] effect by (20)\n            end\n            switch costume to (2 v)\n            set [ghost v] effect to (0)\n            repeat (8)\n                change [y v] by (4)\n                change [ghost v] effect by (5)\n            end\n            switch costume to (2 v)\n            set [xy v] to (join (round (((x) + (offset)) + (5000))) (round ((y) + (5000))))\n            broadcast (Bounce v)\n            change [coins v] by (3)\n            delete this clone\n        else\n            set [finish v] to [Die]\n        end\n    end\nend\n\nwhen I receive [deleteclone v]\ndelete this clone\n\nwhen I receive [start v]\nset [die v] to [0]\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\nwhen I receive [createclone v]\nClone at x: [246] y: [-29] Change: [100] Side: [2]\nClone at x: [358] y: [40] Change: [90] Side: [2.4]\nClone at x: [503] y: [125] Change: [200] Side: [2]\nClone at x: [767] y: [40] Change: [90] Side: [2.4]\nClone at x: [855] y: [-29] Change: [100] Side: [2]\nClone at x: [1415] y: [-121] Change: [100] Side: [2]\nClone at x: [1833] y: [154] Change: [0] Side: [0]\nClone at x: [1972] y: [120] Change: [0] Side: [0]\nClone at x: [2118] y: [120] Change: [0] Side: [0]\nClone at x: [2540] y: [-92] Change: [100] Side: [2]\nClone at x: [2912] y: [-92] Change: [180] Side: [2]\nClone at x: [3256] y: [-92] Change: [210] Side: [2]\n\n@Platform\n\nwhen flag clicked\nforever\n    hide\nend\n\nwhen I receive [start v]\nforever\n    if <(Sounds) = [0]> then\n        set volume to (50) %\n    else\n        set volume to (0) %\n    end\nend\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\nwhen I receive [tick v]\nPosition ((x) - (Scroll x)) ((y) - (Scroll y))\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\ndefine Clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nnext costume\nchange [x v] by (x)\nchange [y v] by (y)\n\nwhen I receive [setup v]\nhide\nswitch costume to (1 v)\nset [x v] to [0]\nset [y v] to [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\nClone at x: [360] y: [0]\n\nwhen I receive [reset v]\ndelete this clone\n\n@Player\n\nwhen I receive [start v]\nset [checkpoint x v] to [-199]\nset [checkpoint y v] to [-118]\nset [speed x v] to [1.75]\nset [speed y v] to [16]\nset size to (50) %\nshow\nbroadcast (Green Flag v) and wait\nbroadcast (Play Game v) and wait\n\ndefine Game On\nset [x v] to (Checkpoint x)\nset [y v] to (Checkpoint y)\nset [sx v] to [0]\nset [sy v] to [0]\nset [in air v] to [0]\nset [finish v] to []\nset [scroll x v] to [0]\nset [scroll y v] to [0]\npoint in direction (90)\nshow\n\ndefine Tick\nswitch costume to (hitbox v)\nif <(Shop) = [No]> then\n    if <not <key (any v) pressed?>> then\n        switch costume to (hitbox v)\n    end\n    if <<<key (a v) pressed?> or <key (left arrow v) pressed?>> or <<(mouse x) < (x position)> and <mouse down?>>> then\n        point in direction (-90)\n        change [sx v] by ((Speed x) * (-1))\n    end\n    if <<<key (d v) pressed?> or <key (right arrow v) pressed?>> or <<(mouse x) > (x position)> and <mouse down?>>> then\n        point in direction (90)\n        change [sx v] by (Speed x)\n    end\n    set [sx v] to ((sx) * (0.8))\n    if <([abs v] of (sx) ) > [0.9]> then\n        Change Player x by (round (sx))\n    end\n    if <<<key (w v) pressed?> or <key (up arrow v) pressed?>> or <<(mouse y) > (y position)> and <mouse down?>>> then\n        if <(in air) < [4]> then\n            set [sy v] to (Speed y)\n        end\n    end\n    if <(sy) > [-20]> then\n        change [sy v] by (-2)\n    end\n    Change Player y by (sy)\n    Die\n    set [scroll x v] to (x)\n    change [scroll x v] by (round (((x) - (Scroll x)) / (10)))\n    if <(Scroll x) < [0]> then\n        set [scroll x v] to [0]\n    end\n    change [scroll y v] by (round (((y) - (Scroll y)) / (10)))\n    if <(Scroll y) < [0]> then\n        set [scroll y v] to [0]\n    end\nend\nPosition\nswitch costume to (stand v)\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\n\nwhen I receive [play game v]\nforever\n    broadcast (Reset v) and wait\n    broadcast (Setup v) and wait\n    Game On\n    repeat until <(Finish) > []>\n        Tick\n        Position\n        broadcast (Tick v)\n    end\n    if <(Finish) = [Yes]> then\n        Game Con\n    else\n        Game End\n    end\nend\n\ndefine Change Player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nPosition\nrepeat until <not <touching (platform 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 Change Player x by (sx)\nchange [x v] by (sx)\nPosition\nif <touching (platform v)?> then\n    repeat (12)\n        change [y v] by (1)\n        Position\n        if <not <touching (platform v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    if <<<key (w v) pressed?> or <key (up arrow v) pressed?>> or <<(mouse y) > (y position)> and <mouse down?>>> then\n        if <(sx) > [0]> then\n            set [sx v] to [-15]\n        else\n            set [sx v] to [15]\n        end\n        set [in air v] to [0]\n    else\n        set [sx v] to [0]\n    end\n    repeat until <not <touching (platform 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 End\nrepeat (2)\n    hide\n    wait (0.05) seconds\n    show\n    wait (0.05) seconds\nend\nhide\n\ndefine Die\nif <<touching (danger v)?> or <touching (spikes v)?>> then\n    set [finish v] to [Die]\nend\n\ndefine Game Con\nbroadcast (Win v)\n\nwhen I receive [bounce v]\nif <touching (enemy v)?> then\n    set [sy v] to [18]\nend\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\nwhen I receive [start v]\nbroadcast (DeleteClone v) and wait\nbroadcast (CreateClone v) and wait\n\nwhen [timer v] > (0.05)\nhide\n\n@Blank\n\nwhen flag clicked\nbroadcast (Start v)\n\nwhen flag clicked\nswitch backdrop to (backdrop1 v)\nset [timer v] to [0]\nforever\n    change [timer v] by (1)\n    if <(timer) > [50]> then\n        set [timer v] to [0]\n    end\nend\n\nwhen flag clicked\nset volume to (10) %\nforever\n    play sound [DEAF_KEV_-_Invincible_NCS_Release_\(getmp3 v] until done\nend\n\n