Game combat method and device based on synchronization of logic layer and rendering layer
By splitting the game combat system into logic layer and rendering layer, and synchronizing combat instructions in each frame, the problem of tight coupling of combat logic and rendering in the existing technology is solved, achieving more efficient development and better game performance and visual effects.
Patent Information
- Application Number
- CN202510110823.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-23
- Publication Date
- 2025-05-06
AI Technical Summary
In existing game systems, combat logic and rendering are tightly coupled, resulting in poor maintainability, limited scalability, low development efficiency and high communication costs.
The game combat system is split into a combat logic layer and a combat rendering layer. The combat logic layer is responsible for initializing and setting the game character attributes, skills and rules, and the combat rendering layer is responsible for generating visual and sound performance. The battle instructions generated by the user's operation are passed from the battle logic layer to the battle rendering layer each frame.
It realizes the decoupling of combat logic and rendering, reduces development and maintenance costs, supports cross-platform development, and improves game performance and visual effects.
Smart Images

Figure CN119925924A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a game combat method, apparatus, computing device and computer-readable storage medium based on synchronization of a logic layer and a rendering layer. Background Art
[0002] In existing game systems, the game's combat logic and rendering are tightly coupled together. All calculations and drawing work are performed in the same module or the same code. The combat logic processing and rendering process are mixed together. For example, the character's attack, skill release, damage calculation, etc. are all performed simultaneously in the rendering frame. All logic and rendering are synchronized through direct calls or shared variables. Such a solution has problems such as poor maintainability, limited scalability, and cannot be reused and transplanted. It is also difficult for developers to be responsible for different modules independently because they are highly coupled with each other, resulting in reduced development efficiency and increased communication costs. Summary of the invention
[0003] In view of this, the embodiments of the present application provide a game combat method, a computing device, and a computer-readable storage medium based on synchronization of a logic layer and a rendering layer to solve the technical defects existing in the prior art.
[0004] According to a first aspect of an embodiment of the present application, a game battle method based on synchronization of a logic layer and a rendering layer is provided, which is used for a client and includes:
[0005] When a battle starts, a battle logic layer instance and a battle rendering layer instance are created simultaneously; the battle logic layer instance is responsible for initializing and setting the attributes, skills and battle rules of the game character; the battle rendering layer instance is responsible for generating visual and sound effects based on the data generated by the battle logic layer;
[0006] Execute the combat logic in the combat logic layer instance according to the user's operation in each frame to generate combat instructions;
[0007] The battle instruction is synchronized to the battle rendering layer instance in the current frame, so that the battle rendering layer instance completes the rendering of the battle scene according to the battle instruction.
[0008] According to a second aspect of an embodiment of the present application, a game battle device based on synchronization of a logic layer and a rendering layer is provided, the device comprising:
[0009] A creation unit, used to simultaneously create a battle logic layer instance and a battle rendering layer instance when a battle begins; the battle logic layer instance is responsible for initializing and setting the attributes, skills and battle rules of the game character; the battle rendering layer instance is responsible for generating visual and sound effects according to the data generated by the battle logic layer;
[0010] An execution unit, used to execute the combat logic in the combat logic layer instance according to the user's operation in each frame and generate combat instructions;
[0011] A synchronization unit is used to synchronize the battle instruction to the battle rendering layer instance in the current frame, so that the battle rendering layer instance completes the rendering of the battle scene according to the battle instruction.
[0012] According to a third aspect of an embodiment of the present application, a computing device is provided, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein when the processor executes the instructions, the steps of the game combat method based on synchronization of a logic layer and a rendering layer are implemented.
[0013] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer instructions, and when the instructions are executed by a processor, the steps of the game combat method based on synchronization of a logic layer and a rendering layer are implemented.
[0014] In the embodiment of the present application, the game battle system is split into a battle logic layer and a battle rendering layer; the battle logic layer is responsible for initializing and setting the attributes, skills and battle rules of the game characters; the battle rendering layer is responsible for realizing visual and sound effects according to the data generated by the battle logic layer. The battle instructions generated by the user operation are passed from the battle logic layer to the battle rendering layer for each frame. This solution realizes the decoupling of battle logic and rendering, which greatly reduces the cost of development and maintenance; the battle logic layer also realizes the processing of different motion modes on different platforms, which not only ensures the visual effects of the game but also completes the correct calculation of logic with limited resources. This solution has a wide range of application value in various scenarios such as real-time battles, turn-based battles, MMORPG battles, etc. Through the separated design, while improving the game performance, on the other hand, it better realizes the complex battle system and rich visual effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 is a structural block diagram of a computing device provided in an embodiment of the present application;
[0016] Figure 2 It is a flowchart of a game combat method based on synchronization of a logic layer and a rendering layer provided in an embodiment of the present application;
[0017] Figure 3 It is a structural schematic diagram of a game combat device based on synchronization of a logic layer and a rendering layer provided in an embodiment of the present application. DETAILED DESCRIPTION
[0018] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0019] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.
[0020] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "in response to determination".
[0021] In the present application, a game combat method and apparatus based on synchronization of a logic layer and a rendering layer, a computing device, and a computer-readable storage medium are provided, which are described in detail one by one in the following embodiments.
[0022] Figure 1 The structure block diagram of a computing device 100 according to an embodiment of the present application is shown. The components of the computing device 100 include but are not limited to a memory 110 and a processor 120. The processor 120 is connected to the memory 110 via a bus 130, and the database 150 is used to store data.
[0023] The computing device 100 also includes an access device 140 that enables the computing device 100 to communicate via one or more networks 160. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 140 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0024] In one embodiment of the present application, the above components of the computing device 100 and Figure 1 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 1 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.
[0025] The computing device 100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 100 may also be a mobile or stationary server.
[0026] In the embodiment of the present application, a game combat method based on synchronization of the logic layer and the rendering layer is proposed. The method is used for the client. Figure 2 ; Figure 2 A flowchart of a game battle method based on synchronization of a logic layer and a rendering layer provided according to an embodiment of the present application is shown, including steps 202 to 206.
[0027] Step 202: When a battle starts, a battle logic layer instance and a battle rendering layer instance are created simultaneously.
[0028] In this step, when the game combat state begins, the game process simultaneously creates a combat logic layer instance and a combat rendering instance.
[0029] When creating a battle logic layer instance, the game character's attributes, skills, and battle rules are initialized and set. Each battle entity in the battle logic layer instance corresponds to a character model. The battle logic layer instance does not involve multimedia presentations such as the images and sound effects presented to players in the game, but focuses on the core processing of game rules, settlement, combat behavior, and character behavior decisions, such as the logic of character movement, attack, skill release, death, and battle victory and defeat judgment.
[0030] When creating a battle rendering layer instance, initialize the role model, set the corresponding animation and other resources related to UI rendering, and wait for the instructions of the battle logic layer instance to perform the corresponding actions. Among them, the battle rendering layer instance is responsible for generating visual and sound effects based on the data generated by the battle logic layer, such as the rendering of role movement, the generation of combat objects, the special effects and sound effects of skill release, the change of role health, etc. Among them, the battle rendering layer instance performs relevant rendering work according to the instructions output by the battle logic layer instance.
[0031] Step 204: The battle logic layer instance executes the battle logic according to the user's operation in each frame and generates battle instructions.
[0032] In this step, the battle logic layer instance executes the game battle logic based on the user's operation in frames and generates corresponding battle instructions.
[0033] Yes, in a turn-based strategy game, when the player clicks the attack button in the game, the battle logic layer instance first determines whether this action is feasible; if the attack is feasible, the battle logic layer instance will calculate the effect of the attack and generate an "attack" battle instruction, which contains all relevant detailed information, and passes this instruction to the battle rendering layer instance. In real-time battles and battles in other types of games, the battle logic layer instance can also efficiently calculate and process a large number of concurrent battle events, which not only improves the performance of the game, but also better realizes complex battle systems and rich visual effects.
[0034] Specifically, in a schematic combat logic layer instance, the MSubObjBullet class instance extends and implements the behavior and logic of bullets fired by characters during combat, including collision detection, motion updates, initialization, destruction, etc., and generates combat instructions based on the updates of bullet positions and angles.
[0035] When called in each frame, the combat logic layer instance updates the logical state of the bullet, creates a bullet object, detects whether the bullet hits the target or exceeds the maximum flight time, and executes corresponding logic based on these conditions, such as stopping the bullet, calling the hit event, etc.
[0036] For example, in the create method of the MSubObjBullet class:
[0037] Initialize the bullet object, obtain the target position, calculate the bullet's moving direction, initial position and height, etc.
[0038] Configure bullet properties: Set the bullet's current angle, maximum flight time and other properties to determine the bullet's flight path and time.
[0039] Special logic processing: Perform some special bullet logic settings, such as trajectory calculation and angle adjustment for different types of bullets.
[0040] Generate combat instructions: Notify the combat rendering layer to update the display of bullets by pushing new bullet objects and rotation events.
[0041] Furthermore, the smUpdatePosition(dt:number) method of the MSubObjBullet class is responsible for calculating the new position of the bullet based on the input time increment dt, and updating the bullet's currPosX and currPosZ properties. After the position is updated, a combat command is generated based on the latest position information.
[0042] / / Update the bullet's end position in the current frame based on direction and speed
[0043] this._smCurrPosX+=MFixFloat.getFixFloat(this._moveDirX*this._speed*dt);
[0044] this._smCurrPosZ+=...
[0045] Preferably, the battle logic layer instance is adapted to both the server side and the client side.
[0046] The above _smCurrPosX and _smCurrPosZ are the end positions of the bullet in the current frame. For the server, the bullet position is a straight line relative to the previous frame, and it is only necessary to record its end position in each frame, thereby greatly reducing the calculation complexity and server load. For the client, the trajectory of the bullet is varied, such as parabola, rotation and forward movement, etc. Therefore, when the above combat logic layer instance is executed on the client, the position of the bullet is simulated by interpolation calculation in accordance with the target trajectory, so that the bullet produces a visual effect such as parabolic motion.
[0047]
[0048]
[0049] Then another combat command is generated, which notifies the combat rendering layer to update the bullet position display by pushing the bullet position event:
[0050] MSendToRenderUtils.pushPostionEvent(this._smCurrPosX,this._smCurrPosZ,1,this.currHeight,...);
[0051] Among them, in the MSendToRenderUtils class, there are a series of static methods used to pass events from the battle logic layer instance to the battle rendering layer instance. These methods achieve communication by triggering various battle reminder events, including but not limited to:
[0052] Events that create new objects (such as characters, skill effects, etc.):
[0053]
[0054]
[0055] Trigger an object position update event:
[0056]
[0057] Trigger animation update event:
[0058]
[0059] Step 206: Synchronize the battle command to the battle rendering layer instance to complete the battle rendering.
[0060] In this step, the battle rendering layer instance performs corresponding rendering according to the battle instruction generated in step 204 to complete the rendering of the battle scene.
[0061] Specifically, the data adapter WorldSceneMgr listens to various battle reminder events generated in step 204, converts the event parameters from BattleNotifier into object instances that can be used by the battle rendering layer instance, and the battle rendering instance layer then implements the corresponding rendering logic according to the object instance to ensure the compatibility and consistency of data transmission and use between different layers, such as:
[0062]
[0063]
[0064] Furthermore, the battle rendering layer instance completes the rendering of the battle scene according to the data converted by the data adapter WorldSceneMgr.
[0065] Preferably, after the battle of the client is completed, the server executes the battle logic layer instance of the battle system again according to the instructions of the client to verify whether the battle result is correct, wherein the battle logic layer instance of the server is the same as the battle logic layer instance of the client.
[0066] In the above embodiment of the present application, the game battle system is divided into two independent parts, the battle logic layer and the battle rendering layer; wherein the battle logic layer is responsible for initializing and setting the attributes, skills and battle rules of the game characters; and the battle rendering layer is responsible for realizing visual and sound performance according to the data generated by the battle logic layer. Each frame of the battle command generated by the user operation is passed from the battle logic layer to the battle rendering layer, so that the display and logic of the game can work together. This scheme makes the code structure of the battle system clearer, decouples the battle logic from the rendering, and greatly reduces the cost of development and maintenance; due to the separation of logic and rendering, developers can easily carry out cross-platform development and use the same set of battle logic for different platforms such as PC and mobile terminals; and the battle logic layer realizes the processing of different motion modes on different platforms, which not only ensures the visual effects of the game but also completes the correct calculation of the logic with limited resources. This scheme has a wide range of application value in various scenarios such as real-time battles, turn-based battles, MMORPG battles, etc. Through the separated design, while improving the game performance, on the other hand, it better realizes the complex battle system and rich visual effects.
[0067] Corresponding to the above method embodiment, the present application also provides an embodiment of a game combat device based on synchronization of a logic layer and a rendering layer, such as Figure 3 As shown, the device comprises:
[0068] A creation unit, used to simultaneously create a battle logic layer instance and a battle rendering layer instance when a battle begins; the battle logic layer instance is responsible for initializing and setting the attributes, skills and battle rules of the game character; the battle rendering layer instance is responsible for generating visual and sound effects according to the data generated by the battle logic layer;
[0069] An execution unit, used to execute the combat logic in the combat logic layer instance according to the user's operation in each frame and generate combat instructions;
[0070] A synchronization unit is used to synchronize the battle instruction to the battle rendering layer instance in the current frame, so that the battle rendering layer instance completes the rendering of the battle scene according to the battle instruction.
[0071] The above is a schematic scheme of a game battle device based on synchronization of the logic layer and the rendering layer of this embodiment. It should be noted that the technical scheme of the device and the technical scheme of the game battle method based on synchronization of the logic layer and the rendering layer belong to the same concept, and the details not described in detail in the technical scheme of the device can be referred to the description of the technical scheme of the game battle method based on synchronization of the logic layer and the rendering layer.
[0072] In one embodiment of the present application, a computing device is also provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor. When the processor executes the instructions, the steps of the game combat method based on synchronization of the logic layer and the rendering layer are implemented.
[0073] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned game combat method based on synchronization of the logic layer and the rendering layer belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above-mentioned game combat method based on synchronization of the logic layer and the rendering layer.
[0074] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the game combat method based on synchronization of a logic layer and a rendering layer as described above.
[0075] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the game combat method based on synchronization of the logic layer and the rendering layer are of the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the game combat method based on synchronization of the logic layer and the rendering layer.
[0076] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0077] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0078] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0079] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0080] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.
Claims
1. A game combat method based on synchronization of logic layer and rendering layer, used in a client, characterized in that: include: When the battle starts, create the battle logic layer instance and the battle rendering layer instance at the same time; The battle logic layer instance is responsible for initializing and setting the game character's attributes, skills, and battle rules; the battle rendering layer instance is responsible for generating visual and sound effects based on the data generated by the battle logic layer; Execute the combat logic in the combat logic layer instance according to the user's operation in each frame to generate combat instructions; The battle instruction is synchronized to the battle rendering layer instance in the current frame, so that the battle rendering layer instance completes the rendering of the battle scene according to the battle instruction.
2. The method according to claim 1, wherein: The combat logic layer instance executes combat logic according to the user's operation in each frame, and generates combat instructions including: The same combat logic layer instance is adapted to both the server and the client.
3. The method according to claim 2, wherein: The combat logic layer instance is adapted to both the server and the client and includes: For the server side, the combat logic layer instance calculates the end point of the combat object in each frame; For the client, the combat logic layer instance further performs interpolation simulation calculations on the position of the combat object that conforms to the target trajectory, so as to realize the rendering of the target trajectory on the client.
4. The method according to claim 2, wherein: The battle logic layer instance executes the battle logic according to the user's operation in each frame, and generates the battle instruction further comprising: When generating a combat instruction, the combat logic layer instance triggers a plurality of combat reminder events to realize the communication between the combat logic layer instance and the combat rendering layer.
5. The method according to claim 4, wherein: The step of synchronizing the battle command to the battle rendering layer in the current frame includes: The data adapter monitors the battle reminder event, converts the event parameters into an object instance used by the battle rendering layer instance, and the battle rendering instance layer further implements the corresponding rendering logic according to the object instance.
6. The method according to claim 1, wherein: The method also includes: after the battle of the client is completed, the server executes the battle logic layer instance again according to the instructions of the client to verify whether the battle result is correct; wherein the battle logic layer instance of the server is the same as the battle logic layer instance of the client.
7. A game combat device based on synchronization of logic layer and rendering layer, characterized in that: include: Creation unit, used to create battle logic layer instance and battle rendering layer instance at the beginning of battle; The battle logic layer instance is responsible for initializing and setting the game character's attributes, skills, and battle rules; the battle rendering layer instance is responsible for generating visual and sound effects based on the data generated by the battle logic layer; An execution unit, used to execute the combat logic in the combat logic layer instance according to the user's operation in each frame and generate combat instructions; A synchronization unit is used to synchronize the battle instruction to the battle rendering layer instance in the current frame, so that the battle rendering layer instance completes the rendering of the battle scene according to the battle instruction.
8. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that: When the processor executes the instructions, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by a processor, the steps of the method described in any one of claims 1 to 6 are implemented.
Citation Information
Cited By
A method and system for processing instant combat data
CN122605178A