2048
The classic time-killing game that merges equivalent value tiles.
In the game's constructor the initial tiles for each direction (i.e. the tiles along the top edge for up, right edge for right, etc.) is stored.
When a direction is played, the grid is traversed with each value from that row/column inserted into a temporary array. The temporary array's values are merged and shifted to the front of the array before being re-inserted into the game's state in the correct order.
If more than one line has moved, a new tile is added in a random empty cell. There is a 90% chance the new tile is a 2 and a 10% chance that it is a 4.
The game detects keypresses on desktop, as well as swipes on mobile devices.