A method and device for processing game map data

By removing redundant and duplicate information, converting data types, updating index values, filtering and generating tile templates, and building a map grid, the performance problems caused by the huge size of the map data generated by Tiled are solved, and the map data is streamlined and efficiently loaded, improving the game operation efficiency.

CN119202109BActive Publication Date: 2025-04-11GUANGZHOU YIYU NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411201738.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2025-04-11
Estimated Expiration
2044-08-29

AI Technical Summary

Technical Problem

The map data generated by the existing game map editor Tiled is huge in size, resulting in performance problems such as slow loading speed, lag in runtime, and high storage pressure and long loading time, which affects the game's running efficiency.

Method used

By obtaining the original map exported by Tiled, removing redundant and duplicate information, converting the data type of the tile set to a smaller preset data type, updating the index value between the tile and the tile set, filtering the tile that meets the preset conditions to generate templates, deleting redundant tiles, and using a random number generator to build a map grid, stitching tiles or templates to generate target maps.

Benefits of technology

It reduces the storage volume of map data, improves the loading efficiency of map data, avoids loading useless data, and improves the game operation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119202109B_ABST
    Figure CN119202109B_ABST
Patent Text Reader

Abstract

The present application belongs to the field of computer graphics technology, and discloses a method and device for processing game map data, which includes: obtaining the original map exported by Tiled, removing redundant information and repeated information, and obtaining map data; changing the original data type of each tile set in the map data to a preset data type; wherein the storage volume of the preset data type is smaller than the original data type; updating the index value between each tile and the corresponding tile set; screening tiles that meet preset conditions, and generating corresponding tile templates; deleting tiles with the same environmental information as the tile template; receiving a map generation instruction, and using a random number generator to construct a map grid; splicing tiles or tile templates based on the map grid and index values ​​to obtain a target map. The present application can streamline the original map, reduce the storage volume of map data, and speed up the loading efficiency of map data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer graphics technology, and in particular to a method and device for processing game map data. Background Art

[0002] In current game development, map editors usually use Tiled, which is specifically used to create maps and level designs. Tiled can provide an intuitive user interface and rich editing functions, and can be easily integrated into game engines. The rich editing functions provided by Tiled include tile map editing, layer management, object editing, collision box definition, etc., allowing map editors to easily create various complex map elements and game objects.

[0003] However, since Tiled has rich editing functions, the original map it generates also includes editing data for multiple functions. For very large maps, the map generated by Tiled is complex and large in size, leading to performance issues such as slow loading or lag during runtime. In addition, the corresponding storage pressure and loading time of a large amount of map data are large, which further leads to low game operation efficiency. Summary of the invention

[0004] The present application provides a method and device for processing game map data, which can simplify the original map, reduce the storage volume of map data, and speed up the loading efficiency of map data.

[0005] In a first aspect, an embodiment of the present application provides a method for processing game map data, comprising:

[0006] Get the original map exported by Tiled, remove redundant and repeated information, and get the map data;

[0007] Change the original data type of each tile set in the map data to the preset data type;

[0008] Wherein, the storage volume of the preset data type is smaller than the original data type;

[0009] Update the index value between each tile and the corresponding tile set;

[0010] Filter tiles that meet the preset conditions and generate corresponding tile templates;

[0011] Delete the tile with the same environment information as the tile template;

[0012] Receive map generation instructions and use a random number generator to construct a map grid;

[0013] Tiles or tile templates are spliced ​​based on the map grid and index values ​​to obtain the target map.

[0014] Furthermore, the redundant information includes:

[0015] Temporary layers, texture data whose closest distance to the player is greater than a preset distance threshold and whose resolution is greater than a preset resolution threshold, and model data whose closest distance to the player exceeds a preset distance threshold and whose geometric accuracy is greater than a preset accuracy threshold.

[0016] Furthermore, the above repeated information includes:

[0017] References to the same model data and the same texture data at different locations.

[0018] Furthermore, the above-mentioned preset data types include: byte type, bool type, char type or short type.

[0019] Furthermore, the method further comprises:

[0020] Before changing the preset data type, merge the layers belonging to the same category in the map data.

[0021] Furthermore, the above-mentioned receiving a map generation instruction and using a random number generator to construct a map grid includes:

[0022] Receive a map generation instruction and create a blank initial map grid according to a preset size;

[0023] A random number generator is used to generate environmental information within an initial map grid to obtain a map grid.

[0024] Furthermore, the above-mentioned splicing of tiles or tile templates based on the map grid and index values ​​to obtain the target map includes:

[0025] Get the current environment information of the current grid;

[0026] Determine the tile or tile template corresponding to the current environment information;

[0027] Place the tile or tile template corresponding to the index value on the current grid.

[0028] Furthermore, the method further comprises:

[0029] Receive a map loading instruction and crop the target map according to a preset interest range;

[0030] A quadtree algorithm is used to determine the current visible area in the cropped target map;

[0031] Render each preset fixed element in the current visible area to obtain the current frame.

[0032] Furthermore, the method further comprises:

[0033] Divide each preset fixed element into multiple resource blocks and put them into a loading queue;

[0034] Calculate the current flow value and determine whether the current flow value reaches the preset flow peak value;

[0035] If so, render the preset number of resource blocks in the loading queue to obtain the current frame.

[0036] Furthermore, the above-mentioned use of the quadtree algorithm to determine the current visible area in the cropped target map includes:

