Technology to take you into the game world, how to restore the progress of the game

Source: Internet
Author: User
Keywords Mobile games internet games game consoles
Tags change consoles data design development development team file game

Many people like to play games, but the game as a complex art form, its production principle is not understood by the majority of players; and game development team design, art, operations and other non-technical practitioners, many Time will also question the principles of game development.

I often feel distressed for the second thing above, because this is a seemingly normal situation that has a significant impact on the final quality of the game. To solve this distress, I talked to these non-technical colleagues for several lessons in an attempt to tell the story of technology in narrative language and more concrete expressions. After a period of accumulation, there are several essays in this series. Each essay is a simple introduction to a specific topic in game development.

Some time ago there is a very hot microblogging game "2048". Let's take it as an example and continue talking about the state of the game. If you have not played this game, just play, we see after nine hours.

The so-called state, is the value of all the parameters of a game at a particular moment.

The Fruit Ninja parameter is the location of a watermelon or the speed of a banana, while the 2048 parameter is the 16 numbers on the grid. At any one time, the state of the game can be expressed in 16 numbers:

Here 0 means there is no number on this grid.

When the game is running, your iPhone will make a space in its own memory to store the 16 numbers. Given that a handful of readers here are not programmers, I think it is necessary to explain this sentence. We can think of memory as a huge wall with countless drawers on the wall and a number for each drawer. What you just said is that your iPhone will open 16 drawers on the wall and place the top 16 numbers in the drawers one by one. Finish the matter, "2048" the first state appeared. Then, the game begins to receive your input, change state (ie, change those numbers in the drawer), receive input, change state, and so on. Every state is like a glimpse of life, fleeting.

Just when you are playing very high, your good friend called a base to talk to you about why people want to live this problem, you talked for a long time, until the phone chatted, you suddenly remembered what you just Only a few steps to reach 2048! Waiting for you shaking hands with the iPhone plug in the power, hopefully open the game again: rub! Progress gone!

Why? Because after the iPhone restarts, the numbers in the memory drawer will be cleared, meaning that when you reopen the game, it does not know what the last state was, Start.

How to do? It does not matter, we have a hard drive.

We might as well understand the hard drive into the other side of the larger wall, the wall more drawers, and these drawer numbers will not be cleaned up because the iPhone restart. In order to restore the progress of the game, we have to base the Friends of the caller, put the memory drawer copy number stored in the hard drive drawer, the machine once restarted, we can copy the hard drive drawer to be cleared In the memory drawer. This game can know the status of the machine before rebooting is what.

The process of copying data to the hard drive is called persistence, as the name suggests, allowing the state of the game to persist on the hard drive. There are many ways to persist the state, we can put these data in a text file or database. If we persist the state of "2048" as a text file, after persistence, you will find a file called "Game Status .txt" on your iPhone's hard drive. Open this file and you will find 16 Number.

Here to say, this series of essays is easy to read rather than detailed for the purpose, that persistence of this matter, in fact, it also involves data encryption and many other processes, not to repeat them here; In addition, this series is not To develop a tutorial, if a programmer dares to name the file "game state .txt", I believe he will soon be burned by his colleagues.

Speaking of forever in the word, many people want to add two words in front of youth. In the movie "Avatar," the protagonist transmits all the information in her brain to Avatar's brains before the movie ends, and it leads to a happy and happy life. This process has a saying called Mind Uploading, is the transmission of information in the brain to other media meaning. Futurist, Google Technical Director Ray Kurzweil, said that by 2045 human beings could perpetuate their brains into computers and avoid death. If fortunate (or unfortunate?) He was made, then you, thirty years later, we see in memory.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.