Design principle about aircraft shooting game

zhaozj2021-02-11  173

Design principle about aircraft shooting game

Author: Yoon Yong

Limited horizontal, please don't show :)

As we all know, the aircraft shooting game is almost our first type of computer game, whether it is in the arcade or in a computer, this type of game is very easy to play and recruit. Even in this instant strategic game, 3D first perspective game, the game is also very pleasant to play, playing a plane.

After studying the knowledge about DirectX in these days, I went to the game of the plane shot. It seems that it is very complicated, in fact, it is just a collection of data structures, or it is more easy to implement.

Regarding DirectDraw programming, I don't want to introduce it, because any one can read the book for a few days, it is nothing more than the 2 to 3 surfaces of the application, Win32 The API function seems to have made us no need to spend a very smooth animation.

The following is a brief introduction to the design method, the key is the control of Player airplane and enemy aircraft, and the control of their bullets.

Obviously, you can implement them with 2 objects. They are Player's aircraft (can be 2), enemy aircraft.

Player's plane:

Class CPlayer {private: cpoint ptpos; // Aircraft coordinate struct bullet * stbullet; // Link list of all bullets issued by the plane

Struct Display Plandisplay; / / 即 即 飞 信息 区域 区域 区域 区域;;;; NSPEED; / / Aircraft Speed ​​Int NDisplayState; // Display mode, if you are hit, turn to the explosive state, so that the aircraft display function displays the explosion effect, for example, normal 1, // disappears 0, and the explosion is - 15. In this way, the display function can //, in accordance with this, calculate the image position // directly display in the sufact, each 1, this -15 plus 15 times, then turn into 0, animation Showed, the plane also disappeared, no need to handle // other processing. Such methods can also be used on bullets, public: cpoint getpos (); // Get a plane coordinate vid setpos (cpoint); // Social set aircraft coordinate void addbullt (struct bullet *); // give The plane is added to the bullet, as long as the TickTime // is added every time, the continuous bulk effect void runbullt (); // Every set TickTime, press the Bullet's attribute update // bullet coordinates, You can form a complex bullet effect struct bullet * isattack (cpoint); // Get the current coordinates have bullets and return to the bullet pointer

// This is to determine if the enemy machine is hitting the function

// The enemy machine can // know if it is hit, and use the pointer to set the status of the bullet} StrusTruct Bullet {struct bullet * next; // point to the next bullet INT NStyle; // Type Int nspeed; // Biometer speed int ndirection; // Bullet direction int ndisplayState; // Display mode, if the target is hit, turn to the explosive state, so that the // runbullet function displays the explosion effect, Like the aircraft processing method on the upper side}

The enemy's class and Player's plane is similar, remove the properties of oil, etc., add a MotionStyle property, control the plane

Flight and attack methods such as lines, slashes, curves, SIN methods, tracking methods, etc. Add a Run () method, use

MotionStyle determines the transformation method of the aircraft coordinates when each TickTime, which can be visually visually controlled by the flight and attacks of the aircraft.

When judging if the parties are attacked, just use the PLAYER object's isattack, put the coordinates of all enemile objects in it,

Get all the aircraft hit by Player, in turn calls isattack with all enemy machines, put the coordinates of the Player plane in it.

You can know if the Player is hit.

As for whether it is hit, it can be judged by a rectangle, and the perfect method is of course to be judged by RGN (area), and the contour of the aircraft

It is possible in the region.

As for the design of the background, it is more simple. Just use a two-dimensional array, put the code of the bitmap in each array unit, pass a code and

The mapping of bitmap RECT can generate a background map. If you want to create a three-dimensional sensation, or the unit in the background is covered, you can pass

Set the priority method, draw the priority of the first level, then draw high priority, naturally you can generate stereoscopic effects. A simpler method is

Press directly from top to bottom (assuming background three-dimensional is up), you can.

转载请注明原文地址:https://www.9cbs.com/read-5348.html

New Post(0)