Skip to content
This repository was archived by the owner on Sep 24, 2022. It is now read-only.

Game Design

yijiacc edited this page Apr 4, 2021 · 11 revisions

A game is composed of Map, Players, Candies, Tiles, Game Items.

Map

Map is a 2D gird, which contains candy and tiles. A grid is composed of cells, each of which has its own row and column. A player can stand or walk on top of the map, but not necessarily stay inside a cell.

The Map scans the whole grid during each Update() call in order to detect potential changes to the cell, such as chained candy explosion and tile breakage. Players can also retrieve game items from the map when their positions overlap over the cells where the items are located at.

Necessary locks are in place to prevent concurrent map modification error caused by asynchronous events released from pubsub.

propagateExplosion

propagateExplosion means when there are two candies next to each other (not really at the same time), if the first dropped one explodes and hits the second dropped one, the second one will then start exploding.

Player

A player currently has 4 states, standing state, walking state, trapped state, and dead state. Each state can transform to certain other states.

Standing State

A player starts at standing state. When direction keys are pressed down or held, the player will enter walking state. When those keys are released, the player will get back to standing state, facing in the direction of the last key press.

Walking State

Once a player enters walking state, the player will try to move in the direction of key press.

MoveChecker

MoveChecker is a field of sharedState. It checks if a player can move in the direction of the player's key press.

Given a player's position in the map, we first get all corner cells of the player's position. Based on corner cells, we can get the neighbor cells and then find all cells that have blocks. In this way, we can decide whether a player can move or not.

Trapped State

A player enters trapped state when he/she is hit by exploding candies. In trapped state, the player is stuck inside of a jelly and loses the ability of walking around or dropping candies.

Dead State

A player will enter dead state unless he/she is saved(e.g. using First Aid kit, saved by teammates) within 5 seconds while in trapped state. A tombstone will appear on the map and disappear after 0.5 second. A player can resurrect in future game modes.

Candy

A candy will explode 5 seconds after it is dropped.

Melting state

After a candy is dropped, the candy is then in the melting state

Exploding state

When a candy is in melting state over 5 seconds, it will then be in the exploding state and start exploding to up, down, left, and right 4 directions.

candyRangeCutter

When the candy explosion reaches to a breakable tile, candyRangeCutter will stop the explosion at the tile.

Exploded state

When a candy finishes exploding, exploded() return true

Game Item

Game items are randomly generated for each tile at the beginning of each new game. A game item will be revealed from a tile when the tile is hit by an exploding candy.

A player can pick up game items which they are revealed. Game itmes collected will be shown in the backpack located at the bottom of the screen. Some game items can be used automatically upon pick up. The others can only be used when the player presses number keys.

CanAutoUse

Power item can increase the power of the player's candy, which means his/her candy can have a larger explosion range. For example, a player's candy can explode at most 1 cell horizontally and verfically. After he/she gets one power item, his/her candy can explode 2 cells.

SpeedType

Speed item can increase the player's walking speed.

Candy item can increase the candyLimit of a player(the maximum amount of candies a player can drop). For example, if a player can drop 2 candies at a time at the beginning of the game, after having 2 Candy items, he/she can drop 4 candies at the same time.

CannotAutoUse

FirstAidKit

A player can use FirstAidKit to save himself/herself when trapped in the jelly.

Guidelines & Processes

Codebase

Testing

Infrastructure

Clone this wiki locally