First days of app development are always filled with possibilities. But being distracted by say overthinking the revenue model is not something conducive to execution. I knew from experience making an app in the beginning is also overwhelming and so focusing on one goal at a time is a great way to start. Since I needed fruit art I got to work right away in Gimp. While making flat fruity pngs I thought about the features of the MVP and the game architecture but all while making the images.
I pumped out seven flat fruits (Apple, Cherry, Strawberry, Pineapple, Grapes, Watermelon, and Orange) destined to be both an enum type and its own Fruit class.
This took me all morning. Making Highlighted versions was faster since adding a Glow to a layer is very mechanical in Gimp.
The rest of the afternoon I spent on the model. This involved making the Fruit enum and Fruit class. The enum knows the filename of both its normal and highlighted texture atlas image. The Fruit class knows its position in the game board, what fruit type it is, as well as the sprite. Since these fruit objects will be used in Sets and Arrays they should have the Hashable protocol which involve both being able to return a hashValue (constructed from its row and column to make it unique) and be comparable (==) based on its position in the game grid.
These Fruit objects need to be kept in a data structure and a generic array that uses this Fruit class makes the most sense. The Array2D would know how big it is (columns and rows) as well as providing subscript access so that we can access say the fruit at column 3, row 2 with a friendly fruits[3,2] syntax.
Finally, the Level is a model class that maintains a private Array2D property of 81 fruits making up the ColumnsxRow game board. Having some functions that initially create random fruits to fill-up the custom array is always a good idea for testing the data structure before any game logic is even constructed.
I pushed the images and model into my repo. Tomorrow I’ll invoke the model from the GameViewController and see how it looks.