Hello everyone! Here’s a progress update on the Galaxy Shooter project.
Prototyping first is a key element when starting a project. We don’t want to be bogged down with the visuals first and then logic after. Therefore, we don’t want to waste time on the visuals and then later find out that the game is not fun.
I created a cube for the player and attached a Player script to it. I then went ahead to program the input so that the player can move!
Now that the player can move, I want to restrict the player from going past the edge of the top and bottom screen. So I restrained the vertical axis of the player.
For the x-axis, I want the player to wrap around instead. To create that illusion, when the player reaches past the edge of the left or right screen, the player’s x position changes to the opposite side of the screen.
I then implemented the shooting mechanics. I created a projectile game object with a Projectile script and set it to be a prefab. The logic of the projectile is for its position to translate upwards every time it is instantiated by the player.
When I hit the space key, the player will now shoot projectiles with a cool-down system. This way I am not able to shoot infinitely by pressing the space key consecutively fast.
To spice it up a bit, I created an enemy game object with an enemy script. Since I want the enemy to keep spawning from above, I turned the enemy game object into a prefab so we can instantiate it numerous times.
When spawning, I want the enemy to automatically translate its y position to move down. I also want it to spawn randomly from above and when it reaches off-screen at the bottom, I want it to change its y position, randomly, above again.
Now that we have the player and enemy setup, I went ahead and added a collision system and a life system. When the player rams into the enemy, the enemy destroys itself and the player loses a life or destroys itself if there are no more lives left.
When the player shoots at the enemy, the projectile and the enemy will register that they both collided and as a result destroy themselves.
It is starting to shape up I would say! The next thing I need to do is to set a spawn system.
Thank you for reading!