Create a new scene with Node2D as root
Rename it to EnemyContainer
Add a Timer node as child
Add a new Script to EnemyContainer
Set up a variable for the enemy scene
Set up a reference to the Timer node
Set up variables for all of the animation frames
Set up variables for each of the different
Set up variables for the grid of enemies
We leave 100px gap between each row and column
Set the starting position of the grid of enemy
Top left corner of the grid starts in the centre
Finally set the screen bounds
Create a function to assemble the sprite frames
Create a new SpriteFrame resource
If it doesn't already have a default animation - Add it
Add the first frame to the default animation, duration is 1.0s
Add the second frame to the animation, duration 1.0s
Return the assembled SpriteFrames
Add a function to create the 3 individual frames
Build the squids, crabs and octos
Add a function to spawn enemies
Create a nested for loop to create the rows and columns
In each row and column
Create a new enemy scene
Create a variable to access the AnimatedSprite2D of the enemy
If you are in the first row create a squid
If you are in the second or third row create a crab
If you are in fourth or fifth row create an octo
Play the default animation
Pause the animation
Calculate the starting position of each enemy
Place the enemy
Add them to the scene
Create a function to move ALL the enemies
Move the enemies by 20px at a time
Set a variable to check if they hit the screen edge
For each enemy in the group
Change the animation frame as they move
If you hit a wall on the left or right
Exit the loop
If you hit a wall
Reverse the direction
Shift ALL enemies down
As enemies get closer to player
Increase their movement speed
Select the MoveTimer node
Connect the timeout signal
Create the spriteframes and
Add a Player to the scene
Set the position to the bottom centre