[0037] Construct a quadtree based on the cropped target map;

[0038] Generate a rectangular query area based on the player's current position coordinates and screen resolution;

[0039] The quadtree is traversed using a rectangular query area to determine each leaf node in the quadtree that intersects with the rectangular query area, and the current visible area is generated based on each leaf node.

[0040] Furthermore, the above calculation of the current flow value and determination of whether the current flow value reaches a preset flow peak value include:

[0041] Get the current number of online players, system load, and latency response time;

[0042] Input the number of online players, system load, delayed response time and current time into the trained traffic analysis model to obtain the current traffic value; determine whether the current traffic value reaches the preset traffic peak value.

[0043] Furthermore, the above-mentioned generation of a rectangular query area based on the player's current position coordinates and screen resolution includes:

[0044] Convert the current position coordinates into two-dimensional screen coordinates;

[0045] The screen coordinates are used as the vertices of the viewing frustum, and the bottom area of ​​the viewing frustum is calculated based on the screen resolution, the player's vertical field of view angle, and the horizontal field of view angle; the bottom area is used as the rectangular query area.

[0046] Furthermore, the above-mentioned preset interest areas include:

[0047] The numerical information, model accuracy information, player quantity information and building quantity information corresponding to the current display mode.

[0048] In a second aspect, an embodiment of the present application provides a device for processing game map data, including:

[0049] The acquisition module is used to obtain the original map exported by Tiled, remove redundant and repeated information, and obtain map data;

[0050] A data changing module, used for changing the original data type of each tile set in the map data into a preset data type; wherein the storage volume of the preset data type is smaller than the original data type;

[0051] An index update module, used to update the index value between each tile and the corresponding tile set;

[0052] The template generation module is used to filter tiles that meet the preset conditions and generate corresponding tile templates;

[0053] A deletion module is used to delete tiles with the same environment information as the tile template;

[0054] A construction module, used for receiving a map generation instruction and constructing a map grid using a random number generator;

[0055] The generation module is used to splice tiles or tile templates based on the map grid and index values ​​to obtain the target map.

[0056] Furthermore, the device also includes:

[0057] The merge module is used to merge the layers belonging to the same category in the map data before changing the preset data type.

[0058] Furthermore, the device also includes:

[0059] A cropping module, used to receive a map loading instruction and crop the target map according to a preset interest range;

[0060] A quadtree module, used to determine the current visible area in the cropped target map using a quadtree algorithm;

[0061] The rendering module is used to render each preset fixed element in the current visible area to obtain the current frame.

[0062] Furthermore, the device also includes:

[0063] A division module is used to divide each preset fixed element into multiple resource blocks and put them into a loading queue;

[0064] The flow determination module is used to calculate the current flow value and determine whether the current flow value reaches the preset flow peak value;

[0065] The rendering module is also used to render a preset number of rendering resource blocks in the loading queue when the current traffic value reaches a preset traffic peak value to obtain the current frame.

[0066] Furthermore, the above quadtree module includes:

[0067] A quadtree construction unit, used to construct a quadtree according to the cropped target map;

[0068] A rectangle generation unit, used to generate a rectangular query area based on the player's current position coordinates and screen resolution;

[0069] The traversal unit is used to traverse the quadtree using a rectangular query area, determine each leaf node in the quadtree that intersects with the rectangular query area, and generate a current visible area according to each leaf node.

[0070] In a third aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of a method for processing game map data as described in any of the above embodiments are performed.

[0071] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a method for processing game map data as in any of the above embodiments.

[0072] In summary, compared with the prior art, the technical solution provided in the embodiment of the present application has at least the following beneficial effects:

[0073] An embodiment of the present application provides a method for processing game map data. First, by removing redundant and repeated information in the original map, the data type of the tile set is changed to a preset data type with a smaller storage volume, thereby reducing the volume of map data, avoiding loading of useless data, and improving operating efficiency. Secondly, the present application makes tiles that meet preset conditions into tile templates. One tile template can be used to replace each tile of the same environmental information, thereby reducing the number of tiles. When generating a target map, certain environmental information can be directly implemented by copying the tile template, thereby improving map loading efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] Figure 1 A flowchart of a method for processing game map data provided as an exemplary embodiment of the present application.

[0075] Figure 2 A flowchart of target map generation steps provided for an exemplary embodiment of the present application.

[0076] Figure 3 A flowchart of the current frame rendering steps provided for an exemplary embodiment of the present application.

[0077] Figure 4 A flowchart of frame rendering steps provided for an exemplary embodiment of the present application.

[0078] Figure 5 A flowchart of the steps of determining the current visible area is provided for an exemplary embodiment of the present application.

[0079] Figure 6 A structural diagram of a device for processing game map data provided as an exemplary embodiment of the present application.

[0080] Figure 7 A structural diagram of a generation module provided for an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0081] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.

[0082] Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative work shall fall within the scope of protection of this application.

[0083] Terminology explanation:

[0084] 1) Tiles: They are the basic units that make up a map, usually small square or rectangular images. In the game, tiles are used to fill layers to form a continuous map surface. The position of each tile in the map is determined by its index and can have different properties and behaviors. For example, in the Tiled Map Editor, tiles can be used to create different terrains or obstacles.

