It was the appeal of video games that got me into programming in the first place, really, as was the case for much of my CS131 class at the University of Montana. It turns out that making video games has almost nothing to do with playing video games, so many of my classmates didn’t continue with the program. I made a Tetris clone once, but that was the extent of my ‘game development,’ since PHP and C# CRUD apps are worth money to business and government customers and games aren’t.
But since I wanted a well-defined problem in an understood space, Unity beckoned. They provide top-notch tutorial projects, one of which is building an arcade-style “space shooter,” of the sort I loved to play as a kid.
The tutorial walks you through creating a player spaceship, adding the ability to shoot lasers, and providing some asteroids as hazards to avoid and destroy. However, the assets they provide with the tutorial also include an enemy spacecraft, and in the interests of illustrating that I can do more than just follow directions I decided to add him to the game as well.
Again, this isn’t perfect. The idiomatic design pattern for the project is to spawn the lasers a short distance in front of the spaceship using a GameObject to hold the offset, and I spawned the enemy laser by using an offset in a script. You can shoot down the enemy lasers since I re-used the collision detection from the asteroids, which is either cool or silly. And it might be nice if the enemy ship moved around, or if I used the assets provided to create some variety among the asteroids. If this were a production game, we’d want progressive difficulty and probably a persistent high-score system. As it stands, though, I’m happy with the project for what it is.
You can play the game here, or you can follow the tutorial to create your own game.