[quote]Yes the aliens fly on and cannot turn around. And yes I was planning to make some preplanned flight paths, initially, but after I will try to add some AI. How could I add some preplanned flight paths?
[/quote]
Most shoot’em ups (with Galaga being a prime example) use a state machine for the purpose of AI. How it works is that the character entity has a state associated with it, then behaves differently based on the state.
Let’s use Galaga as an example. Each ship has three states, with one optional, extra state for the crab ships:
PATH
FORMATION
DIVING
TRACTOR (optional)
When the ships first fly onto the screen, they are in the PATH state. In this state, they follow whatever path is laid out for them. (This path could even be precalculated.) Once they reach the end of the path, they automatically switch to FORMATION state and take their respective places.
From there, some sort of algorithm (whether it be pre-planned or random) decides to occasionally place ships in the DIVING or TRACTOR state. If a ship receives the state DIVING, it begins a dive manuver aimed at the player. This might be as simple as incrementing X and Y until the ship reaches the player, or it might be a curved trajectory designed to confuse the player.
If a crab ship receives the TRACTOR state, it makes a descent and activates its tractor beam. Once the TRACTOR or DIVING state is complete, the ship returns to FORMATION state and makes its way back to the FORMATION at the top of the screen.