[0085] 2) Tileset: A collection of images that can be used in tile maps. Each tileset contains multiple tiles, which can be reused as tiles of a map. Tilesets allow developers to define a set of image resources that can be shared and reused in different maps. In Tiled, a tileset can contain a single large image that is divided into multiple small tiles, each of which can be used separately.

[0086] 3) Layer: It is a container for placing tiles. A layer can contain multiple tiles, which are combined in a specific arrangement to form a part of the map. Layers can be of different types, such as TileLayer, Object Layer, and Image Layer. Tile Layers are composed of tiles, Object Layers contain objects in the game such as enemies and props, and Image Layers can hold entire images. In Cocos Creator, layers are represented by the TMXLayer class, and each layer uses a TextureAtlas to render tiles.

[0087] When creating a map in Tiled Map Editor, you first need to determine the size of the map and the size of the tiles, then import the tile set and use these tiles on different layers to build the map. Each layer can be operated independently and can be set with different visibility, properties, etc. The stacking order of the layers is also important because it determines the order in which they are displayed in the final map. Developers can add multiple layers as needed to create complex map structures.

[0088] A tile can contain multiple layers of information. It can be understood as three pieces of paper cut vertically to obtain three small pieces, but from a top-down perspective, the three pieces overlap and are combined into a tile.

[0089] In general, a tile is the smallest unit of a map, a tile set is a collection of tiles, and a layer is a map level composed of tiles or tiles. By organizing these elements reasonably, you can efficiently create and manage complex game maps.

[0090] See also Figure 1 The present application embodiment provides a method for processing game map data, which specifically includes the following steps:

[0091] Step S11, obtaining the original map exported by Tiled, removing redundant information and repeated information, and obtaining map data.

[0092] The redundant information may include the creation date of the map data, the editor ID, etc.

[0093] Step S12, changing the original data type of each tile set in the map data into a preset data type; wherein the storage volume of the preset data type is smaller than the original data type.

[0094] Step S13, updating the index value between each tile and the corresponding tile set.

[0095] Specifically, the index value represents the position of the tile in the tile set, in order to match the tile with the tile set. When the data type of the tile set changes, in order to prevent tile index errors, it needs to be updated.

[0096] To update the index value, you just need to write a program algorithm to make the index value of the original data type correspond to the index value of the preset data type one by one, and then all tiles and tile sets will execute the update algorithm at the same time to update the index value. Therefore, no matter what type of preset data type is used, the index value update process is the same.

[0097] Step S14, screening tiles that meet preset conditions and generating corresponding tile templates.

[0098] Among them, the preset conditions include: 1. The borders around the tile are not special and the height of the four sides is consistent, so they can be seamlessly connected; 2. The environmental information of the tile meets the type and corresponding requirements of the commonly used templates. Common templates include mountain templates, river templates, and flat land templates. Different commonly used templates have different requirements. For example, the flat land template has nothing but flat land, the river template must be all fluid, the depth of the mountain template is greater than the preset height, and so on.

[0099] Specifically, after determining the tile that meets the preset conditions, it is used as a tile template and placed in a register of a corresponding common template type, waiting to be referenced when generating a target map.

[0100] Step S15, deleting tiles having the same environment information as the tile template.

[0101] Specifically, the operation of this step means that only one commonly used template of the same type is required; because there is often more than one tile that meets the requirements of the commonly used template in the exported original map, that is, there may be multiple tiles that meet the preset conditions for being a mountain template. Here, only one of them needs to be selected, and the remaining mountain tiles are directly deleted; when generating the target map, if a grid with environmental information of a mountain is encountered, the only mountain template is directly used.

[0102] Step S16, receiving a map generation instruction, and using a random number generator to construct a map grid.

[0103] Step S17, splicing tiles or tile templates based on the map grid and index values ​​to obtain a target map.

[0104] Specifically, since the environmental information in the map grid is randomly generated, it cannot be guaranteed that the environmental information of all grids corresponds to a commonly used tile template type. If the environmental information in the map grid does not have a corresponding tile template, it is necessary to find the corresponding tiles for splicing. Therefore, the target map usually includes both tiles and tile templates.

[0105] For example, for a lake, the central lake water part can be copied using the lake water template, while the lakeside location includes both lake water and land, and using a copied tile template can easily lead to misalignment, so actual tiles are needed.

[0106] In the specific implementation process, 2-3 spare tile templates of the same type can also be used. This is because in the process of generating the target map, the tile template needs to be connected to tiles in addition to other tile templates. After connecting to the tiles, it is necessary to check whether the border position is seamlessly linked. If there is a problem, use the same type of spare tile template.

[0107] The above-mentioned embodiment provides a method for processing game map data. First, by removing redundant and repeated information in the original map, the data type of the tile set is changed to a preset data type with a smaller storage volume, thereby reducing the volume of map data, avoiding loading of useless data, and improving operating efficiency; secondly, the present application makes tiles that meet preset conditions into tile templates, and one tile template can be used to replace each tile of the same environmental information, thereby reducing the number of tiles. When generating a target map, certain environmental information can be directly implemented by copying the tile template, thereby improving map loading efficiency.

[0108] In some embodiments, the redundant information may also include a temporary layer, texture data whose closest distance to the player is greater than a preset distance threshold and whose resolution is greater than a preset resolution threshold, and model data whose closest distance to the player exceeds a preset distance threshold and whose geometric accuracy is greater than a preset accuracy threshold.

