Role-playing game engine design principle - Transfer from MOVE2008 role playing game engine design principle role playing game (rpg) is a game that is popular with the majority of game fans, it attracts countless interactivity and story Player. 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 speaks the engine, and 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. The production of two-character playing games A complete role-playing game can be divided into: planning, programming, art, music production, project management, post-test test, etc. 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 techniques 1. There are many developing tools for the development tools, and 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 Talk about the game development under the Windows system, we have to talk about 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 uses alphablend technology in order to achieve a transparent effect of light and images. 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, you should use the mouse to control the figures, and let the 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's production RPG game often has a large number of scenes, and the scene can be grazed, lake, trees, houses, furniture, and the map needs a lot of scenes and the map is getting bigger and larger. In order to save space, Increasing the reusability of the image file, the screen of the RPG game uses a lot of repeated units (which can be called "Figure"), which is 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 (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 procedure is as follows: Void Messageloop // message loop {switch (msg) {char addressname [16]; // array addressname [16] used to store the name of the protagonist location case address == 001: // The value of address determines the scene value (go out) screenx = 12; screeny = 0; // Initialization game background position HERO.X = 360; HERO.Y = 80; // protagonist move (); // protagonist mobile function // The following procedures use to display the location of the protagonist Sprintf (name "of AddressName," next game scene "); PrintText (LPDDSPRIMARY, 280, 330, AddressName, RGB (255, 255)); // Show the name of the scene on the screen Break }}} 3: Most of the rpgs in the fighting system have fighting, 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.