January 2015
Intermediate to advanced
282 pages
6h 12m
English
Now that we've built all the components required to make an implementation of the 2048 game, let's move on to more interesting things: spawning, moving, and combining tiles.
It's only logical that we begin with spawning new tiles in random empty cells. The algorithm for doing so is as follows:
Board.b), and to the board widget itself (using add_widget()) for Kivy to render it.The sequence of actions should be self-evident; the following Python implementation of this algorithm is also very straightforward:
# In main.py, a method of class Board: def new_tile(self, ...
Read now
Unlock full access