[0109] Temporary layers are layers that are used for editing purposes but are not needed in the game. Geometric accuracy generally refers to the number of geometric faces of a model. The distance between texture data and the player can be calculated by the distance between the model that references the texture data and the player.

[0110] Specifically, in the generated target map, the range in which the player can move is not the entire target map. Especially in an open world, the player's activity range is usually set in the map. The map outside the activity range is an area that the player can see but cannot approach. For the area outside the activity range, its function is generally to provide players with an open map gaming atmosphere (if players can directly touch the edge of the map, it will affect the open world gaming experience).

[0111] However, since players cannot actually reach areas outside the activity range, the models, textures, etc. in areas outside the activity range usually need to use low-precision or low-resolution versions to simulate the distant view.

[0112] Therefore, this application determines those textures or models that are only displayed to players at a distance by presetting a distance threshold, and deletes the high-resolution texture data and high-precision model data in the original map (the same texture or model in the original map usually has different resolutions or accuracies to achieve display at different distances from the player). These high-resolution texture data and high-precision model data that will not be displayed in the target map will be deleted.

[0113] The redundant data defined in the above embodiment takes into account the high-precision model data and high-resolution texture data that will not be used in the original map. Although the diverse precision of the model and the diverse resolution of the texture are required for display at different distances during the development stage, in fact not all precisions and resolutions will be used. The removal of this data will not only not affect the display and generation of the target map, but also reduce the volume of map data, thereby alleviating storage pressure.

[0114] In some embodiments, the repeated information includes references to the same model data and the same texture data at different locations.

[0115] Specifically, the original map may contain repeated texture data, model data or other data blocks, which are referenced in multiple locations, but actually only need to be stored in one copy.

[0116] Therefore, the present application deletes these repeatedly referenced texture data and model data, which can also reduce the volume of map data without affecting the display and generation of the target map.

[0117] In some embodiments, the preset data type includes byte type, bool type, char type or short type.

