Role play the design principle of the game engine

xiaoxiao2021-03-06  94

Role play the design principle of the game engine

Role play game (RPG) is a game that is popular with the majority of game fans, which attracts countless players with unique interactive and story. It provides people with a broad virtual world that exceeds real life, enabling people to try to play different roles, experience and experience a variety of different life journey or fantasy experience. These experiences are unable to be implemented in real life. After playing a lot of games, many players no longer only satisfied with a game player's identity, and thinking about how the game is made, and intend to make a game, all kinds of game production groups on the Internet are like the spring bamboo shoots. Emerging. Below I will introduce you to the principle and production of the role playing the game engine, hoping to help the game making enthusiasts.

The principle of a game engine

Speaking of the engine, the game fans are very familiar. The game engine is a collection of machine-identified code (instructions) that can be identified by machines that run a type of game. It is like an engine to control the operation of the game. A game work can be divided into two parts: game engine and game resources. Game resources include images, sounds, animations and other parts, column a formula is: game = engine (program code) resource (image, sound, animation, etc.). The game engine is called these resources in the order design of the game design.

Two Role Play Game Production

A complete role-playing game can be divided into: planning, program design, art, music production, and project management, post-test testing. The main task of planning is to design the plot, type, and mode of the game, and analyze how much the complexity of the game is, how much is content, and the planning progress is more fast. The programming task is to use some programming language to complete the game design and cooperate with planning to achieve the desired purpose. The American work is mainly based on the game of the game. Scene and the image of the topic design game. Music production is based on the game's plot and background making game music and sound effects. Project management is mainly to control the process of game production, take full advantage of existing resources (personnel, funds, equipment, etc.) to achieve maximum benefits with as little funds as possible. The late test is also a very important part. For a few dozens of games that have been made for a few months or even a few years, tests often find a lot of problems, only improved procedures to ensure the safety issuance of the game. Since the article is mainly explaining the production of the game program, the reader will refer to other articles aspects, and I will tell the design of the game program.

(1) Development tools and main technologies

1. Part development tool

There are a lot of game program development tools, there are different development tools on different game platforms. On your personal computer, you can use currently fluid software development tools, such as: C, C , VC , Delphi, C Builder, etc. Due to the popularity of the Windows operating system and its powerful multimedia features, more and more games support the Windows operating system. Since VC is Microsoft's product, use it to write a strong program interface and rich development resources support, plus VC rigorous memory management, a good distribution process on the stack, generating a small size, high stability The advantage, so VC has become the mainstream development tool for the current game.

2. DirectX Components Knowledge

Talking about the game development under the Windows system, we have to say Microsoft's DirectX SDK. A main advantage of the Windows system is the independence between applications and devices. However, the application's device-independent is to add an intermediate abstraction layer to the hardware and software through the sacrifice of partial speed and efficiency, and the intermediate abstraction layer is added to the software, and our applications we can have over different hardware. However, we will not completely utilize hardware features to get the maximum operation and display speed. This is fatal when writing a Windows game, DirectX is designed to solve this problem. DirectX consists of a fast underlying library and does not add too much constraint to the game design. Microsoft's DirectX Software Development Kit (SDK) provides an excellent application programming interface (APIS), which can provide you to develop high quality and real-time applications. 6 components of DirectX are: DirectDraw: Use the page switching method to implement animation, which can not only access system memory, but also access to display memory. Direct3D: Provides a 3D hardware interface. DirectSound: Stereo and 3D sound effects, and manage the memory of the sound card. Directplay: Supports developing multi-person online games and can handle communication between networks in the game. DirectInput: Provides input support for a large number of devices. DirectSetup: Automatically install the DirectX driver. As the DirectX version is improved, the DirectMusic played by music is also added. 3. Alphablend technology

Now many games will use alphablend technology to achieve the transparent effect of the light and image. The so-called alphablend technology is actually mixing the source pixels and target pixels in accordance with the value of "alpha" mixed vector, generally used to process translucent effects. The image in the computer can be represented by R (red), G (green), B (blue) three primary colors. Assuming an image is a, another transparent image is B, then taken through b, it looks at the image C is the mixed image of B and A, and the transparency of the B image is Alpha ( The value is 0-1, 0 is completely transparent, and 1 is completely opaque), Alpha mixed formula is as follows: R (c) = alpha * R (b) (1-alpha) * R (a) g (c) = Alpha * g (b) (1-alpha) * g (a) b (c) = alpha * b (b) (1-alpha) * b (a) r (x), g (x), b (x) Refers to the RGB component original color value of color X, respectively. From the above formula, Alpha is actually a value that determines the mixed transparency. Applying Alpha hybrid technology, many effects in the game, such as fire, smoke, shadow, dynamic source and other translucent effects.

4. A * algorithm

In many games, use mice to control people's movements, and let people walk from the current position to the target location should take the shortest path. This is to use the shortest path search algorithm, which is a * algorithm. A * Algorithm is actually a heuristic search, so-called heuristic search, the use of an estimated function to evaluate the value of each decision, which is determined which solution is tried first. If an valuation function can find the shortest path, we call it adopt. A * algorithm is an adopted best priority algorithm. The value of the A * algorithm can be represented as: f (n) = g (n) h (n) Here, f (n) is the estimating function of Node N, G (n) is the shortest path value of the starting point to the end point, H (n) is the inspiration value of the maximum path of the target. Since the A * algorithm is more complicated, it is limited to the space, in this brief introduction, specific theoretical friends can see a detailed situation in artificial intelligence. Other technologies include particle system, audio and video calls, image file formats and information storage, etc., you can gradually learn more technologies on the basis of learning DirectX.

