The Goal: Create a game mechanic or mini-game in under a week that involves the Factory Method Design Pattern in the code's implementation.
1. What does the player do in the game that determines which Creator class is used to create objects?
Not only is there a random enemy spawner which starts when the player starts the game, but there are different colored powerups that, when picked up by the player, determine which creator class is used to create and spawn either allies or enemies.
2. What determines which Product object the Creator class creates (with the Factory Method design pattern) while the game is running? Does the player choose the object or does the game choose the object based on something the player does? In other words, what sets the condition that is checked by the factory method?
There’s a string array of enemies that are randomly chosen from when the game needs to spawn in a new enemy randomly. For the powerups, the string is attached to the specific powerup which is passed into the spawner when the player hits the powerup.
3. What were the benefits of using the Factory Method Pattern to make your mini-game?
This pattern made it easier for the powerups specifically to have easy access to spawning in specific allies and enemies. Other than that, making a game with this pattern in mind at least helped me to come up with a game that has multiple different things that needed to be spawned, which is always a fun exercise.
4. Did you find any drawbacks to using the Factory Method Pattern? If so, what were they?
It seems overly complicated for what it’s doing. I don’t see the point of using two different creators for enemies and allies, when I feel like I would’ve written the same amount of code putting them both in a non-abstract SpaceFolkCreator class.
5. What is the player’s goal in your mini-game and what makes it challenging?
The goal in this mini-game is to survive until you reach your “final destination,” which is determined by a timer ticking down in the corner. A secondary goal is to get as many points as possible by shooting down enemies. What makes these goals challenging is that enemies are constantly spawning to attack you, and you lose the game on contact with any enemy or their bullets.
6. How does the game communicate its goal(s) to the player?
The game communicates both the goals and the controls to the player through a “How to Play” section, where the player can click through a tutorial on how to play and win.
7. How can the player fail at the game and how does the game detect it?
The player can fail at the game by getting hit by any of the enemies or enemy bullets before the “timer” runs out. This is detected by an OnTriggerEnter2D function that’s in all of the enemies and enemy bullets.
8. How does the game give players feedback about how well they are doing?
The game gives players feedback by showing them both the score and their current destination as the game progresses. When you lose, the game shows you how far you have left to go.