[0118] Specifically, taking the default data type as byte as an example, the original map exported by Tiled Figure 1 Generally, the data types are json, csv, etc. The original map is parsed and exported by programming languages ​​(c#, java, etc.). According to the specific meaning of the data, the data is converted into byte type in the code. This involves bit operations, encoding conversion, etc. The converted byte data is stored in a file, memory or other data source, or used directly in the game. In addition to the above preset data types, you can also customize a data type; for example, use the programming language on the programming software to create a new custom data type suitable for development. This new data type can be created based on int, string, list or other data types.

[0119] In some embodiments, the method further comprises:

[0120] Before changing the preset data type, merge the layers belonging to the same category in the map data.

[0121] The basis for judging whether two coatings are of the same type mainly includes: content usage and attribute settings. If the content usage or attributes of two layers are consistent, they are considered to be of the same type and then merged into the same layer.

[0122] The layer merging operation mentioned in the above embodiment can reduce the number of layers in the map data, further reducing the size of the map data and the time required to load tiles in the map data.

[0123] In some embodiments, the receiving of the map generation instruction and constructing the map grid using a random number generator includes:

[0124] Step S161, receiving a map generation instruction, and creating a blank initial map grid according to a preset size.

[0125] Step S162, using a random number generator to generate environmental information within the initial map grid to obtain a map grid.

[0126] Among them, the random number generator (such as a pseudo-random number generator) generates random factors within each grid, such as mountains, rivers, forests, etc. The purpose of this is to control the randomness of the map.

[0127] Specifically, the environment information generated by the random number generator and the environment information of the tile belong to the same data type, that is, the types and descriptions included in the environment information generated by the random number and the environment information of the tile are the same.

[0128] For example, the environmental information generated by the random number generator includes mountains, rivers, grasslands, trees, bushes and buildings, and the environmental information of the corresponding tiles is also described as mountains, rivers, grasslands, trees, bushes and buildings, that is, the two can be matched, thereby ensuring the index based on environmental information in the subsequent target map generation process.

[0129] See also Figure 2 In some embodiments, the above-mentioned splicing of tiles or tile templates based on map grids and index values ​​to obtain a target map may specifically include the following steps:

[0130] Step S171, obtaining current environment information of the current grid.

[0131] Step S172, determining the tile or tile template corresponding to the current environment information.

[0132] Specifically, first determine whether there is a corresponding tile template for the current environment information. If so, use the tile template first. If not, search for tiles with the same environment information.

[0133] For example, if the current environment information of the current grid is a mountain, and there is a mountain template in the previously generated tile template, then the mountain template can be used here; if the current environment information of the current grid is a building, and there is a building template in the tile template, then it is necessary to search the tiles for tiles whose environment information is also a building.

[0134] It should be noted that if there is no tile template, there is a high probability that there will be multiple "tiles with the same environmental information", that is, two grids with the same environmental information may index two different tiles, which will result in the need to load two different tiles when loading the target map. The setting of the tile template greatly reduces the above situation.

[0135] Step S173, placing the index value corresponding to the tile or tile template on the current grid.

[0136] The index value of the tile template is the index value of the tile template previously used as a tile.

[0137] Specifically, the present application uses index values ​​to splice tiles or tile templates, that is, the index values ​​are placed on the grid, and the placement and splicing of tiles or tile templates are achieved through the index mechanism between the tile set and the tiles.

[0138] After the index value is placed in each grid, the map formed by linking the tile and tile template corresponding to the index value is linked to the map grid to form a relationship to avoid index errors during the placement process, thereby obtaining the target map.

[0139] The following is a specific example to illustrate the effect of the above operation on simplifying map data.

[0140] Assume that there is a raw map data file exported by Tiled, which contains multiple layers, each of which contains a large amount of tile information, as well as possible object layers and attribute data. The file is stored in JSON or TMX format without any streamlining.

[0141] Further assuming that the original Figure 1 A total of 1,000 tiles are included, each tile is optimized (i.e., redundant and repeated information is deleted), the data type of the tile set of the map data is changed, and then after the tile template is determined, the tiles with the same environmental information as the tile template are deleted.

[0142] Effect of updating the tile set data type: Assuming that the overall data volume is reduced by 10% through this step, the reduced data volume for the entire map data file (assuming the original size is X KB) is 0.1X KB.

[0143] Effect of removing redundant tiles: After determining the tile template, 200 redundant tiles with the same environment information were deleted. Assuming that each tile occupies an average of 1KB of space, the amount of data is reduced by 200KB. This is one of the main parts of reducing the file size.

[0144] Detail optimization effect: On average, each tile is optimized from 1KB to 0.8KB. For the remaining 800 tiles, the total data volume is reduced by (1KB-0.8KB)*800=160KB. (For map data, the deleted tiles reduce the size of the entire tile, so the number of deleted tiles is calculated first and then the optimization effect on the remaining tiles).

[0145] Based on the above steps, assuming that the original map data file size is 1MB (i.e. 1024KB), the tile set data type update is reduced by 102.4KB. The approximate reduction after the streamlining operation is:

[0146] 1. Redundant tiles reduced: 200KB.

[0147] 2. Detail optimization and reduction: 160KB.

[0148] 3. Custom data types and index reshaping reduction (estimated at 10%): 102.4KB.

[0149] The total reduction is about 462.4KB, which means that the file size is reduced by about 45.16% (462.4KB / 1024KB).

[0150] It should be noted that this percentage is a rough estimate and will vary depending on factors such as the specific map data, the level of detail of the streamlining operation, and the optimization of the storage format.

[0151] See also Figure 3 In some embodiments, the method further comprises:

[0152] Step S21, receiving a map loading instruction, and cutting the target map according to a preset interest range.

[0153] Specifically, the preset interest range includes numerical information, model accuracy information, player quantity information, and building quantity information corresponding to the current display mode. That is, the preset interest range is determined by the current display mode selected by the player, and different display modes correspond to different data requirements. For example, the first display mode requires the target map to be fully displayed, and the second display mode requires only the model data and texture information therein to be displayed, and the model is the minimum accuracy version, and there is no need to display numerical values.

[0154] Therefore, before the target map is loaded and displayed, the data information in the target map can be further cropped according to the preset interest range selected by the player before being displayed.

[0155] Step S22, using a quadtree algorithm to determine the current visible area in the cropped target map.

[0156] Step S23, rendering each preset fixed element in the current visible area to obtain a current frame.

[0157] The preset fixed elements are objects or resources that exist in each area of ​​the target map, such as tree models, grass models, or special effect resources, etc., mainly in each area, which belong to the preset fixed elements. Each area here can refer to the four areas divided by the quadtree algorithm in step S22, or multiple areas that the target map is divided in advance.

[0158] The above embodiment performs further cropping and selective display when the target map is loaded, thereby reducing the data that needs to be rendered and further speeding up the loading speed of the game screen.

[0159] See also Figure 4 In some embodiments, the method further comprises:

[0160] Step S31, dividing each preset fixed element into a plurality of resource blocks and putting them into a loading queue.

[0161] The size of each resource block and the number of resource blocks can be determined based on the resource size of all preset fixed elements and the performance requirements of the game. The loading queue can use a resource manager to track currently loaded resources and loaded resources. The resource manager is responsible for deciding which resources need to be loaded in the current frame and which resources can wait for subsequent frames to load.

[0162] Step S32, calculating the current flow value, and determining whether the current flow value reaches a preset flow peak value.

[0163] Step S33: If yes, render the preset number of resource blocks in the loading queue to obtain the current frame.

[0164] Specifically, when the preset traffic peak is reached, in order to ensure the loading efficiency and smoothness of the game screen, it is necessary to further process each preset fixed element in frames, that is, only a limited number of elements are loaded in each frame; the loading process involves reading data from the disk, decoding, converting formats, etc. These steps also need to be accelerated to avoid affecting the frame rate of the game.

[0165] Furthermore, after all necessary resource blocks are loaded in the resource manager, they can be integrated into complete resources for use by the game logic and rendering engine.

[0166] The above embodiment adopts frame processing during traffic peaks, that is, only limited data is processed within one frame time, thereby ensuring the performance and smoothness of the game and bringing a better gaming experience to the players.

[0167] See also Figure 5In some embodiments, the quadtree algorithm is used to determine the current visible area in the cropped target map, which may specifically include the following steps:

[0168] Step S221, constructing a quadtree according to the cropped target map.

[0169] Specifically, the scope of the cropped target map is first used as the root node of the quadtree. Each node of the quadtree recursively divides its area according to the number of its child nodes. If the number of objects contained in a node exceeds a certain threshold or reaches the maximum depth, the node will be divided into four child nodes, each representing a quadrant.

[0170] In the game, as the player moves or other objects change dynamically, the quadtree needs to be dynamically updated to reflect these changes.

[0171] Step S222, generating a rectangular query area based on the player's current position coordinates and screen resolution.

[0172] Step S223, traversing the quadtree using the rectangular query area, determining each leaf node in the quadtree that intersects with the rectangular query area, and generating a current visible area according to each leaf node.

[0173] Specifically, starting from the root node, recursively traverse the quadtree. For each node, determine whether its boundary range intersects with the rectangular query area. If there is an intersection, further traverse its child nodes; if there is no intersection, skip the subtree. During the traversal process, collect all game objects in the leaf nodes that intersect with the rectangular query area as the current visible area.

[0174] In the process of traversing the query, the application skips the nodes that have no intersection with the query area, which can reduce unnecessary calculations.

[0175] The above-mentioned embodiment can effectively use the quadtree to manage the cropped target map and determine the current visible area of ​​the player, thereby optimizing game performance and improving the player experience.

[0176] In some embodiments, the above-mentioned calculation of the current flow value and determination of whether the current flow value reaches a preset flow peak value include:

[0177] Step S321, obtaining the current number of online players, system load and delayed response time.

[0178] Among them, the number of online players is the total number of active players in the current server; the system load is the CPU usage or memory usage of the server; the delayed response time is the time it takes for the server to receive the player's operation instructions and respond to the player's operation instructions.

[0179] Specifically, since the above three types of data change in real time, the time series is divided into periods to obtain each moment. For example, when the period is 1s, if it is judged at the current moment that the current traffic peak reaches the preset traffic peak, then within 1s starting from the current moment, each frame is processed according to the above-mentioned frame division operation until the next moment arrives.

[0180] Step S322, input the number of online players, system load, delayed response time and current time into the trained traffic analysis model to obtain the current traffic value; determine whether the current traffic value reaches the preset traffic peak value.

[0181] Specifically, before inputting into the traffic analysis model, since the metrics between the data are different, the collected data can be standardized to obtain the features corresponding to each data, and the format of the features meets the requirements of the traffic analysis model input.

[0182] The processed features and the current time are used as input to the trained traffic analysis model. The traffic analysis model will predict the current traffic value based on the input features and the learned patterns.

[0183] Among them, the traffic analysis model can use a deep learning model or a representation learning model.

[0184] Deep learning models include convolutional neural networks (CNN), recurrent neural networks (RNN), long short-term memory networks (LSTM), autoencoders, and convolutional recurrent neural networks (CRNN). Deep learning models learn complex patterns and features from massive data and solve several challenges that are difficult to handle with traditional time series analysis technologies, such as massive data modeling, complex time series changes, multivariate correlations, and the generalization of analysis models.

[0185] The representation learning model is used to automatically learn and select features. This method avoids the information loss and reliance on feature selection caused by secondary processing of traffic data sets in traditional machine learning algorithms, and improves the recognition accuracy of game traffic.

[0186] The above embodiment uses a traffic analysis model to calculate the current traffic value, which can effectively analyze and calculate the game traffic, thereby starting the frame processing operation to ensure that the game screen is smooth and not stuck.

[0187] In some embodiments, the above-mentioned generation of a rectangular query area based on the current position coordinates of the player and the screen resolution includes:

[0188] Step S2221, convert the current position coordinates into two-dimensional screen coordinates.

[0189] The player's current position coordinates are usually expressed in the form of (X, Y, Z), where the Z axis represents the height of the player's perspective (ie, the camera), and X and Y are the player's coordinates on the map.

[0190] When converting screen coordinates, the current position coordinates need to be converted to the camera coordinate system, which is usually achieved through a transformation matrix that contains the camera's position, rotation, and translation information.

[0191] Then, in the camera coordinate system, the perspective projection matrix is ​​used to project the 3D point onto a 2D plane. Perspective projection simulates the way the human eye observes the world, that is, the effect of near objects being larger and far objects being smaller. The point after perspective projection is in normalized device coordinates (NDC), whose x and y values ​​range from -1 to 1, and finally the point in NDC is used as the screen coordinate.

[0192] Step S2222, using the screen coordinates as the vertices of the viewing frustum, calculating the bottom surface area of ​​the viewing frustum according to the screen resolution, the vertical field of view angle and the horizontal field of view angle of the player; and using the bottom surface area as the rectangular query area.

[0193] Among them, the player's perspective is usually determined by a vertical field of view angle, namely the pitch angle (usually 45 degrees) and a horizontal field of view angle, namely the field of view angle (such as 90 degrees or wider). The perspective affects the range of the game world that the player can see.

[0194] Specifically, a viewing cone is first constructed. The viewing cone is a pyramid-shaped area formed by the viewing angle, with its vertices in the screen coordinates and the bottom on the visible plane. The tangent function is first used to calculate the half-width and half-height of the viewing cone, and then the half-width and half-height are multiplied by 2 to obtain the mapping size, and then multiplied by the screen resolution to obtain the screen pixels, that is, the rectangular query area.

[0195] For example, for a horizontal field of view angle θ, the half width The line of sight is a known data.

[0196] The above embodiment calculates the rectangular query area based on the principle of the viewing frustum, can accurately screen out the player's current visible area, and can prevent the map outside the current visible area from being rendered, thereby reducing unnecessary calculations and drawing and saving computing resources.

[0197] See also Figure 6 Another embodiment of the present application provides a device for processing game map data, including:

[0198] The acquisition module 101 is used to acquire the original map exported by Tiled, remove redundant information and repeated information, and obtain map data.

[0199] The data changing module 102 is used to change the original data type of each tile set in the map data into a preset data type; wherein the storage volume of the preset data type is smaller than the original data type.

[0200] The index updating module 103 is used to update the index value between each tile and the corresponding tile set.

[0201] The template generation module 104 is used to screen tiles that meet preset conditions and generate corresponding tile templates.

[0202] The deleting module 105 is used to delete tiles having the same environment information as the tile template.

[0203] The construction module 106 is used to receive a map generation instruction and construct a map grid using a random number generator.

[0204] The generation module 107 is used to splice tiles or tile templates based on the map grid and the index value to obtain a target map.

[0205] Furthermore, the device also includes:

[0206] The merge module is used to merge the layers belonging to the same category in the map data before changing the preset data type.

[0207] Furthermore, the building block 106 includes:

[0208] The initialization unit is used to receive a map generation instruction and create a blank initial map grid according to a preset size.

[0209] The construction unit is used to generate environmental information within an initial map grid using a random number generator to obtain a map grid.

[0210] See also Figure 7 , further, the generating module 107 includes:

[0211] The environment acquisition unit 71 is used to acquire the current environment information of the current grid.

[0212] The tile determination unit 72 is used to determine the tile or tile template corresponding to the current environment information.

[0213] The placement unit 73 is used to place the index value corresponding to the tile or tile template on the current grid.

[0214] Furthermore, the device also includes:

[0215] A cropping module, used to receive a map loading instruction and crop the target map according to a preset interest range;

[0216] A quadtree module, used to determine the current visible area in the cropped target map using a quadtree algorithm;

[0217] The rendering module is used to render each preset fixed element in the current visible area to obtain the current frame.

[0218] Furthermore, the device also includes:

[0219] A division module is used to divide each preset fixed element into multiple resource blocks and put them into a loading queue;

[0220] The flow determination module is used to calculate the current flow value and determine whether the current flow value reaches the preset flow peak value;

[0221] The rendering module is also used to render a preset number of rendering resource blocks in the loading queue when the current traffic value reaches a preset traffic peak value to obtain the current frame.

[0222] Furthermore, the above quadtree module includes:

[0223] A quadtree construction unit, used to construct a quadtree according to the cropped target map;

[0224] A rectangle generation unit, used to generate a rectangular query area based on the player's current position coordinates and screen resolution;

[0225] The traversal unit is used to traverse the quadtree using a rectangular query area, determine each leaf node in the quadtree that intersects with the rectangular query area, and generate a current visible area according to each leaf node.

[0226] Furthermore, the above-mentioned traffic judgment module is used to obtain the number of online players, system load and delayed response time at the current moment; input the number of online players, system load, delayed response time and the current moment into the trained traffic analysis model to obtain the current traffic value; and judge whether the current traffic value reaches the preset traffic peak value.

[0227] Furthermore, the rectangle generation unit is used to convert the current position coordinates into two-dimensional screen coordinates; use the screen coordinates as the vertices of the viewing cone, calculate the bottom area of ​​the viewing cone according to the screen resolution, the player's vertical field of view angle and the horizontal field of view angle; and use the bottom area as the rectangular query area.

[0228] The specific definition of a device for processing game map data provided in this embodiment can be found in the embodiment of a method for processing game map data described above, and will not be repeated here. Each module in the above-mentioned device for processing game map data can be implemented in whole or in part by software, hardware, and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each of the above modules.

[0229] An embodiment of the present application provides a computer device, which may include a processor, a memory, a network interface and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, the processor executes the steps of a method for processing game map data as in any of the above embodiments.

[0230] The working process, working details and technical effects of the computer device provided in this embodiment can be found in the above embodiment of a method for processing game map data, which will not be described in detail here.

[0231] The embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of a method for processing game map data as in any of the above embodiments are implemented. The computer-readable storage medium refers to a carrier for storing data, which may include but is not limited to a floppy disk, an optical disk, a hard disk, a flash memory, a USB flash drive and / or a memory stick, etc. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The working process, working details and technical effects of the computer-readable storage medium provided in this embodiment can be found in the above embodiment of a method for processing game map data, and will not be repeated here.

[0232] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0233] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0234] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A method for processing game map data, characterized in that: include: Get the original map exported by Tiled, remove redundant and repeated information, and get the map data; Changing the original data type of each tile set in the map data into a preset data type; Wherein, the storage volume of the preset data type is smaller than that of the original data type; Update the index value between each tile and the corresponding tile set; Screening the tiles that meet the preset conditions and generating corresponding tile templates; Deleting the tile having the same environment information as the tile template; Receive map generation instructions and use a random number generator to construct a map grid; Specifically, a map generation instruction is received, and a blank initial map grid is created according to a preset size; a random number generator is used to generate environmental information in the initial map grid to obtain the map grid; splicing the tiles or tile templates based on the map grid and the index value to obtain a target map; Specifically, current environment information of a current grid is acquired; the tile or the tile template corresponding to the current environment information is determined; and the index value corresponding to the tile or the tile template is placed on the current grid.

