Learn to Create your First Video Game based on Ethereum

in #busy6 years ago

If you are attracted to smart contrats, and you would like to know how to create your first video game based on #Ethereum, you have to know http://cryptozombies.io/es.

You'll learn:

How to write smart contracts in #Ethereum
Schedule in #Solidity, the #Ethereum intelligent contracts programming language
Build games in #Ethereum
Do you want to create your own #CryptoZombie and add it to your rows?
Learn how to create your own games in #Ethereum #GRATIS with #CryptoZombies!

It's amazing to create your own #video game based on #Ethereum

123.png

I have completed Lesson 1 of #CryptoZombies and have learned the basics of programming a game in #Ethereum. Take a look at the first zombie in my army!

https://share.cryptozombies.io/es/lesson/1/share/Jose_Poveda

1234.png

6.png

Chapter 1: Tokens on Ethereum
Let's talk about tokens.

If you've been in the Ethereum ecosystem for a while, you've probably heard about the tokens - specifically, the tokens # ERC20.

A token is basically an intelligent contract that follows some common rules, that is, implements a standard set of functions that share the rest of tokens (contracts), such as transfer (address _to, uint256 _value) and balanceOf (address _owner).

Internally, the intelligent contract usually has a mapping (address => uint256) balances, which tracks how much balance each address has.

So, basically, a token is just a contract that tracks who owns the amount of that token and some functions so that users can transfer their tokens to other addresses.

Why does it matter?
Since all tokens # ERC20 share the same set of functions with the same names, everyone can interact in the same way.

This means that if you create an application that is able to interact with a token of type # ERC20, it will also be able to interact with any token of type # ERC20. In this way, more tokens can be easily added to your application in the future, without having to have custom codes for each of the token types # ERC20. You can simply connect the new contract address of the token and boom, your application has another token that you can use.

An example of this would be an exchange (house of change). When an exchange adds a new token # ERC20, you really only need to add another smart contract to communicate with. Users can instruct that contract to send the tokens to their wallet address in the exchange, and the exchange can instruct the contract to return the tokens to the users when they request a withdrawal.

The exchange only needs to implement this transfer logic once, then, when you want to add a new token # ERC20, it is simply a matter of adding the new contract address to your database.

Other token standards
The ERC20 tokens are really great because they act like coins. But they are not particularly useful for representing zombies in our zombie game.

On the one hand, zombies are not divisible like coins - I can send you 0.237 ETH, but transferring 0.237 from a zombie does not really make sense.

Second, all zombies are not created equal. Your level 2 zombie "Steve" is not equal to my level 732 zombie "H4XF13LD MORRIS 💯💯😎💯💯". (Nor are you close to being, Steve).

There is another token standard that fits much better with crypto-collectibles like #CryptoZombies, and they are called tokens # ERC721.

The tokens # ERC721 are not interchangeable with each other, since it is assumed that each of them is totally unique and indivisible. They can only be exchanged in complete units, and each one has a unique ID. So these are perfect for making our zombies tradable.

Note: Keep in mind that the use of a standard such as # ERC721 has the benefit that we do not have to implement the logic behind the system that allows buy / sell operations in our contract, and that determines how players can buy / sell our zombies. If we comply with the specification, someone else could build another exchange platform for assets # ERC721, and our zombies # ERC721 could be used on that platform. Therefore, there are clear benefits in using a standard token instead of developing your own business logic.

Put it to the test
We are going to deepen the implementation of # ERC721 in the next chapter. But first, let's configure our file structure for this lesson.

We will store all the logic # ERC721 in a contract called ZombieOwnership.

Declare our version of pragma at the top of the file (check the syntax of the files from the previous lessons).

This file must make an import of zombieattack.sol.

Declare a new ZombieOwnership contract, inheriting from ZombieAttack. Leave the body of the contract empty for the moment.

fin.png

https://share.cryptozombies.io/en/lesson/5/share/Seiro?id=Z29vZ2xlLW9hdXRoMnwxMDQ0NDU3NDkxMDQ4OTI1NTI1ODA%3D

Finally I learned:

By completing Lesson 5 of CryptoZombies, your friend learned about:

Tokens, the ERC721 standard and create tokens / tradable assets
Solidity libraries and how to use them
The SafeMath library and prevent overflows
Comment the code in Solidity and the natspec standard

Lección 6 estará disponible, en las próximas semanas.

Es un juego bastante difícil de pasárselo, tienes que tener conocimientos técnicos. Te sirve para aprender el potencial que tiene el #blockchain.

I would like to receive your #Upvote and your comments. Thank you

Sort:  

This is great! I've been looking into making a Crypto game. Thanks!

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.029
BTC 66703.61
ETH 3518.80
USDT 1.00
SBD 2.68