How do you give each enemies their own health

I am not sure how to give each enemy health. For instance, the enemy in the game, I want it to have 4 hp, but after the projectile hits the enemies 4 times, all the enemies will have 0 hp.
I dont want the health of the enemies to decrease when only 1 enemy is shot.

Well you can use things like player 2 health-player 4 health

use the data extension, and give them health when you create each sprite. in your +1normal function, you can set a piece of data in the sprite to 4. you’re setting a global variable to 4 right now which won’t work. each time enemy gets hit you subract 1hp from their individual sprite. if you look at my game Fable of Zelba look at the functions SpawnMonsters, and DamageMonster (going by memory)

Use the sprite data extension!

I already figured out this after looking through the forum’s td game. But now I have a problem with my td game: the towers aiming at the first sprite to spawn.

2 Likes