Remember Maronic, the platformer we were designing in Chapter 3, Understanding Structural Patterns, while discussing the Facade design pattern?
Well, canary Michael, who acts as a game designer in our small indie game development company, came up with a great idea. What if we were to give our hero an arsenal of weapons to protect us from those horrible carnivorous snails?
Weapons all shoot projectiles (you don't want to get close to those dangerous snails) in the direction our hero is facing:
enum class Direction {
LEFT, RIGHT
}
All projectiles should have a pair of coordinates (our game is 2D, remember?) and a direction:
abstract class Projectile(private val x: Int,
private val y: Int,
private val direction: Direction)
If we were to shoot only one type of projectile, that would be simple, since we already covered...