2. The method for processing game map data according to claim 1, characterized in that: The redundant information includes: A temporary layer, texture data whose closest distance to the player is greater than a preset distance threshold and whose resolution is greater than a preset resolution threshold, and model data whose closest distance to the player exceeds the preset distance threshold and whose geometric accuracy is greater than a preset accuracy threshold.

3. The method for processing game map data according to claim 1, characterized in that: The repeated information includes: References to the same model data and the same texture data at different locations.

4. The method for processing game map data according to claim 1, characterized in that: The preset data types include: byte type, bool type, char type or short type.

5. The method for processing game map data according to claim 1, characterized in that: Also includes: Before changing the preset data type, the layers belonging to the same category in the map data are merged.

6. The method for processing game map data according to claim 1, characterized in that: Also includes: Receiving a map loading instruction, and clipping the target map according to a preset interest range; Using a quadtree algorithm to determine the current visible area in the clipped target map; Rendering each preset fixed element in the current visible area to obtain a current frame.

7. The method for processing game map data according to claim 6, characterized in that: Also includes: Divide each of the preset fixed elements into a plurality of resource blocks and put them into a loading queue; Calculate the current flow value, and determine whether the current flow value reaches a preset flow peak value; If so, render the resource blocks of the preset rendering quantity in the loading queue to obtain the current frame.

