Skip to content
Levi Webb edited this page Sep 17, 2015 · 6 revisions

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:

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.