2D Game Dev Journey — Day 24: New Enemy and Enemies Destroying Pick-ups
Welcome to 2D Game Dev Journey — Day 24: New Enemy and Enemies Destroying Pick-ups. Today I go over how I implemented a new enemy with lasers, and a mechanic for enemies to destroy power-ups.
Starting Point & Setup
Today we will be starting right where we left off in 2D Game Dev Journey — Day 23: Aggressive Enemy and Enemy Shields.

To get set up for today, I went ahead and created the enemy type that will represent the new one we create today.

New Enemy Type
Now when it comes to this enemy type, I pretty much am considering it to be a pre-boss. As such, its attack will be a pretty devastating one, but one the player can still feasibly maneuver around. After some code implementations, my pre-boss enemy looks like the following:

As can be seen, each laser does one health of damage to the player if they come in contact. This enemy also does not shoot until it notices the player is within the trajectory of one of its lasers. If the player is detected, it slows down, preps the shot, and then speeds up a bit more once fired. I will probably balance this enemy a bit more in the future, but this is good for now.
Enemies Destroy Pick-ups
For this one, all we want to do is give all of the enemies the ability to do destroy a power-up if they find themselves in front of one. This is where, yet again, raycasts come in handy. After some coding implementation, I got the result below.

Conclusion
Thanks for checking in and reading today’s article. Tomorrow I will be creating a homing missle power-up. If I have made any mistakes, please let me know so I can correct them for future readers. If you would like a more in-depth tutorial about anything I went over today, let me know and I will take the time to write something up.