This on-going greenfield SDK and game project has been programmed from scratch using Kotlin, unit tested and released using the GitFlow branching model. Its final objective is to help mental health patients work out their mental habilities driving them to a health improvement.
SDK & initial game: MVVM pattern, custom Canvas, shapes enum with abstract methods and fragment callbacks
An SDK built from scratch to allow build multi screen games around shape types, colors, sequences and their rotation.
The goal behind this project is to let a gamer cycle shapes to achieve a certain sequence of shapes and colors and "kill" them. On the upper side of the screen the player sees a sequence of shapes. One, two or three of them are surrounded by a green layer to inform the player of the seek sequence. Pushing on the screen, the player adds shapes of random type and color. The Goal is to "long press" a shape as in the given sequence to kill it and get points.
✔ Write a Clean Code Architecture project
✔ Use Google Architecture components with a MVVM
✔Extend View & create custom widget
✔Handle touch events & business logic in View Model
✔ TDD & addition of recommendable tests.
✔ Use logs to prove performance & assumptions
✔ Benchmark game & architecture performance with one or two custom views
✔ Add Artificial Intelligence to reward player & train frequent failures.
✔ Justify medically game objectives & their acquisition.
✔ Validate gamer/patient habilities improvement.
✔Create a multi screen game using the SDK
✔ Done -> Explained in this article
✔ On going -> Detailed in a coming article
✔ Pending -> Dealt in a coming article
✔Enable & disable bombs on first shape (sg-32)
✔Change button behaviour to work as shape killers (sg-31)
✔Compare performance using 1 or 2 views (sg-29)
✔ Shapes can be added at a pushed coordinate (sg-28)
✔ Game rules progress from left to right. (sg-27)
✔ Draw a square around the shapes that are needed to win. (sg-26)
✔ Allow Game Rules to have a wanted length. (sg-25)
✔ Change game rules every given seconds. (sg-23)
✔ Allow to undelete only previously existing shapes (hot-fix)
✔ Refactor margins to allow rotated shapes appear complete (sg-22)
To allow the creation of multiple screens of changing difficulty and challenges, the project has worked in the first place in the SDK. The following lines explain and show a short video of the current developed functionality. This blog-post is beeing periodically updated.
Shape rotation
When clicking on a shape, this changes to the next one in a cycle.
From circle to triangle, from triangle to square and from square to circle.
Additional shapes could be added by adding new enum cases and implementing abstract methods for them as appropriate.
Pushing the undo button cycles the shapes back.
Shape selection
Long pressing on a shape outlines it with a color. If the selected shape belongs to the game rules on the top of the screen, it will be outlined in green. If the shape color matches that of one shape on the game rules but the shape is wrong, it will be outlined in yellow, meaning it can be fixed. Last, if the shape selected is not in the game rules, it will be outlined in red.
Playing the game
The screen is divided into two parts. The upper one or the "game rules" and the lower one, or the "game zone".
The goal is to achieve the "game rules" on the shapes we select on the "game zone".
By selecting shapes in the color given in the "game rules", the shapes will be killed and we will score points.
Move shape
Shapes can be moved around in the screen to kill shapes of equal type.
Also the user can place them in a more confortable location on the screen to help achieve the current game rules.
Kill equal shapes
Shapes of equal type and color can be killed any time, by moving one on top of the other. This feature can help the player "clean" the screen and grant the player a different amount of "points" than pairing it with shapes as per the upper game rules.
Undoing actions
All actions can be undone. Cycling a shape can be undone by clicking the undo button and resulting in the previous shape type. Adding or moving a shape can also be undone. Pairing shapes of the same type or meeting the game rules also can be undone.
Shape bombs!
Bombs allow to kill all shapes on the screen of a given type. For example we can kill all circles, all triangles or all squares and it doeesn't matter of which color are they.
Last updated October 2022.
Rotated shapes
Shapes can also have a rotation angle, in which case they have to meet the rotation angle of the "game rules" pattern (on the upper side of the screen game). In the example below, the selected shapes have a rotation of 45º whereas the one on the rules are not rotated, thus, they are not killed.
Rules length
The upper side of the screen displays the "game rules", the shapes that need to be matched in order to score points. The game starts with one shape and it increases complexity with two and three shapes. An additional level of complexity requires the shapes to be selected in the exact given order.
Shape bombs!
Bombs can only be enabled when that type of shapes are on the screen. The Fragment observes viewModel Livedata and updates the binding (using view bindings).
Last updated September 2022 (sg-32).
Project features have been documented in a Jira project and each branch named as per the ticket number. Branches when finished have been tested and merged back to develop. A few branches result in a new release. Releases are documented in the GitHub and also in a changelog, where each of the branches and features developed are quickly summarized.
Each feature is documented in Jira and also in a CHANGELOG that belongs to the repository. The image below displays how the changelog has evolved. It summarizes what each brnach does, which branches belong to which release and also when a hot-fix was created and deployed.
A 90-95% Unit test coverage percentage has been added for application code
Junit Test sample code
A 90-95% Unit test coverage percentage has been added for application code
Spliting the project in multiple layers and using the MVVM pattern has helped achieve the goals of the project. The code could be easily refactored when the initial requirements had to be refined or those had changed as time went by. The created Junit tests helped ensure the functionlaity remained stable when changing the specifications.
The video below shows all the functionality when playing the game. You can see how shapes can be added, rotated, moved, "bombed" (kill all shapes of one type) and the game sequence achieved (achieve the game sequence results in deleting the shapes from the screen).
Last but not least we can see how all actions can be undone when pushing the undo button multiple times.
Marc Farssac
WeWork - Espai d'oficines i coworking
Carrer de Tànger 86
08018 Barcelona
Catalonia, Spain
E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
Mobile: +34 644 22 00 88
Landline: +34 93 460 86 39