2D game resource hierarchical sorting method, storage medium and device
By configuring character ID and random values for map characters in 2D games, and determining the display order based on these attributes in the overlapping part, the repeated flickering problem caused by overlapping multiple characters in 2D games is solved, and effective hierarchical sorting and picture optimization of 2D resources are achieved.
Patent Information
- Application Number
- CN202411770565.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-03-18
AI Technical Summary
In 2D games, multiple 2D characters overlap at the same time in the map scene, X-axis coordinates, Y-axis coordinates, and character IDs, resulting in repeated flickering problems.
When generating map roles, configure the role ID and a randomly generated random value for each role. When multiple characters are displayed on the map, overlap is judged by the Y-axis coordinates, and the character displayed in the overlapping part is determined based on the role ID and the random value. The character with the Y-axis coordinates are preferred. If the Y-axis coordinates are the same, the character with the front character ID is displayed. If the Y-axis coordinates are the same, the character with the front character with the front character's random value is displayed.
It solves the problem of repeated flickering caused by overlapping multiple characters in 2D games, optimizes the hierarchical sorting of all 2D resources in 2D games, and improves the stability and optimization effect of the game screen.
Smart Images

Figure CN119633370A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of 2D game technology, and in particular to a method, storage medium and device for hierarchical sorting of 2D game resources. Background Art
[0002] 2D games are a type of game in which combat takes place in a two-dimensional space.
[0003] More information related to the above technical solution can also be found in the following documents:
[0004] In a Chinese patent with publication number CN107789836A, a method and client for realizing online games with thousands of people on the same screen are disclosed, which include step 1: using AOP cross-cutting technology to collect client pressure point information in real time; step 2: classifying and loading resources, and classifying them according to the priority of the game plan, and establishing relevant classification numbers; step 3: establishing a file loading cache for resources corresponding to specific classification numbers, and making reference counts, and performing LIFO processing according to the actual memory capacity of the user's machine when running; step 4: character animation is cached according to the action frame sequence, and indexed according to the direction; step 5: comprehensively generating combined resources, dividing them according to the level, and then subdividing them according to the area size and sound duration; step 6: filtering and leaving the necessary parts according to the collected relevant pressure point information, optimizing the playback level, and submitting them in batches to the graphics card for rendering.
[0005] In the process of implementing the present invention, the inventors found that the prior art has the following problems:
[0006] In the prior art, in a 2D game, when multiple 2D characters are in a map scene, their X-axis coordinates, Y-axis coordinates, and character IDs overlap at the same time, which will cause a problem of repeated flickering. Summary of the invention
[0007] In view of the above problems, the present application provides a method, storage medium and device for hierarchical sorting of 2D game resources, which are used to solve the technical problem that in 2D games, when multiple 2D characters in a map scene have overlapping X-axis coordinates, Y-axis coordinates and character IDs, they will cause repeated flickering.
[0008] To achieve the above objectives, in a first aspect, the present application provides a method for hierarchical sorting of 2D game resources, comprising the following steps:
[0009] S1. Build a 2D game to form the X-axis and Y-axis in the 2D game map;
[0010] S2. When generating map characters, configure a character ID for each character and a randomly generated random value for each character;
[0011] S3. When multiple characters are displayed on the map, determine whether the multiple characters overlap by using the Y-axis coordinates of the multiple characters. If the multiple characters overlap, determine the character to be displayed based on the character IDs of the multiple characters, and display the character with the earlier character ID in the overlapping part.
[0012] S4. If the role IDs of multiple roles in the overlapping part are the same, the role to be displayed is determined based on the random values of the multiple roles, and the role with the higher random value is displayed in the overlapping part.
[0013] As an implementation mode of the present invention, in step S2, when generating a map character, a role ID is configured for each character, a different random value is generated for each character, and the role ID plus the random value is used as a unique identifier of the role and is set in the attributes of the role.
[0014] As an embodiment of the present invention, in step S3, when multiple characters are displayed on the map, when the X-axis coordinates are the same, the character with the front Y-axis coordinate is displayed;
[0015] When the X-axis coordinates and Y-axis coordinates are the same, the character with the earlier character ID will be displayed;
[0016] When the X-axis coordinates, Y-axis coordinates, and character IDs are the same, the character with the higher random value will be displayed.
[0017] As an implementation mode of the present invention, among the character IDs, the sorting priority of the human ID is greater than the sorting priority of the monster ID.
[0018] As an implementation mode of the present invention, when generating map characters, a health bar is configured for each character, and the health bar is displayed according to the sorting priority of the character.
[0019] As an implementation mode of the present invention, during the display of a 2D game map, the sorting priority of special effect display is higher than the sorting priority of character and monster display.
[0020] As an implementation of the present invention, in the step of configuring a randomly generated random value for each role, the system generates a key according to the setting, following the random value of each role. When the random value of each role needs to be modified, the key needs to be verified.
[0021] As an implementation mode of the present invention, in the step of configuring a randomly generated random value for each role, a random value is randomly generated, and it is determined whether the random value has appeared in the role ID. If the random value has appeared in the role ID, a random value is updated until the random value has not appeared in the role ID.
[0022] Different from the prior art, the technical solution of the present application is to configure a role ID for each role when generating a map role, and configure a randomly generated random value for each role; when displaying multiple roles on the map, the y-axis coordinates of the multiple roles are used to determine whether the multiple roles overlap. If multiple roles overlap, the role to be displayed is determined based on the role IDs of the multiple roles, and the role with the leading role ID is displayed in the overlapping part; if the role IDs of the multiple roles in the overlapping part are the same, the role to be displayed is determined based on the random values of the multiple roles, and the role with the leading role random value is displayed in the overlapping part. In this way, the role with the leading Y-axis coordinate is displayed first, and when the Y-axis coordinates are the same, the role with the leading role ID is displayed. When the Y-axis coordinates and the role ID are the same, the role with the leading role random value is displayed, which solves the problem of repeated flickering caused by the overlap of the Y-axis coordinates and the role ID, and solves the hierarchical sorting problem of all 2D resources in 2D games.
[0023] To achieve the above objectives, in a second aspect, the inventor provides a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the method steps as described in any one of the above are implemented.
[0024] To achieve the above object, in a third aspect, the inventor provides an electronic device, including a processor and a storage medium, wherein the storage medium is the storage medium as described above;
[0025] The processor is used to execute the computer program stored in the storage medium to implement any of the method steps described above.
[0026] The above-mentioned records related to the invention content are only an overview of the technical solution of the present application. In order to enable ordinary technicians in the field to more clearly understand the technical solution of the present application, and then implement it according to the text of the specification and the contents recorded in the drawings, and to make the above-mentioned purpose and other purposes, features and advantages of the present application easier to understand, the following is an explanation in combination with the specific implementation mode and drawings of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The drawings are only used to illustrate the principles, implementation methods, applications, characteristics and effects of the specific embodiments of the present application and other related contents, and shall not be considered as limitations of the present application.
[0028] In the drawings of the specification:
[0029] Figure 1 A logical diagram of a method for hierarchical sorting of 2D game resources according to an embodiment of the present application;
[0030] Figure 2 A schematic diagram of a module of an electronic device according to an embodiment of the present application;
[0031] Figure 3 A schematic diagram of overlapping role IDs in a map display according to an embodiment of the present application;
[0032] Figure 4 A schematic diagram of a map display in which Y-axis coordinates and character IDs overlap at the same time in an embodiment of the present application;
[0033] Figure 5 A schematic diagram of a special effect display of an embodiment of the present application;
[0034] Figure 6 This is a schematic diagram of the effect after hierarchical sorting of an embodiment of the present application.
[0035] The reference numerals in the above drawings are described as follows:
[0036] 10. Electronic equipment,
[0037] 101. Processor,
[0038] 102. Storage medium. DETAILED DESCRIPTION
[0039] In order to explain in detail the possible application scenarios, technical principles, specific schemes that can be implemented, and the purposes and effects that can be achieved, the following is a detailed description of the specific embodiments listed in conjunction with the accompanying drawings. The embodiments described herein are only used to more clearly illustrate the technical solutions of the present application, and are therefore only used as examples, and cannot be used to limit the scope of protection of the present application.
[0040] Reference to "embodiment" herein means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present application. The term "embodiment" appearing in various places in the specification does not necessarily refer to the same embodiment, nor does it particularly limit its independence or association with other embodiments. In principle, in the present application, as long as there is no technical contradiction or conflict, the various technical features mentioned in the embodiments can be combined in any way to form a corresponding implementable technical solution.
[0041] Unless otherwise defined, the technical terms used in this document have the same meanings as those generally understood by those skilled in the art to which this application belongs; the use of relevant terms in this document is only for describing specific embodiments and is not intended to limit this application.
[0042] In the description of this application, the term "and / or" is an expression used to describe the logical relationship between objects, indicating that three relationships may exist, for example, A and / or B, which means: A exists, B exists, and A and B exist at the same time. In addition, the character " / " in this article generally indicates that the objects before and after are in an "or" logical relationship.
[0043] In the present application, terms such as “first” and “second” are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship of quantity, priority or sequence between these entities or operations.
[0044] Without further limitations, in this application, the words "include", "comprises", "has" or other similar open-ended expressions used in sentences are intended to cover non-exclusive inclusion. These expressions do not exclude the presence of additional elements in the process, method or product including the elements, so that the process, method or product including a series of elements may include not only those limited elements, but also other elements not explicitly listed, or also include elements inherent to such process, method or product.
[0045] Similar to the understanding in the Examination Guidelines, in this application, expressions such as "greater than", "less than", "exceed" and the like are understood to exclude the number itself; expressions such as "above", "below", "within" and the like are understood to include the number itself. In addition, in the description of the embodiments of this application, "multiple" means more than two (including two), and similar expressions related to "multiple" are also understood in this way, such as "multiple groups", "multiple times", etc., unless otherwise clearly and specifically limited.
[0046] In the description of the embodiments of the present application, space-related expressions used, such as "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "vertical", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential", etc., indicate the orientation or position relationship based on the orientation or position relationship shown in the specific embodiments or drawings, and are only for the convenience of describing the specific embodiments of the present application or facilitating the reader's understanding, and do not indicate or imply that the referred device or component must have a specific position, a specific orientation, or be constructed or operated in a specific orientation, and therefore cannot be understood as a limitation on the embodiments of the present application.
[0047] The processor described in the embodiments of the present application can be implemented by hardware, firmware, software or a combination thereof, and can use a circuit, a single or multiple application-specific integrated circuits (Application Specific Integrated Circuit, ASIC), a digital signal processor (Digital Signal Processor, DSP), a digital signal processing device (Digital Signal Processing Device, DSPD), a programmable logic device (Programmable Logic Device, PLD), a field programmable gate array (Field Programmable Gate Array, FPGA), a central processing unit (Central Processing Unit, CPU), a controller, a microcontroller, at least one of a microprocessor, and also includes other physical, biological or chemical structures that can achieve similar or equivalent functions to the processors listed above, such as biological neurons, quantum computing units, DNA computing units, etc., so that the processor can execute some or all of the steps in the computer program or method involved in the various embodiments of the present application, or any combination of the steps mentioned therein.
[0048] The computer program involved in the embodiment can be stored in a computer device readable storage medium, which includes but is not limited to a disk, a tape, a magnetic card, a floppy disk, a flash memory, an optical disk, an optical card, a read-only memory (ROM), a random access memory (RAM), an erasable programmable ROM (EPROM) and an electrically erasable programmable ROM (EEPROM), etc., and also includes other biological, physical or chemical structures that can achieve the same or equivalent functions as the storage media listed above, such as DNA, RNA, protein and other units with information storage capabilities. In a specific embodiment, the storage medium involved can be one of the above-mentioned media types, or a combination of the above-mentioned media types. In different embodiments, the computer program involved in the embodiment can be stored in a single medium in a centralized manner, or it can be stored in multiple media in a distributed manner. The memory containing the computer device readable storage medium can be a non-volatile memory or a random access memory. These computer device readable storage media can be built into the device, or they can be connected to the device involved in the embodiment as an external device or a part of an external device. In some embodiments, a memory with a computer device readable storage medium is deployed locally; in other embodiments, a solution of deploying the memory away from the processor may also be adopted, such as a network attached memory accessed via an RF circuit or an external port and a communication network, wherein the communication network may be the Internet, one or more intranets, a local area network (LAN), a wide area network (WLAN), a storage area network (SAN), etc., or a suitable combination thereof, as long as the computer device can access the memory. In addition, the computer program involved in the embodiment may be stored in plaintext / ciphertext form, or may be designed as training data, which may be integrated and reorganized through model training and implicitly stored in the parameter state of a deep neural network or other machine learning model.
[0049] According to some embodiments of the present application, please refer to Figures 1 to 6 This embodiment relates to a method for hierarchical sorting of 2D game resources, comprising the following steps:
[0050] S1. Build a 2D game to form the X-axis and Y-axis in the 2D game map;
[0051] S2. When generating map characters, configure a character ID for each character and a randomly generated random value for each character;
[0052] S3. When multiple characters are displayed on the map, determine whether the multiple characters overlap by using the Y-axis coordinates of the multiple characters. If the multiple characters overlap, determine the character to be displayed based on the character IDs of the multiple characters, and display the character with the earlier character ID in the overlapping part.
[0053] S4. If the role IDs of multiple roles in the overlapping part are the same, the role to be displayed is determined based on the random values of the multiple roles, and the role with the higher random value is displayed in the overlapping part.
[0054] In this embodiment, the X-axis is Figures 3 to 6 The left and right horizontal directions, the Y axis is Figures 3 to 6 vertical direction.
[0055] The characters in this embodiment include human characters, monster characters, pet characters, etc. The monster characters include plant characters, animal characters, etc.
[0056] The character ID can be directly displayed in the character animation, but the random value cannot be displayed in the character animation.
[0057] Thus, this embodiment configures a role ID for each role when generating a map role, and configures a randomly generated random value for each role; when displaying multiple roles on the map, the y-axis coordinates of the multiple roles are used to determine whether the multiple roles overlap. If multiple roles overlap, the role to be displayed is determined based on the role IDs of the multiple roles, and the role with the leading role ID is displayed in the overlapping part; if the role IDs of the multiple roles in the overlapping part are the same, the role to be displayed is determined based on the random values of the multiple roles, and the role with the leading role random value is displayed in the overlapping part. In this way, the role with the leading Y-axis coordinate is displayed first, and when the Y-axis coordinates are the same, the role with the leading role ID is displayed. When the Y-axis coordinates and the role IDs are the same, the role with the leading role random value is displayed, which solves the problem of repeated flickering caused by the overlap of the Y-axis coordinates and the role ID, and solves the problem of hierarchical sorting of all 2D resources in 2D games.
[0058] According to some embodiments of the present application, optionally, in step S2, when generating a map character, a role ID is configured for each character, a different random value is generated for each character, and the role ID plus the random value is used as a unique identifier of the role and is set in the attributes of the role.
[0059] In this way, by adding a random value to the character ID, each character is made unique, avoiding the problem of repeated flashing when two characters overlap.
[0060] According to some embodiments of the present application, optionally, in step S3, when multiple characters are displayed on the map, when the X-axis coordinates are the same, the character with the front Y-axis coordinate is displayed;
[0061] When the X-axis coordinates and Y-axis coordinates are the same, the character with the earlier character ID will be displayed;
[0062] When the X-axis coordinates, Y-axis coordinates, and character IDs are the same, the character with the higher random value will be displayed.
[0063] In this way, we can first determine the position of the Y-axis coordinate, then determine the order of the character IDs, and finally determine the character random value. This can solve the hierarchical sorting problem of all 2D resources and optimize the picture.
[0064] According to some embodiments of the present application, optionally, among the character IDs, the sorting priority of the character ID is greater than the sorting priority of the monster ID.
[0065] In this way, the character ID can be displayed preferentially.
[0066] According to some embodiments of the present application, optionally, when generating a map character, a health bar is configured for each character, and the health bar is displayed according to the sorting priority of the character.
[0067] In this way, the health bar can be displayed according to the order of the characters, and the order of character display can be determined based on the health bar.
[0068] According to some embodiments of the present application, optionally, during the display of a 2D game map, the sorting priority of special effects display is greater than the sorting priority of characters and monsters display.
[0069] So, like Figure 5 As shown, when skill special effects appear, the effects of the special effects are displayed first before characters and monsters.
[0070] According to some embodiments of the present application, optionally, in the step of configuring a randomly generated random value for each role, the system generates a key according to the setting, following the random value of each role, and when the random value of each role needs to be modified, the key needs to be verified.
[0071] In this way, when generating special effects, a key is generated synchronously. When modifying the random value of each character, it must be authenticated by the key before it can be modified to prevent the random value from being modified arbitrarily.
[0072] According to some embodiments of the present application, optionally, in the step of configuring a randomly generated random value for each role, a random value is randomly generated, and it is determined whether the random value has appeared in the role ID. If the random value has appeared in the role ID, a random value is updated until the random value has not appeared in the role ID.
[0073] In this way, after generating a random value, it is necessary to first determine whether the same random value has been generated for this role ID before. If the same random value has appeared, a new random value must be generated until the random value has not appeared for this role ID, thereby avoiding the same random value appearing in the same role ID and achieving a unique random value for the same role ID.
[0074] In a second aspect, the present invention further provides a storage medium storing a computer program, which implements the method steps of the first aspect of the present invention when executed by a processor.
[0075] On the third side, see Figure 5 The present invention also provides an electronic device 10, including a processor 101 and a storage medium 102, wherein the storage medium 102 is the storage medium of the second aspect; the processor 101 is used to execute the computer program stored in the storage medium 102 to implement the method steps of the first aspect.
[0076] Finally, it should be noted that although the above embodiments have been described in the specification and drawings of this application, this does not limit the scope of patent protection of this application. All technical solutions generated by replacing or modifying equivalent structures or equivalent processes based on the essential concept of this application using the contents recorded in the specification and drawings of this application, as well as directly or indirectly implementing the technical solutions of the above embodiments in other related technical fields, are included in the scope of patent protection of this application.
Claims
1. A method for hierarchical sorting of 2D game resources, characterized in that: The following steps are involved: S1. Build a 2D game to form the X-axis and Y-axis in the 2D game map; S2. When generating map characters, configure a character ID for each character and a randomly generated random value for each character; S3. When multiple characters are displayed on the map, determine whether the multiple characters overlap by using the Y-axis coordinates of the multiple characters. If the multiple characters overlap, determine the character to be displayed based on the character IDs of the multiple characters, and display the character with the earlier character ID in the overlapping part. S4. If the role IDs of multiple roles in the overlapping part are the same, the role to be displayed is determined based on the random values of the multiple roles, and the role with the higher random value is displayed in the overlapping part.
2. The method for hierarchical sorting of 2D game resources according to claim 1, characterized in that: In step S2, when generating a map character, a character ID is configured for each character, and a different random value is generated for each character. The character ID plus the random value is used as the unique identifier of the character and is set in the attributes of the character.
3. The method for hierarchical sorting of 2D game resources according to claim 2, characterized in that: In step S3, when multiple characters are displayed on the map, when the X-axis coordinates are the same, the character with the front Y-axis coordinate is displayed; When the X-axis coordinates and Y-axis coordinates are the same, the character with the earlier character ID will be displayed; When the X-axis coordinates, Y-axis coordinates, and character IDs are the same, the character with the higher random value will be displayed.
4. The method for hierarchical sorting of 2D game resources according to claim 1 or 2, characterized in that: Among the character IDs, the sorting priority of the character ID is higher than the sorting priority of the monster ID.
5. The method for hierarchical sorting of 2D game resources according to any one of claims 1 to 3, characterized in that: When generating map characters, a health bar is configured for each character, and the health bar is displayed according to the character's sorting priority.
6. The method for hierarchical sorting of 2D game resources according to any one of claims 1 to 3, characterized in that: During the 2D game map display process, the sorting priority of special effects display is higher than the sorting priority of character and monster display.
7. The method for hierarchical sorting of 2D game resources according to claim 1, characterized in that: In the step of configuring a randomly generated random value for each role, the system generates a key according to the settings, following the random value of each role. When the random value of each role needs to be modified, the key needs to be verified.
8. The method for hierarchical sorting of 2D game resources according to claim 1, characterized in that: In the step of configuring a randomly generated random value for each role, a random value is randomly generated, and it is determined whether the random value has appeared in the role ID. If the random value has appeared in the role ID, a random value is updated until the random value has not appeared in the role ID.
9. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method steps according to any one of claims 1 to 8 are implemented.
10. An electronic device, characterized in that: comprising a processor and a storage medium, wherein the storage medium is the storage medium according to claim 9; The processor is used to execute the computer program stored in the storage medium to implement the method steps according to any one of claims 1 to 8.
Citation Information
Patent Citations
Online game thousand-player on-screen implement method and client
CN107789836A