DESIGN AND IMPLEMENTATION OF WECHAT APPLETS AIRCRAFT BATTLE AND IMPLEMENTATION OF WECHAT APPLETS AIRCRAFT BATTLE.”

With the rise and development of WeChat applets, their convenient features are very popular with users, making their number of users develop rapidly. With the emergence of small games in WeChat applets, more and more non-game players are also attracted. This article is about a classic flight shooting game " Airplane Wars" developed by WeChat developer tools and JavaScript language. It mainly uses canvas drawing and sprite wizard to detect collisions and other functions. It can realize smooth human-computer interaction and animation rendering. It has rich game elements and high playability.


Introduction
In today's fast-paced life, most people in the hard work and study life difficult to relax, spare time to relax, life pressure is more and more big, the WeChat little game development difficulty and although profit is not high, but to allow the user to relax in the fragments of time, alleviate the pressure of the life, this is what the meaning of the research [1][2][3]. In recent years, WeChat opened a similar small program of small games, no download and installation, portable experience, and WeChat friends can play together, such as PK, onlookers, enjoy the fun of small games, attracted a large number of non-game players to join in [4][5][6][7].

Design Requirement
Scene arrangement: the game background is fighting in the air, and the player's perspective is overlooking, under such conditions, a rolling dynamic background is essential. Player control: players need to control the flight path of our aircraft through their fingers. Collision detection: as a shooting game, collision detection and the trigger condition is indispensable, so you need to [Mengshan et. al create the object collision detection for judgment, because the game set to shoot down enemy planes and crashed a collision with the enemy, so need to detect collision detection in our aircraft fired bullets collision with the enemy aircraft and our aircraft collision with the enemy aircraft [8][9][10][11][12].
Enemy planes and bullets: the constant flow of bullets and the oncoming enemy aircraft requires the creation of a large number of objects. Special enemy aircraft and flying objects: special enemy aircraft with larger airframe will drop a flying object if shot down, and the flying object will move in a circle according to a specific route in the screen. When the player catches the flying object through collision, the number of bullets fired at the same time will be increased [13][14][15][16].
Game performance: as a small game, the performance of the game should be taken into account during the game experience to ensure the smoothness of the game and reduce the running memory occupied by the game. Frame animation: as a dynamic game, the image on the screen needs to be changed at every moment according to the operation and different event triggering, and at the same time, the continuity and fluency between each frame should be guaranteed. End of game tip: after the game is over, need to display the score on the screen and prompt to start a new game [17][18][19][20][21].

Design Thought
1) At the beginning of the game, creating two background images, and the screen size, leakage from one part of the rest of the hidden in the screen above, the other a completion screen below the rest, the rest of the hidden in the bottom of the screen, two images automatically move down, when the first moved to the location of the entire screen redraw two pictures, the effect of rolling. 2) Create an object for our aircraft that appears at the bottom of the screen.When players to put the finger on the screen, by a Boolean value to determine whether a contact in the plane, if not, then don't do anything, if it is, the cycle began, by moving the position of the contact to change the plane's position, and limit the scope of the aircraft, to ensure that the aircraft fuselage within the entire screen. 3) Create three object pools to store enemy aircraft, fallen objects, and bullet objects from our aircraft. 4) The bullet is created right in the middle of the fuselage, flying at a fixed speed from the bottom up. When a bullet flies off the edge of the screen or collides with an enemy aircraft, recycle the bullet into the object pool. 5) The creation position of enemy aircraft is outside the top of the screen, flying from top to bottom at a fixed speed, and being recovered to the object pool after flying over the bottom screen edge or colliding with bullets. 6) When the enemy aircraft and bullets collide, they are retrieved to their respective object pools, and an animation of an explosion is played at the location of the collision. 7) When our plane collides with falling objects, the number of bullets fired at the same time will be changed from 1-5 cycles. 8) When our plane and local plane collision, scene, the symbol of material to draw in the middle of the screen box shape, including "game over" and tips on how to score, button shape to draw in the right place in the box, including the start of prompt, click to reset all the objects and restart the game.

1) Set a Basic Sprite Class to Detect Collisions
There are two main collision detection methods in 2d games. One is to detect collision by object frame, and the other is to detect collision by mask color. The first method is fast, but the collision detection of complex objects is not accurate. The second method is accurate, but requires a lot of calculation. Because the game relies on the WeChat applet platform, there is no need to use overly accurate collision detection, so the first method is used.

2) Game Start
Game background class, use update and render functions to achieve the background function of infinite scrolling, draw two pictures, the size of the two pictures and the screen is the same, the first leak height is the top part, the rest is hidden in the screen, the second fill in the part except the top height, as shown in figure 1 at the beginning of the game.

5) Enemy Planes
 create enemy aircraft objects  when bullets collide with enemy aircraft, recycle two objects into the object pool and play the frame animation of explosion effect  circular detection, the function of recycling objects is the same as that of bullet recycling.

6) Flying Object Pickup
After shooting down the enemy's special plane, a flying object will be created from the shot down position, and the object will move in a circle in the screen according to its specific trajectory. After colliding with the player's plane, the object will be removed and the state of bullets of our plane will be changed, as shown in figure 3.

7) Game Over
At the end of the game, the end prompt box and the button of restart function appear.