W1ld : Cats

I am making a game. The black + white cats are the enemies. Is there any way to make them fight back?

2 Likes

Wow, I love your art! What kind of fighting are you picturing? Something like the enemy cats dashing forward to attack? Or shooting some kind of projectile? Or you could have the enemies “follow” the player and when the enemy overlaps the player, the player takes damage

1 Like

Thanks! I was trying to have it so the other cat dashes forward but I have them so they randomly spawn. If I were to have them follow the player, they would all come rushing at the player at once. Maybe I could make a bush or something to trigger the black and white cat to ¨ambush¨ the player.

1 Like

That makes sense! So, here’s how I would do a “dash” kind of attack:

The one change I made to your code was to set the kind of EnemyCat to “Enemy” (instead of Player).

image

To break it down a bit:

  • The “forever” block gets a list of all Enemy sprites (black and white cats), and calls the “catAttack” function with a random enemy. The “pause 1000” makes this function basically equivalent to “on game update every 1000ms”, with one important difference: if you pause inside an “on game update”, it will also pause the screen, making it look like your game is frozen, but if you pause inside a forever, the rest of the game will keep going.
  • The “catAttack” function checks if the enemy should be attacking left or right, changes the Kind to AttackingCat, changes the velocity and pauses for half a second (the dash). Then it resets the kind and velocity.
  • The “overlaps” event checks when an AttackingCat overlaps the Player and decreases the health. Then it pauses, so that the player isn’t attacked many times, since the “overlaps” function is called every frame (every 30ms or so).

Here’s the code for it!:

One change I think you’ll need to make to your code, where you have is B button pressed and cat overlaps EvilCat, you should instead move that to a on sprite of kind Player overlaps sprite of kind Enemy. The way you currently have it, “EvilCat” will only be the most recently created enemy, and not all black-and-white cats.

Hope that helps! Let me know if any of this is unclear or you have any questions!

2 Likes

Wow! Thank you SO much!! This is very helpful! Thank you for helping me! :slight_smile:

1 Like

You did an amazing job with the pixel cats and rabbits! The music is great too! Please keep the cat games coming!

1 Like

Thank you!! I have an updated version of it too! If you look on my profile you should see it. It is called W1ld : Cats * UPDATE * :slight_smile:

2 Likes