Day 14. New enemy type improvements. Laser beam.
Today I worked more on New enemy type task. I improved side to side movement. The lower limit point is now generated by a random function. I added the vertical zig-zag movement. I tried to calculate distance first from the base point to turn an enemy into the opposite direction. It had to code too many conditions, especially when the object moves to the side of the screen and appear on another. I decided to remove all code for that kind of movement. I count the time that the enemy moves in one direction, instead of a distance. That was a significant decrease in code.
_movementTimer += Time.deltaTime;
if (_movementTimer > 1.2f)
{
_movementLeftRight = (_movementLeftRight == 1) ? 0 : 1;
_movementTimer = 0f;
}
The next feature I worked on was a superpower.
That is how a laser beam works:
Planning to make something like this soon:
I also did some C# crash course in parallel. Refreshed on if statement.