I want to make maze game. I have the idea to 'leave' bitcoins in some rooms and players can pickup it like a penny from the street. And question is how to do it?
In a normal video game, in order to transfer an amount between two quantities, you can simply declare it in code.
var amountHeldByCharacter = ??; var amountInJar = ??; //Change amounts amountHeldByCharacter = amountHeldByCharacter + amountInJar; amountInJar = amountInJar - amountInJar;
In the game, however, the bitcoin will have to come from actual bitcoin addresses, so you'll have to have some function within your code,(call it PAY) that connects externally to the blockchain and transfers bitcoin from the game to a the user's address.
var gameAddress = "<some address connected to the game>"; var userAddress = "<some address provided by the user>"; var amountInJar = ??; //Change amounts -- PAY(fromAddress, toAddress, amount); PAY(gameAddress, userAddress, amountInJar); amountInJar = amountInJar - amountInJar;
How to implement the PAY function is the hard part, but that seems to answer the essence of your question.