(2) The specific production of the game

1. Map editor production

RPG games often have a large number of scenes, and there can be grass, lakes, trees, houses, and furniture in the scene. Since a game requires a lot of scenes and the map is getting bigger and bigger, in order to save space, improve image files Reusability, the picture of the RPG game is made of a lot of repeated units (which can be called "diagram"), which is used to use the map editor. Before we make game engine, we must complete the production of map editing. In the RPG game, the configuration of the scene is a record of the sequence of the drawing block. First, a scene format format is made, and in this file, you record the order of the tile required to constitute the scenario, because we have established an index for each tile, so you can only record these indexes. The composition of a scene is to be divided into several layers: ground, building and plant, furniture arrangement, and characters or objects in the scene (such as a fluttering banner), display them in a certain order to the screen. A rich scene has been formed. We can use arrays to represent the generation of map scenes.

Mapdata [x] [y]; // map data, x represents the map width, y indicates that the map height Picture [NUM]; // props picture, NUM represents the total number of props VOID MAKEBACKGROUND () // Generate Scene Function {INT N For (int i = 0; i

2. Division of the module of the game

The game is divided into: message processing system, scene display and walking system, the three major parts of the fighting system. Among them, the message processing system is the core module, and the rest is tight around it.

1: Message processing system

The message processing system is the core part of the game. The message processing system used by the game is waiting for the message, and then transfer to the corresponding function according to the received message. For example: After the protagonist encounters the enemy, we let the program generate the 'fight message', and the message processing system will go to the fight module after receiving this message. The general framework for message processing is as follows:

/ / Define the variable DWORD Message; // message variable winmain () // enter the program {initialization main window; initialize the DirectDraw environment, and transfer the graphics required by the program; while (1) // Message loop {copy (message) {case walk message: walking module (); case fight message: fight module (); case event message: event module ();}}} 2: Scene display and walking system

As a RPG game, all of its events are almost related to the scene, for example: different places will encounter different enemies, and dialogue different things. Given the importance of this part, we can divide it into: background display, walking and events, and handle their respective functions. The following is a specific analysis.

(1) After the background display program is running, first read the order of the capture required by the scene made by the front map editor, and put the image into a complete scene according to the order of arrangement, and the general practice is: opening up in memory To two screen buffers, preparation of the upcoming image data in advance is in the cache, then moving one-time: transfer them to the true screen buffer. The picture used by the game is produced in advance and stored in another graphic file. The scene file made by the map editor is just the corresponding data, not a real picture. Generating scenarios in the game is the reverse process of map editing, one is based on the scene generation data, and the other is based on the data generation scenario.

(2) Walking to let the protagonist walk in the scene, at least four walking directions, down, left, right, 4 maps in each direction (standing, left leg, right leg, scorpion leg), such as Photo: The background of the picture must be set to transparent, so it will not cover the background color when drawing the characters (this technology DirectDraw only uses the setColorKey () function to filter out the original picture background color. . We make the protagonist positions, and make the scene move, ie, use scroll technology to implement the role to move on the scene. This role has been kept in the middle of the screen, and the job that needs to be done is only based on the walking direction and the pace. The obstacle judge when walking is also necessary in every scene. Some props such as trees, houses, etc. are not spanning. I mainly use a two-dimensional array corresponding to a scene, each array value represents a small size of the scene (see Figure 3). Where there is obstacles, the corresponding value of the array is 1, and the value of the place that can be passed is 0.

(3) The incident occurrence of events is to store the serial number of the corresponding event in some plaids of the map, and when the protagonist step into this grid will trigger the corresponding event. For example: At the beginning of the game, the protagonist is in his home. If he wants to go out, you need to perform the scene to switch this handler. We assume that the number of the event is 001, then set the lattice value at the outside of the house to 001 on the map. When such a protagonist goes to the intersection, the number of scene switched functions numbered 001 will be triggered, so the protagonist is in the next scene. The apparatus is as follows:

Void MessageLoop (INT MSG) // Message Cycle {Switch (MSG) {char addressname [16]; // Array AddressName [16] Used to store the name of the protagonist location case address == 001: // Decided by address of Address Scene value (out of the door) Screenx = 12; screeny = 0; // Initialization game background position HERO.X = 360; HERO.Y = 80; // protagonist coordinate MOVE (); // protagonist mobile function // The following procedure is used Show the protagonist location sprintf (the name of AddressName, "next game scene"); PrintText (LPDDSPRIMARY, 280, 330, AddressName, RGB (255, 255)); // Show the name of the scene on the screen;}} : Fighting system

The vast majority of RPGs have battle, so the fighting system is a very important ring in the RPG system. There are many RPG games to use a turn-fighting method because it is simple to achieve. The fastening is closely related to the upgrade, usually after a battle, the most experience value of the protagonist will increase. When the experience value reaches a certain degree, the role is upgraded. Above I briefly introduced the production of role playing games, because the purpose of writing this article is to let readers have a basic understanding of the role playing game, so readers can study relevant information.

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

New Post(0)