Enemies
- hard
- Game Development
Instead of just having asteroids that move down the screen, why not add enemies that move across the top of the screen horizontally and occassionally shoot bullets down towards the player?
Task Definition
This is a fairly big task but one that uses skills that you have learned through the week and adds a whole new dynamic to the game.
You could break the task down into something like the following steps;
- Just like with asteroids, spawn a new enemy ship every few seconds.
- Instead of spawning the enemy ship off the top of the screen and moving it down, spawn it off the side of the screen and move it across.
- Make the enemy ship move back and forth whenever it gets near the edge of the screen.
- The enemy ship will need to fire bullets down the screen at the player. Add a ‘spawnEnemyBullet’ function that takes an (x,y) co-ordinate for where to spawn the bullet.
- Try the function out and use it to spawn some enemy bullets going down the screen at the player.
- If an enemy bullet hits the player - you you should destroy the bullet and make the player lose a life!