What is the game about?

Last year I developed a demo game in which you play a soldier that needs to fight some animals to lvl up. You spawn in front of a wall which shows a 150 sat LN invoice as a QR code. You can pay that invoice with your mobile LN wallet or click it to copy the invoice to clipboard and pay with your desktop wallet. When the invoice is paid, the LN node will notify the game client and open the wall. With LN payments you also spawn monsters, buy weapons (apples, bananas kiwis) or buy a new life. You can even open a toilet with a LN payment which will make some BCH coins fall into the toilet (https://twitter.com/BR_Robin/status/1134944539440029696)

How does it work?

That game was made with the Unity Game Engine and the Donnerunity API from twitter user @sputn1ck. I am running a LND node on a raspberry pi. I used an API which lets me connect a Unity game with my LND node (https://github.com/donnerlab1/donnerunity). I hard coded my invoice.macaroon into my source code and also the URL to my dyndns which points to my raspberry pi. When someone runs the game, it will try to connect to my raspberry and talk to my LND node via the invoice.macaroon. It will request some invoices (e.g. 150 sat with memo "entry"). That invoice in form of a string is now being displayed as a QR code inside the game and can even be clicked for fast copying. Whenever that invoice is paid, my LND node will inform the game client and a certain action happens. The code looks a bit like this

void invoice_paid(string invoice_memo) { if(invoice_memo=="entry") open_door(); if(invoice_memo=="penguin 6") spawn_penguin(6);

if(invoice_memo=="whatever") { /basically trigger whatever action I want inside this bracket/ } }

With this I can basically do any action in the game and use a LN payment as the trigger.

Unfortunately I often had issues with my LN node, so it could be, that the game doesn't work properly. So I made it possible for anyone to connect to his/her own node (so testnet is possible too). For more information, please see my original github README below.

My inspiration

In the 2017 bullrun with abnormal high fees I almost gave up hope for Bitcoin because like this it would never get adoption. I then found out about the LN but didn't care much. Then I saw the following video on youtube in which someone paid a LN invoice inside a minecraft game (https://www.youtube.com/watch?v=I7qgYkd7Qsc). Not much happened here, but this video showed me the huge potential of Lightning and Bitcoin as a whole. In August 2018 a twitter user @sputn1ck published his Donnerunity Plugin which made it possible to integrate lightning payments into any unity project. I had never used Unity before, but I gave it a try and it was super easy to implement LN payments. I just had nothing to show in that project. I programmed a cube, wrote a move_away() function and triggered that function with a LN payment. It worked!!! I realised that this is the future of ingame payments and I wanted everyone to try this out. But I don't know how to create websites to show that demo in a simple way. Websites like satoshis.place a great to show LN payments because you can just go on a website and scan the invoice. But I knew, noone would download my unity program (an .exe file) just for moving a cube. So I decided to create some more features until finally a whole indie game was created. I still call that game a demo, because it's not something you would be playing for fun. But it is a very good way to test out Lightning payments and see how this can change the gaming industry.

I published my game in Mid-January 2019 and got a huge huge feedback on twitter and reddit (https://twitter.com/BR_Robin/status/1086648655459876869) I spent so much time on this game. The Lightning part was very easy, but the game itself took months. I did not want to continue programming, because of my limited time. BUT!! After the huge feedback I decided I want to continue!! Programming is just a hobby for me and I have been a programmer for about 10 years. I had never published any of my projects before. But now I did and it was the first time that others appreciated my effort. Someone even made a review on YouTube which made me really proud (https://www.youtube.com/watch?v=kKXjiowmbSQ) I decided to continue developing Lightning based demo games.

What did I learn?

Writing a game is not as easy as it seems. I was new to unity, so I learned how to use that game engine from scratch. I knew C++ before, so C# was not that difficult. The most important thing I learnt was that anything is possible with Lightning. It is now possible to have money, that can be electronically sent via the internet and anyone in the world can write code on top of it or use its functions. Anyone can write a program and trigger certain actions (if (is_paid) do_something()). You can finally make money programmable. The game part took much much time, but integrating Lightning was super easy. There are thousands of indie game developers out here who have games which are a thousand times better than mine. Commecialising that game with LN would take them 30 min if they know how to do it. I see a very bright future for Bitcoin and Lightning Technology and I am proud to be one of the early adopters.

The following is the original Readme from my Github repository.

PenguinShooter - A Lightning Network enabled RPG which displays LN invoices within the game.

It is a simple demo RPG in which you fight monsters and lvl up. You will see LN invoices as QR codes in the game and scan them with your mobile wallet or click them which copies it to clipboard for fast desktop payments (for example with Zap wallet)

You can open a door, spawn monsters, buy items etc. with small Lightning Network payments. https://www.youtube.com/watch?v=ZCOwVHUmIT4

In this version you can now connect to your own LND node which makes it basically free. You can also connect to a testnet node. By default you will be connected to my personal (mainnet) node 02b94191cd26b1b8650b1204371ee65aa8725ca56474efbb629240a41d4bf7fec0@penguinshooter.chickenkiller.com:9735

This is also a demo game to show how livestreaming could become more interesting. You can setup a webserver which creates invoices to your livestream viewers. When they pay these invoices, something will happen live in your stream. Some payments help you (e.g. buy you items) and some are bad (e.g. freeze you for some seconds). If you are connected to your own node, you as the streamer can keep that money that you earn while playing.

Link to the webserver https://github.com/Donno1994/PenguinShooterWeb

Medium article of livestreaming features https://medium.com/@BR_Robin/user-intervention-in-livestreams-via-ln-penguinshooter-5e12bdcece49

Video Examples: https://www.youtube.com/watch?v=gTuWi-WNynQ&t=1s

To play this game you need a Bitcoin Lightning Wallet. To setup a LN node on a Raspberry Pi, follow this guide https://github.com/Stadicus/guides/blob/master/raspibolt/README.md . If this is to hard for you, you can use https://bluewallet.io/ as a custodial solution. You also need a windows computer.

To connect this game with your own node, you need the LND implementation of LN https://github.com/lightningnetwork/lnd Important are the invoice.macaroon and tls.cert

Instructions to play this game (connecting to the LN node of the developer)

  1. Download this repository.
  2. Open the PenguinShooter-master folder and run PenguinShooter.exe The game will now boot and connect to my LND node. If successful, it will display a QR code at the wall in front of you.
  3. You now have to pay the invoice at the wall (150 sat). You can either use your mobile wallet and scan the QR code, or you can click on the QR code (which copies it to clipboard) and paste it into a desktop LN wallet.
  4. For gameplay visit https://medium.com/@BR_Robin/a-bitcoin-lightning-network-powered-rpg-penguinshooter-6d36cc34de0c

Instructions to play this game with your own node (testnet and mainnet possible)

  1. Download this repository
  2. Enter the folder PenguinShooter-master\PenguinShooter_Data\Resources and open the donner.conf
  3. Enter the information about you LND node. Replace "penguinshooter.chickenkiller.com" with the IP address of your node. If it is on the same computer as you run the game you can enter "127.0.0.1". If it's in the same wifi network (e.g. if you have the node on a rapberry pi) you can use something like "192.168.2.157" (you need to check the local IP address of the node). Under "Port" enter the port number of your LND node (default is 10009).
  4. Copy your invoice.macaroon and your tls.cert into the same folder as donner.conf. You can find this in your LND folder under ".lnd/data/chain/bitcoin/mainnet/invoice.macaroon" and ".lnd/tls.cert"
  5. Start the game and see the instructions above (connecting to developer node)

If you want to test the webserver which generates a normal internet webpage and generates invoices, check out https://github.com/Donno1994/PenguinShooterWeb If you want to test livestreaming, you can connect your own node and keep the money that you earn. I know, this game is not the most interesting one, but I hope it's a nice demo on how livestream viewer integration could work with Bitcoin Lightning Network.

This project was made by https://twitter.com/BR_Robin and the Unity Game Engine. I used the open source API from https://twitter.com/sputn1ck from https://www.donnerlab.com/ . You can find that API on https://github.com/donnerlab1/donnerunity/ Also check out his LN powered game when he plays donnerdungeon live on https://www.twitch.tv/donnerlab (checkout his twitter for the exact times)

I am a hobby developer who works on this project in his spare time. I created this game for fun to show the use cases of LN in games. The game itself has some flaws. My LN node might be offline or payments could go through but you see nothing (hopefully it doesn't happen) If you find bugs or have some other criticism, you can use the issue function on github. I will try to fix them.

If you have some ideas that I could implement, let me know. I am especially interested in new features that the viewers can pay to help or annoy the streamer.

I hope you enjoy this game and can already see how the Lightning Network can completely change the gaming industry.

Built With

  • asp.net
  • c#
  • https://github.com/donnerlab1/donnerunity
Share this project:

Updates