8. The method for processing game map data according to claim 6, characterized in that: The method of using a quadtree algorithm to determine the current visible area in the clipped target map includes: Construct a quadtree according to the clipped target map; Generate a rectangular query area based on the player's current position coordinates and screen resolution; The quadtree is traversed using the rectangular query area to determine each leaf node in the quadtree that intersects with the rectangular query area, and the current visible area is generated according to each leaf node.

9. The method for processing game map data according to claim 7, characterized in that: The calculating the current flow value and determining whether the current flow value reaches a preset flow peak value includes: Get the current number of online players, system load, and latency response time; The number of online players, the system load, the delayed response time and the current time are input into a trained traffic analysis model to obtain the current traffic value; and it is determined whether the current traffic value reaches a preset traffic peak value.

10. The method for processing game map data according to claim 8, characterized in that: The generating of a rectangular query area based on the current position coordinates of the player and the screen resolution includes: Convert the current position coordinates into two-dimensional screen coordinates; The screen coordinates are used as vertices of a viewing frustum, and the bottom surface area of ​​the viewing frustum is calculated according to the screen resolution, the vertical viewing angle and the horizontal viewing angle of the player; and the bottom surface area is used as the rectangular query area.

11. The method for processing game map data according to claim 6, characterized in that: The preset interest range includes: numerical information corresponding to the current display mode, model accuracy information, player quantity information and building quantity information.

