Enemy for scrolling platformer ( or just a platformer )
@Stage\n\n@Hitbox\n\nwhen flag clicked\nhide\nbroadcast (start v)\n\nwhen I receive [start v]\ngo to x: (0) y: (0)\nshow\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nset [ghost v] effect to (100)\nforever\n    Move\nend\n\ndefine Move\nif <key (d v) pressed?> then\n    change [x v] by (1)\nend\nif <key (a v) pressed?> then\n    change [x v] by (-1)\nend\nchange x by (x)\nif <touching (level v)?> then\n    change x by ((x) * (-1))\n    set [x v] to [0]\nelse\n    set [x v] to ((x) * (0.9))\nend\nchange y by (y)\nif <touching (level v)?> then\n    change y by ((y) * (-1))\n    set [y v] to [0]\n    if <key (w v) pressed?> then\n        set [y v] to [14]\n    end\nelse\n    change [y v] by (-1)\nend\nchange [scroll x v] by ((x position) * (-1))\nchange [scroll y v] by ((y position) * (-1))\ngo to x: (0) y: (0)\n\nwhen flag clicked\nset [lives v] to [3]\nshow variable [lives v]\nforever\n    if <(Lives) = [0]> then\n        hide variable [lives v]\n        stop [all v]\n    end\nend\n\n@Cat\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nshow\nswitch costume to (costume1 v)\nforever\n    go to x: (0) y: (0)\nend\n\ngo to x: (0) y: (0)\n\nwhen I receive [start v]\nwait (0.4) seconds\nset rotation style [left-right v]\nforever\n    if <key (d v) pressed?> then\n        point in direction (90)\n    end\n    if <key (a v) pressed?> then\n        point in direction (-90)\n    end\n    if <not <key (w v) pressed?>> then\n        if <not <touching (level v)?>> then\n            switch costume to (costume4 v)\n            wait until <touching (level v)?>\n        end\n    end\n    if <touching (level v)?> then\n        if <<key (d v) pressed?> or <key (a v) pressed?>> then\n            switch costume to (costume2 v)\n            wait (0.1) seconds\n            switch costume to (costume1 v)\n            wait (0.1) seconds\n        end\n        if <key (w v) pressed?> then\n            switch costume to (costume3 v)\n        end\n        if <not <<key (a v) pressed?> or <<key (d v) pressed?> or <key (w v) pressed?>>>> then\n            switch costume to (costume1 v)\n        end\n    end\nend\n\nwhen I receive [oh no v]\nstop [other scripts in sprite v]\nswitch costume to (costume5 v)\nstart sound [Crazy Laugh v]\nbroadcast (start v)\n\n@Level\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nshow\nforever\n    go to x: (scroll x) y: (scroll y)\nend\n\n@Enemy\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nclear graphic effects\nshow\nset [enemy x v] to [0]\nset [enemy y v] to [0]\nforever\n    go to x: ((scroll x) + ((enemy x) + (200))) y: ((scroll y) + ((enemy y) - (60)))\nend\n\nwhen I receive [start v]\nwait (0.2) seconds\nforever\n    if <<<touching (hitbox v)?> and <not <(Lives) = [0]>>> and <(enemy dead) = [no]>> then\n        change [lives v] by (-1)\n        broadcast (oh no v)\n        stop [this script v]\n    end\nend\n\nwhen I receive [enemy dead v]\nstop [other scripts in sprite v]\nstart sound [Bell Toll v]\nswitch costume to (3 v)\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\nstop [this script v]\n\nwhen I receive [start v]\nforever\n    switch costume to (1 v)\n    wait (0.2) seconds\n    switch costume to (2 v)\n    wait (0.2) seconds\nend\n\nwhen I receive [start v]\nset rotation style [left-right v]\npoint in direction (90)\nforever\n    point in direction (90)\n    repeat (25)\n        change [enemy x v] by (-2)\n    end\n    wait (0.1) seconds\n    point in direction (-90)\n    repeat (25)\n        change [enemy x v] by (2)\n    end\n    wait (0.1) seconds\nend\n\n@Enemy hitbox\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nshow\nset [ghost v] effect to (100)\nset [enemy x v] to [0]\nset [enemy y v] to [0]\nforever\n    go to x: ((scroll x) + ((enemy x) + (200))) y: ((scroll y) + ((enemy y) - (60)))\nend\n\nwhen I receive [start v]\nset rotation style [left-right v]\npoint in direction (90)\nforever\n    point in direction (90)\n    repeat (25)\n        change [enemy x v] by (-2)\n    end\n    wait (0.1) seconds\n    point in direction (-90)\n    repeat (25)\n        change [enemy x v] by (2)\n    end\n    wait (0.1) seconds\nend\n\nwhen I receive [start v]\nset [enemy dead v] to [no]\nwait (0.2) seconds\nforever\n    if <touching (hitbox v)?> then\n        set [enemy dead v] to [yes]\n        stop [other scripts in sprite v]\n        broadcast (enemy dead v)\n        hide\n        stop [this script v]\n    end\nend\n\nwhen I receive [enemy dead v]\nstop [other scripts in sprite v]\nhide\n\n
You can remix this if you want