<p>In a normal video game, in order to transfer an amount between two quantities, you can simply declare it in code.</p>

<pre><code>var amountHeldByCharacter = ??;
var amountInJar = ??;
//Change amounts
amountHeldByCharacter = amountHeldByCharacter + amountInJar;
amountInJar = amountInJar - amountInJar;
</code></pre>

<p>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.</p>

<pre><code>var gameAddress = "&lt;some address connected to the game&gt;";
var userAddress = "&lt;some address provided by the user&gt;";
var amountInJar = ??;
//Change amounts -- PAY(fromAddress, toAddress, amount);
PAY(gameAddress, userAddress, amountInJar);
amountInJar = amountInJar - amountInJar;
</code></pre>

<p>How to implement the PAY function is the hard part, but that seems to answer the essence of your question.</p>

CC BY-SA 3.0
2014-11-14T23:45:57.423Z
2014-11-14T23:45:57.423Z
John Henry
<p>I believe the best solution will to use in-game currency (in fact many MMO games have such), that can be withdrawn to bitcoins, just like online casinos are cashing out their chips. </p>

CC BY-SA 3.0
2014-11-26T00:55:15.727Z
2014-11-26T00:55:15.727Z
ElRey777
<p>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?</p>

CC BY-SA 3.0
2014-11-14T15:47:22.467Z
You need to be more specific. What part are you having trouble with? What have you tried? Creating a web-game is a broad topic.
Nick ODell
<sell-bitcoins><trade>
Give bitcoin to user in web game
wytrzeszcz
# Give bitcoin to user in web game

(Asked by: username_0 on 2014-11-14)

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?

**Tags:** sell-bitcoins, trade

> **Comments:**
> **username_1**: You need to be more specific. What part are you having trouble with? What have you tried? Creating a web-game is a broad topic.  

---

## 2 answers

### Answer by username_2 on 2014-11-14. Score: 0

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.


---

### Answer by username_3 on 2014-11-26. Score: 0

I believe the best solution will to use in-game currency (in fact many MMO games have such), that can be withdrawn to bitcoins, just like online casinos are cashing out their chips.


---

