-
Notifications
You must be signed in to change notification settings - Fork 8
Minesweeper
Minesweeper is a fun game that is installed on computers by default, but it's also a great example of the cool things you can do with the graphics API and a good knowledge of Lua. You can check out the source code for /bin/minesweeper
and /lib/minesweeper_block
here:
Minesweeper, Minesweeper Block
We use the minesweeper_block
's table called Block
, and we create prototypes with it with the function Block:new(...)
. This is similar to object-oriented programming in languages like C++ and Java, just a lot more barebones. Each tile in Minesweeper has its own Block
table, which can interact with other blocks from the game.
Also, in minesweeper
's start()
function, we see how a main loop can work using custom buffers and input polling, without having to introduce coroutines or threads for handling our own sessions.