I'm busy with this myself. I will charge for the game/app and buyer will be issued with a software license. Some will be valid for a month(trial) others a year etc etc.
You can sell, or even offer free - the choice is yours.
Easy digital downloads plugin. [free]
Easy digital downloads extension (software licensing) [$82]
This postto teach you how to interact with mysql database. (I know its multiplayer, but it teaches you how to connect to database, how to send and recieve data)
You need to be able to send / recieve data using the Software Licensing Extension API.
Sidenote: the extension is written more for wordpress theme/plugin developers, but can be used or anything that requires a licensing system with a little out the box thinking.
I am actually stripping it down (writing my own so to speak) and adding in a few more features to make it work better with C2 (this is for my own needs, not for sale) besides it will take me some time as it is a side side project.
Also, woocommerce (also a shopping cart system) has an extension for licensing (more expensive) I didn't go for woo for a number of reasons, but you might like that option too.