AIR Android: Game Design Ideas

Source: Internet
Author: User

The first AIR Android program: flipped black and white games

I have introduced the establishment of the Development Environment. According to the practice of computer application development, it should be the time for "HelloWorld" to come out. Considering that it is not a basic tutorial about programming languages, but a focus on practice, we skip the simple "HelloWorld" to see a more complex instance.

This article will write a complete mobile game and deploy it on your mobile phone. Therefore, we will witness the complete birth process of a mobile program, from program design, code writing, to the final installation. This process involves a lot of technical details of Android development. Readers can also feel the development pleasure of AIR at close distance.

Game Design Ideas

In the current Flash program, casual games account for a large proportion. These games are generally small in size and have simple gameplay, but they are creative and easy to attract users. From a technical point of view, casual games are very suitable for mobile platforms, and facts prove this. Casual Games account for a large proportion in both Google's e-market and Apple's App Store. It is foreseeable that in the future, many Flash games on the network will be transplanted to mobile devices.

The flipped black and white games are a classic intellectual game. The first version I saw was produced by Terry Paton, formerly FlipIt. After the launch of the game, the game became popular. It was released in the Google electronics market and Apple App Store.

The game rules are very simple: several pieces are arranged neatly on the board, divided into black and white. When a player clicks any piece, the piece turns to the opposite color. At the same time, the adjacent piece is also flipped, as shown in 2-1. When all the pawns are white, the system passes the victory. Of course, the fewer clicks, the better the score.

 
Figure 2-1 flip the black and white games

Although it was easy to start with, it was very difficult to really play, especially on a large board. if you don't master some skills, you may not be able to play for a day.

From a technical point of view, the only difficulty of the game may be how to dynamically generate a board map and control the difficulty of the map. There have been a lot of discussions on the network, for example, some people use linear equations to solve the problem. The discussion of game algorithms is not within the scope of this book. The author draws on a level in the original game and uses a 4x4 chessboard. The simulated effect is 2-2.

 
Figure 2-2 board Simulation

After the problem of map is solved, design the game structure. During the running of the program, there is only one type of user interaction action, that is, click an event. Therefore, the entire game logic is clear, and the running process can be divided into the following two steps.

Step 1. Draw a board based on the existing map data and enter the STANDBY state.

Map data can be represented by a 4x4 two-dimensional matrix. Each value represents the color of the pawns at the corresponding position in the initial state, as shown in 2-3. Because only black and white are used, the status of the pawns can be expressed simply by a Boolean value. That is, false indicates black, and true indicates white. Each time you click a piece, the piece to be flipped is not processed logically.

 
Figure 2-3 use a matrix to describe the chessboard

When creating a map, you can easily layout the chess pieces based on the index position of each value in the matrix.

Step 2 process the user-clicked event.

Each time you click a piece, flip it and flip the pieces around it. When dealing with the surrounding pawns, you should be sure to determine which pawns are effective. For example, if the clicked pawns are already on the leftmost left, there is no adjacent pawns on the left. After you click it, the status of the pawns on the board changes. Therefore, you need to determine whether all the pawns are white. If yes, the game is over.

Here, I believe that the readers have come to understand the idea of making a game. The rest of the work is to write code and present the entire process.

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.