As3 RPG Game Engine Development log 2: understanding and analysis of RPG games

Source: Internet
Author: User
Tags farm games

RPGGames

GEO chart

│ BytesBackground

│ ├ Prospect: Construction, mountains, rivers, trees, etc.

│ Gamers

│ Orientation and coordinates

│ Actions: Station, walk, run, jump, and other actions, such as attacks

│ BytesNPC: Same player

│ Items: dropped items, items that can be picked up, etc.

│ Element: for example, a bullet flying after shooting

│ Character window: character information, skill information, package, dialog, etc.

Display window of Game Information: Mini map, life value, item bar, chat box, etc.

 

1. Map level

Playhouse andNPCWhen players move around, they only need to move the map instead of moving the map.NPC.

Here we divide the map into three layers:

Background layer: it is at the bottom layer at any time, and I don't think it should have an animation (video clip), and the background is the largest in the whole map, it has a large animation that seriously affects the speed. If you need an animation, place it in the middle layer.

Foreground layer: everything that exchanges depth with players is at this layer, where they participate in game interaction (such as collision ).

Top layer: The top layer is displayed at any time, and the top layer does not move with the player to speed the game. Such as cloud and rain.

Deep relationships also exist in each layer.

 

2. Map description

Each map is divided into an array of blocks, and the values of the arrays describe the information of the blocks. The information contains the obstacle features, vacancy features, instance depth, and events.ID (For example, the exit for map jump).

Obstacle characteristics should have three values: no obstacle, no obstacle, but no obstacle, and no obstacle, which is used in deep exchange.

Vacant feature: indicates whether the block is "empty" and can be placed as an item. It is used separately to indicate whether an item can be placed without obstacle features, the reason is that items may not be placed in accessible blocks, such as transfer points. items may be placed in inaccessible blocks.

The background and foreground are collectively referred to as graphs, which haveIDAnd the image file address and an array of a block. The value of this array identifies the barrier feature and vacancy feature. When storing the map description in a file, three layers are represented separately, and each block in the background layer stores a value, similar to an array. The foreground layer is a list that indicates the graphicIDAnd location. Events must also be stored.

Graphics can be used repeatedly. They can be dragged to a map multiple times. You can also add names and introduction information when a foreground image is put on a map, used for display during interaction,ProgramThe instance depth of the running foreground image is assigned to the instance depth of the corresponding block array value (each block array value occupied by the foreground image is assigned a value ).

Using this map description can effectively achieve the blocking effect. "masking" is a deep exchange. Taking players and buildings as an example, you only need to judge the front of the players (the front is the front of the players) the array value corresponding to any block in a row of blocks determines whether to swap the depth of players and buildings (this depth value is the instance depth in the map array ). "Block" is collision detection. It also determines whether an object exists in front of the map based on the value in the map array.

In this way, the map array is constructed based on efficiency. First, the array stores the instance depth rather than the Instance name, because the Instance Object (that is Getchildbyname Method ) Has not been hurt by depth to obtain the Instance Object (that is Getchildat Method ). Second, if you do not store the instance depth in the map array, you can find the Instance Object in front of it. You can use Getobjectsunderpoint Method to obtain the instance object, but if the program is not well written, the instance object cannot be found (I use As3 This method is used to rewrite farm games. After multiple debugging, it can be implemented perfectly ), Therefore, this method is not good enough. Third, if you use Hittestobject , Hittestpoint Or Hittest Collision detection is not suitable because these functions can only be detected after a collision occurs, but we actually need to make a collision prediction, although the last two functions can be used for efficient pixel-level detection and collision prediction through some means, but we need to know the objects to be detected in advance, which is exactly what we want to know and the efficiency of the existing array identification method is also very good. Therefore, the collision detection here should be called collision prediction.

Although this reduces the possibility of frequent operations, the concern of this approach is that players andNPCThe efficiency of collision detection between players andNPCAny point of movement requires changes to the map array, players andNPCThis will bring a lot of burden, so I am going to make an option to set whether to enable the occlusion feature of the role. If it is not enabled, the role will step on another role.

45Comprehensive perspective, in fact45Degree of view is not45Degree, which is halved in the height of the map.26More degrees, I think this is mainly because45Degrees of view will cause a perspective effect that is not close to Big, small, and thus visual discomfort. The figure below is what I imagined45A map with a full view (with blocks on four corners so that the whole map is not a diamond but a rectangle). However, we are still considering whether to use this method, the map array is still used.90Degrees angle of view, without rotation, the coordinate conversion formula is:

Small diamond height:H, Small diamond width:W = 2 h

Game coordinatesX = 2 H * j-(I % 2) * H

Game coordinatesY = I * H/2-h/2

 

3. Actions and skills

Execution sequence of an action:

Action token>Skill ── ─ accept

Bytes>Action of the target object<Bytes

Bytes>No response<── ─ Accept

Both action and skill are animations, and actions are played by players orNPCSelf-generated, some actions do not produce skills, and directly act on objects or do not respond. Some actions generate skills and then act on objects or do not respond. Skill animations are controlled by programs, it can be used for tracking, flying straight lines, and scope of action.

An object affected by an action or skill sometimes enters a State, and the State can also be animated. It ends with a timer or other action acting on it.

 

4. Update

Implementation principle: Multiple animations are used for each action of each role for each equipment (such as clothes and gloves). Among these animations, only this equipment is used. Why do we need multiple animations, two glove animations are required for a role to walk to the left. The left hand has one right hand, the left hand has the highest depth, and the right hand has the lowest depth (which will be blocked by the role itself and other equipment ), it can also be an animation. When a role performs an action, the program places all the animations of the action currently worn by the role in the action according to the depth value relative to the role itself, in this way, the update is implemented.

From the words that are difficult to express above, we can see that the dress change is a huge workload for art personnel. It is very time-consuming to make a good operation, moreover, no action of each role should be animated. The role term mentioned above refers to players andNPC.

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.