Scratch for Kids

A Watch the course on Frontend Masters

Adding Enemies

What fun is eating tacos if you didn’t avoid some enemies on your quest to get your tacos?We can create an additional sprite and have it chase our hero around.

when green flag clicked
forever
	point towards [Player v]
	move [5] steps
end

I went for 5 steps because I wanted our enemy to be a little bit slower than our hero. But you can adjust this to whatever feels right for you. But, what do I do when the enemy gets to the player?

when green flag clicked
forever
	point towards [Player v]
	move [5] steps
	if <touching [Player v]> then
		stop [all v]
	end
end

And now, the game will end whenever our enemy catches up the our player. You can see this iteration of the game here.

We can also choose to make the game go faster as the score gets higher.