12. A device for processing game map data, characterized in that: include: The acquisition module is used to obtain the original map exported by Tiled, remove redundant and repeated information, and obtain map data; A data changing module, used for changing the original data type of each tile set in the map data into a preset data type; wherein the storage volume of the preset data type is smaller than that of the original data type; An index updating module, used for updating the index value between each tile and the corresponding tile set; A template generation module, used for screening the tiles that meet the preset conditions and generating corresponding tile templates; A deleting module, used for deleting the tile having the same environment information as the tile template; A construction module is used to receive a map generation instruction and use a random number generator to construct a map grid; specifically, receive a map generation instruction and create a blank initial map grid according to a preset size; use a random number generator to generate environmental information in the initial map grid, and obtain the map grid A generation module is used to splice the tiles or tile templates based on the map grid and the index values ​​to obtain a target map; specifically, obtain the current environment information of the current grid; determine the tiles or tile templates corresponding to the current environment information; and place the index values ​​corresponding to the tiles or tile templates on the current grid.

13. The game map data processing device according to claim 12, characterized in that: Also includes: The merging module is used to merge the layers belonging to the same category in the map data before changing the preset data type.

14. The game map data processing device according to claim 12, characterized in that: Also includes: A clipping module, used for receiving a map loading instruction and clipping the target map according to a preset interest range; A quadtree module, used to determine the current visible area in the cropped target map using a quadtree algorithm; The rendering module is used to render each preset fixed element in the current visible area to obtain a current frame.

15. The game map data processing device according to claim 14, characterized in that: Also includes: A division module, used for dividing each of the preset fixed elements into a plurality of resource blocks and putting them into a loading queue; A flow determination module is used to calculate the current flow value and determine whether the current flow value reaches a preset flow peak value; The rendering module is further configured to render a preset rendering quantity of the resource blocks in the loading queue to obtain the current frame when the current traffic value reaches the preset traffic peak value.

16. The game map data processing device according to claim 14, characterized in that: The quadtree module comprises: A quadtree construction unit, used for constructing a quadtree according to the clipped target map; A rectangle generation unit, used to generate a rectangular query area based on the player's current position coordinates and screen resolution; A traversal unit is used to traverse the quadtree using the rectangular query area, determine each leaf node in the quadtree that intersects with the rectangular query area, and generate the current visible area according to each leaf node.

17. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method for processing game map data as described in any one of claims 1 to 11 are implemented.

18. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for processing game map data as described in any one of claims 1 to 11 are implemented.

Citation Information

Patent Citations

  • Electronic map construction method and device, equipment and medium

    CN111210490A

  • Airborne vector map data processing method

    CN115687675A