Shapes Game & SDK

Last updated 22 October 2022

Train memory , logic & mental speed by cycling shapes & pairing colors.

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.

Written by Marc Farssac. Last Updated October 21st 2022 --- (Updated Bugs Fixed section & random videos.)

Objectives

  • 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


Bugs fixed & improvements

Last Updated October 21st 2022 with the repository CHANGELOG. (SG-XY = Jira ticket numbers for Shapes Game Project.
  • 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)


SDK functionality

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.


Updated videos (after improvement or bug fix)

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).


GitFlow release & branching model

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.

Releases changelog

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.

Release

Tags


Junit Test

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

Conclusions

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.


Written by Marc Farssac on June 31st 2021. Last updated May 19th 2022

All functionality in one video

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
Interim Android
Developer & Team Leader


Let's talk now !
+34 644 22 00 88

Get in touch

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

© Marc Farssac. All rights reserved.
Legacy site https://former.mfb.cat.
Find my apps on the Google play store