CN116617669A - Collision test and detection method, device and storage medium thereof - Google Patents

Collision test and detection method, device and storage medium thereof Download PDF

Info

Publication number
CN116617669A
CN116617669A CN202310586105.9A CN202310586105A CN116617669A CN 116617669 A CN116617669 A CN 116617669A CN 202310586105 A CN202310586105 A CN 202310586105A CN 116617669 A CN116617669 A CN 116617669A
Authority
CN
China
Prior art keywords
player character
player
virtual map
grid
collision
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202310586105.9A
Other languages
Chinese (zh)
Other versions
CN116617669B (en
Inventor
赖玮
严泽涛
桂景祁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Yingfeng Network Technology Co ltd
Original Assignee
Guangzhou Yingfeng Network Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Yingfeng Network Technology Co ltd filed Critical Guangzhou Yingfeng Network Technology Co ltd
Priority to CN202310586105.9A priority Critical patent/CN116617669B/en
Publication of CN116617669A publication Critical patent/CN116617669A/en
Application granted granted Critical
Publication of CN116617669B publication Critical patent/CN116617669B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/55Controlling game characters or game objects based on the game progress
    • A63F13/57Simulating properties, behaviour or motion of objects in the game world, e.g. computing tyre load in a car race game
    • A63F13/577Simulating properties, behaviour or motion of objects in the game world, e.g. computing tyre load in a car race game using determination of contact between game characters or objects, e.g. to avoid collision between virtual racing cars
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/53Controlling the output signals based on the game progress involving additional visual information provided to the game scene, e.g. by overlay to simulate a head-up display [HUD] or displaying a laser sight in a shooting game
    • A63F13/537Controlling the output signals based on the game progress involving additional visual information provided to the game scene, e.g. by overlay to simulate a head-up display [HUD] or displaying a laser sight in a shooting game using indicators, e.g. showing the condition of a game character on screen
    • A63F13/5378Controlling the output signals based on the game progress involving additional visual information provided to the game scene, e.g. by overlay to simulate a head-up display [HUD] or displaying a laser sight in a shooting game using indicators, e.g. showing the condition of a game character on screen for displaying an additional top view, e.g. radar screens or maps

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Radar, Positioning & Navigation (AREA)
  • Physics & Mathematics (AREA)
  • Optics & Photonics (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention discloses a collision test and a detection method, equipment and a storage medium thereof, wherein the collision test method comprises the following steps: editing the virtual map in the tile map editor; loading user-controlled player characters in the virtual map during the virtual map test; if a movement operation triggered by the player character is received, planning a path for avoiding the current non-player character for the player character in a plurality of grids; extracting visual features in the virtual map from the player character and the non-player character as visual features in the process of controlling the player character to move along the path; detecting whether a visual collision occurs between the non-player character and the player character according to the visual characteristics; and writing the information of the visual collision between the player character and the non-player character into a test report. The present embodiment maintains the visual characteristics of the player character and the non-player character in the collision detection, thereby improving the accuracy of the collision detection.

Description

Collision test and detection method, device and storage medium thereof
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a collision test method, a collision test device, and a storage medium.
Background
In application programs such as functional games, social applications, shopping applications and the like, an independent virtual map is designed, and most of the virtual maps are simple tile maps, so that a user can control virtual roles to play games, social activities, shopping and the like in the virtual maps.
In the process of controlling the movement of the virtual characters by the user, the virtual characters may collide with other moving virtual characters, so that whether collision occurs between the two virtual characters needs to be detected in real time, and when a collision event occurs between the two virtual characters is detected, the collision event can be processed in a callback.
However, in a tile map, a virtual character is generally moved as a particle, and in collision detection, whether the particle collides is detected by using the particle, and because the particle deviates from the visually presented gesture of the virtual character in a UI (User Interface), it may happen that the particle does not collide, and the accuracy of collision detection is low.
Disclosure of Invention
The invention provides a collision test and a detection method, equipment and a storage medium thereof, which are used for solving the problem of how to improve the accuracy of detecting whether collision occurs between virtual roles in a tile map.
According to an aspect of the present invention, there is provided a collision test method including:
editing a virtual map in a tile map editor, wherein the virtual map is divided into a plurality of grids, and non-player characters in a moving state are edited in the virtual map;
loading a user-controlled player character in the virtual map when testing the virtual map;
if a movement operation triggered by the player character is received, planning a path for avoiding the current non-player character for the player character in a plurality of grids;
extracting features visible in the virtual map as visual features for the player character and the non-player character in the process of controlling the player character to move along the path;
detecting whether a visualized collision occurs between the non-player character and the player character according to the visualized characteristics;
and writing the information of the visual collision between the player character and the non-player character into a test report.
According to another aspect of the present invention, there is provided a collision detection method including:
loading a virtual map and loading player characters controlled by a user in the virtual map when entering a specified virtual map, wherein the virtual map is divided into a plurality of grids, and non-player characters in a moving state are edited in the virtual map;
If a movement operation triggered by the player character is received, planning a path for avoiding the current non-player character for the player character in a plurality of grids;
extracting features visible in the virtual map as visual features for the player character and the non-player character in the process of controlling the player character to move along the path;
and detecting whether a visualized collision occurs between the non-player character and the player character according to the visualized characteristics.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the collision test method or the collision detection method according to any one of the embodiments of the present invention.
According to another aspect of the present invention, there is provided a computer-readable storage medium storing a computer program for causing a processor to execute the collision test method or the collision detection method according to any one of the embodiments of the present invention.
In the embodiment, a virtual map is edited in a tile map editor, the virtual map is divided into a plurality of grids, and a non-player character in a moving state is edited in the virtual map; loading user-controlled player characters in the virtual map during the virtual map test; if a movement operation triggered by the player character is received, planning a path for avoiding the current non-player character for the player character in a plurality of grids; extracting visual features in the virtual map from the player character and the non-player character as visual features in the process of controlling the player character to move along the path; detecting whether a visual collision occurs between the non-player character and the player character according to the visual characteristics; and writing the information of the visual collision between the player character and the non-player character into a test report. According to the method and the device for detecting the collision of the player character and the non-player character, the frequency of collision detection can be reduced, the resources consumed by collision detection can be reduced, whether the visualized collision between the non-player character and the player character occurs or not can be detected depending on the visualized features of the player character and the non-player character, the visual characteristics of the player character and the non-player character are maintained in the collision detection, the occurrence of the situation that the player character and the non-player character are judged to not collide but visually occurs is reduced, and therefore the accuracy of the collision detection is improved.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a collision test method according to a first embodiment of the present invention;
FIG. 2 is an exemplary diagram of an edited virtual map provided in accordance with a first embodiment of the invention;
FIG. 3 is an exemplary diagram of a path provided in accordance with a first embodiment of the present invention;
FIG. 4 is an exemplary diagram of a test prompt provided in accordance with one embodiment of the present invention;
FIG. 5 is a flow chart of a collision test method according to a second embodiment of the invention;
fig. 6 is a flowchart of a collision detection method according to a third embodiment of the present invention;
Fig. 7 is a schematic structural view of a collision test apparatus according to a fourth embodiment of the present invention;
fig. 8 is a schematic structural view of a collision detecting device according to a fifth embodiment of the present invention;
fig. 9 is a schematic structural diagram of an electronic device according to a sixth embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
Fig. 1 is a flowchart of a collision testing method according to a first embodiment of the present invention, where the method may be applied to editing a tile map and testing whether a collision occurs between virtual characters in the tile map, and the method may be performed by a collision testing device, where the collision testing device may be implemented in a form of hardware and/or software, and the collision testing device may be configured in an electronic device. As shown in fig. 1, the method includes:
and step 101, editing the virtual map in a tile map editor.
In practical applications, in application programs such as a functional game, a social application, a shopping application and the like, a technician can develop an independent virtual map according to the requirements of a service scene, for example, in the functional game, the technician can develop multiple virtual maps for users to learn knowledge in a game playing form, in the social application, the technician can develop multiple virtual maps such as a farm and the like for users to social with other users in the game playing form, in the shopping application, the technician can develop virtual maps in a farm, a virtual street and the like for users to participate in sales promotion such as point, group purchase and the like in the game playing form, and the like.
For example, as shown in fig. 2, different application programs have different development modes, in the process of developing the application programs, a suitable tile map editor may be selected to edit the virtual map according to the development modes of the application programs, that is, the virtual map belongs to the tile map, the format of the virtual map is TMX, the virtual map may be divided into a plurality of grids, and the shapes of the grids may be canonical rectangles (especially squares), hexagons, and the like.
For example, a certain type of functional game is developed using the engine Cocos Creator, and the virtual map edited by the map editor relies on Cocos Creator support, so the tile map editor TiledMap can be selected.
Typically, the virtual map contains map layers, object layers, tile tiles, objects, etc., each of which can be set with custom attribute values (Custom Properties), e.g., set with a "collision detect" attribute to the grid, set with an "enemy type" attribute to an object of the object layer, etc., which custom attributes can be set in the tile map editor, and these attributes and corresponding attribute values can be obtained in the code.
Among other things, the attribute of "collision detection" may be used for road finding, movement, which may include immobility (i.e., an obstacle), portability, etc.
In addition, the technician may develop a virtual character according to the requirements of the business scenario and define as a non-player character (NPC), i.e., a game character that is not manipulated by the user, e.g., a toy, a robot, etc., the non-player character is configured with a movement rule, e.g., a direction of movement, a distance of a single movement, a time of pause, etc., and the non-player character moves in the virtual map continuously or at a specific time applying the movement rule, i.e., edits the non-player character in a moving state in the virtual map.
Step 102, loading the player character controlled by the user in the virtual map during the test of the virtual map.
After the technician has completed editing the virtual map, various tests may be performed on the virtual map, one of which is collision detection, at which time a user-controllable virtual character may be loaded in the virtual map and defined as a player character, which may include cartoon characters, small animals, robots, and so forth.
Step 103, if a movement operation triggered by the player character is received, a path for avoiding the current non-player character is planned for the player character in a plurality of grids.
In practical applications, the virtual map may provide various ways to trigger the movement operation for the player character, which may be triggered manually by the user, or may be triggered automatically by the application program, for example, when the user clicks a certain position in the virtual click map, the user may take the position as an endpoint and trigger the movement operation, or the application program may provide an automatic path-finding function, and the user clicks a certain control (such as a control representing a task or a person) by the application program (including the current virtual map or other virtual map), invokes the automatic path-finding function by means of a task, a dialogue scene, or the like, triggers the movement operation, or triggers the movement operation again after the player character and the non-player character collide visually, or the like.
In the test scenario, the technician may manually trigger a movement operation for the player character, may write a test case or script, trigger a movement operation for the player character, and so on, which is not limited in this embodiment.
As shown in fig. 3, if a movement operation triggered for a player character is received, a path for evading the current non-player character may be planned for the player character in a plurality of grids of the virtual map according to an instruction of the movement operation, that is, the path is composed of grids, may be displayed in a manner of an arrow, a dotted line, or the like, may be hidden, and the present embodiment does not impose a limitation on this.
Further, since the non-player character (e.g., cow in fig. 3) is in a moving state, i.e., the non-player character occupies a movable position, and the grid is changed in real time, the grid occupied by the non-player character is repositioned each time a moving operation triggered for the player character (e.g., cartoon character in fig. 3) is received, thereby evading the non-player character.
Of course, other fixed map elements are defined in the virtual map as obstacles, such as mountains, trees, rivers and the like, and the path planned for the player character also hard avoids other obstacles besides the current non-player character.
In one embodiment of the present invention, step 103 may include the steps of:
in step 1031, when the player character is simplified to a particle, a grid currently occupied by the player character is located in the virtual map as a first target grid.
Typically, to facilitate path planning in a tile map, player characters may be reduced to particles in real-time, one occupying each grid.
For example, player image data with content of a player character may be queried to set a center point of the player image data to a particle.
Then, in the case where the player character is simplified to a particle, the grid currently occupied by the player character is located in the virtual map and marked as the first target grid, that is, the first target grid is the starting point.
Step 1032, locating the grid currently occupied by the destination indicated by the movement operation in the virtual map as the second target grid.
Since the triggering modes of the mobile operation are different, correspondingly, the destination indicated by the mobile operation is also different, for example, the position clicked by the user is the destination, and a fixed position (such as the position of a certain virtual object and the position of a certain virtual character) is set in the task and dialogue scene as the destination.
In the virtual map, the grid currently occupied by the end point indicated by the movement operation may be located as the second target grid, i.e., the second target grid is the end point.
In step 1033, when the non-player character is simplified to a particle, the mesh currently occupied by the non-player character is located in the virtual map as the third target mesh.
Step 1034, marking the third target table with the obstacle.
Typically, to facilitate path planning in a tile map, non-player characters may be reduced to particles in real-time, one occupying each grid.
For example, non-player image data with non-player character content may be queried, and invalid areas are removed from the non-player image data to obtain valid image data, wherein the invalid areas are areas where virtual elements of the non-player character that are irrelevant to collision are located, and a center point of the valid image data is set as a particle.
Then, in the case where the non-player character is reduced to a particle, the grid currently occupied by the non-player character is located in the virtual map as the third target grid.
The non-player character is currently positioned in the third object grid, and the attribute of the third object grid in the virtual map is shown as movable, but the attribute of the third object grid in the virtual map can be changed from movable to immovable and marked as an obstacle because the non-player character currently occupies the third object grid.
Step 1035, searching paths from the first target lattice to the second target lattice for avoiding obstacles in each grid in the virtual map.
In case of known origin, destination, obstacle, movable grid, a can be used * Greedy algorithm, dijkstra algorithm (Dijkstra algorithm), B * And a path searching algorithm for searching one or more paths which can start from the first target lattice and avoid obstacles to reach the second target lattice in each grid in the virtual map.
In A way * The algorithm is exemplified by meshing in the virtual map as a search area, and simplifying the search area into a 2-dimensional array. Each entry of the array represents a mesh whose states are movable (walkalbe) and immovable (unwalkable), and the mesh whose destination is reached from the start point is searched out in order with the shortest distance as the target of the search, and is recorded as a path.
A * The algorithm has two tables, one is an open list (openlist), records a list of all meshes considered to find the shortest path, and one is a closed list (close) records a list of meshes that are no longer considered.
Traversing the grid from the starting point A, adding the grid to the openlist, wherein the grid in the openlist is a list of grids to be checked, which may or may not be traversed by the path.
The following procedure was repeated:
traversing openlist, finding a grid with the minimum path increment F, wherein f=g+h, where G is the amount of movement from the starting point a to the current grid, and H is an estimated amount of movement from the current grid to the end point.
The current grid node is moved to close.
For other grids adjacent to the current grid, if it is an immovable (unwarped) grid (e.g., water, mountain, tree, non-player character, etc.) or it is in close, it is ignored.
If it is not in the openlist, it is added to the openlist and the current grid is set as its parent, recording the F, G and H values of the grid.
If it is already in openlist, it is checked whether this path (i.e. it arrives there via the current pane) is better, with the G value as reference. A smaller G value indicates that this is a better path. If so, its parent node is set to the current grid and its G and F values are recalculated.
When an endpoint joins the openlist, the path has been found, or the search for the endpoint fails, and the openlist is empty, with no path.
From the end point, each mesh moves along the parent node to the start point, denoted as a path.
Step 104, extracting the visual features in the virtual map from the player character and the non-player character as the visual features in the process of controlling the player character to move along the path.
In the virtual map, the non-player character is in a moving state, and according to a given moving rule, each grid in the virtual map, a plurality of random algorithms are used for the moving rule, for example, a moving direction is selected randomly, a single moving distance is selected randomly, and after a path is planned for the player character, the non-player character usually leaves the grid where the path is planned, moves to other grids and possibly passes through the path, so that when the player character moves according to the path, a certain probability and collision of the non-player character can exist.
In this regard, during the process of controlling the player character to move along the path, some features visible in the virtual map and relevant to the collision may be continuously extracted from the player character and the non-player character and recorded as the visual features.
In one embodiment of the invention, the visual features include player area, non-player area, distance and forward range; then in this embodiment, step 104 may include the steps of:
step 1041, identifying a plurality of grids currently covered by the player character in the virtual map as a player area, and identifying a plurality of grids currently covered by the non-player character as a non-player area.
Typically, the player character is larger in size than the single grid and the non-player character is larger in size than the single grid.
To simplify the operation of the player character with the non-player character, and to facilitate collision detection, multiple grids currently covered by the player character can be identified in real time in the virtual map as player areas, which can generally represent the player character as a visual feature.
Further, multiple grids currently covered by the non-player character may be identified in real-time in the virtual map as non-player areas, which may generally represent the non-player character as a visual feature.
In practical applications, player image data with a player character content and non-player image data with a non-player character content may be queried locally in the application program, wherein the player image data includes transparent pixels except for the player character and is invisible to the user, and the player image data includes transparent pixels except for the non-player character and is invisible to the user.
Because the player character is controlled by the user and operates in a game mode in the application program, a plurality of states possibly exist, virtual elements such as props are added on the basis of the player character, the image of the virtual elements is changed to a certain extent, the change is limited, the virtual elements have more transparent pixels, and the influence on collision detection is less, so that in order to facilitate the operation of collision detection, multi-frame original image data with non-player characters can be queried.
If a certain frame of original image data does not add other virtual elements other than the player character, that is, the frame of original image data records the original state of the player character, the frame of original image data may be extracted as player image data.
And a part of the non-player image data may have an invalid region, wherein the invalid region is a region where a virtual element (such as a tail and the like) which is irrelevant to collision in the non-player character is located, the invalid region is provided with more transparent pixels, and interference exists on collision detection, namely, a visually obvious collision event does not occur to the virtual element (such as the tail and the like) in the player character and the non-player character, so that the invalid region can be removed from the non-player image data, the valid image data can be obtained, and the interference on collision detection is eliminated.
And (3) rounding down the ratio between the size of the player image data and the size of the grids to obtain a first quantity, filling grids meeting the first quantity around a first center point of the player image data in the virtual map to obtain a player area, namely filling grids meeting the first quantity around the first center point of the player image data to obtain the player area, wherein the player area is a regular rectangle, and the aspect ratio of the player area is similar to that of the player image data.
And (3) rounding down the ratio between the size of the effective image data and the size of the grids to obtain a second quantity, filling grids meeting the second quantity around a second center point of the effective image data in the virtual map to obtain a non-player area, namely filling grids meeting the first quantity around the second center point of the effective image data to obtain a non-player area, wherein the non-player area is a regular rectangle, and the aspect ratio of the non-player area is similar to that of the effective image data.
In general, the ratio between the size of the player image data and the size of the grid, the ratio between the size of the effective image data and the size of the grid are all decimal, not integer, the comparison value is rounded down, the decimal part is ignored, the player area does not completely cover the player character, the player character may have partial pixel points protruding out of the player area, the non-player area does not completely cover the non-player character, the non-player character may have partial pixel points protruding out of the non-player area, the pixels of the protruding player area and the non-player area are mostly pixels of the player character and the non-player character edge, the pixels do not visually generate obvious collision events, and the interference on collision detection can be reduced.
To facilitate testing, test code may be added to the application or test case, and during the test, the test code is invoked to add a first layer of the same size and location as the player area (e.g., color patch under cartoon character in fig. 4), and a second layer of the same size and location as the non-player area (e.g., color patch under pig, color patch over cow in fig. 4).
The first layer may be located above the player character or below the player character, and the second layer may be located above the non-player character or below the non-player character.
The first layer is filled with a first color, the second layer is filled with a second color, and the first color and the second color can be the same or different.
Further, the test code changes the first color to a third color when a visual collision occurs between the player character and the non-player character, the first color being different from the third color.
Thus, whether the size and the position of each dynamic barrier (namely, the non-player character) are correct or not can be clearly seen, whether the collision detection is correct or not is convenient for debugging and finding the Bug of the collision detection
If the test code is positioned in the application program and the test is completed, the comment is added to the test code so as to ignore the test code and ensure the normal operation of the application program.
Of course, the test code may be deleted directly in addition to adding comments and ignoring the test code, which is not limited in this embodiment.
Step 1042, calculating the distance between the player area and the non-player area currently spaced in the virtual map.
For the player region and the non-player region, the distance between the player region and the non-player region, which is currently spaced in the virtual map as a whole, may be calculated as a visual feature.
The distance may be an actual distance or an edit distance, and this embodiment is not limited thereto.
Illustratively, a first center point of the player region, a second center point of the non-player region are located;
the distance between the first center point and the second center point is calculated using a Euclidean distance or the like function as the distance between the player area and the non-player area currently spaced in the virtual map.
Step 1043, identifying a forward range formed by the player character when it is currently moving along the path in the virtual map.
Visually, a collision of a player character with a non-player character should occur in the forward direction of the player character, and it is often unreasonable to occur in other directions than the forward direction, and therefore, a forward range formed when the player character is currently moving along a path in a virtual map can be identified as a visual feature, where the forward range represents a set of forward directions of the player character visually.
In a specific implementation, a grid where the player character is currently located in the virtual map is identified as a first candidate grid, and a grid located next to the first candidate grid when the player character is currently moving along the path in the virtual map is identified as a second candidate grid.
The direction in which the first candidate points to the second candidate is set to be the direction in which the player character is currently heading in the virtual map,
and expanding the player character to two sides by a designated angle (such as 30 degrees) on the basis of the moving direction, so as to obtain the advancing range formed when the player character moves along the path in the virtual map.
Of course, the above-mentioned visual features are merely examples, and other visual features may be set according to actual situations when implementing the present embodiment, and the present embodiment is not limited thereto. In addition, in addition to the above-mentioned visual features, those skilled in the art may also adopt other visual features according to actual needs, which are not limited in this embodiment.
Step 105, detecting whether a visualized collision occurs between the non-player character and the player character according to the visualized characteristic.
In this embodiment, whether a visual collision between the non-player character and the player character occurs, that is, whether a visual collision occurs, may be detected depending on the visual characteristics.
In particular implementations, where the visual characteristics include a player region characterizing a player character, a non-player region characterizing a non-player character, a distance of separation between the player region and the non-player region, and a forward range of the player character, whether a visual collision between the non-player character and the player character occurs may be detected as a function of the player region characterizing the player character, the non-player region characterizing the non-player character, the distance of separation between the player region and the non-player region, and the forward range of the player character.
In one aspect, an interface provided in the application (e.g., an interface of the game engine) may be invoked to detect whether the player region overlaps the non-player region.
Alternatively, a threshold may be set for the non-player character and the distance compared to the threshold.
The threshold may be a default experience value set for the non-player character and the player character, or may be a value updated for the non-player character and the player character in real time, which is not limited in this embodiment.
Illustratively, a first minimum circumscribing circle is added to the player region, a second minimum circumscribing circle is added to the non-player region, and the radius of the first minimum circumscribing rectangle is summed with the radius of the second minimum circumscribing rectangle to serve as a threshold value representing the maximum distance at which a visualized collision between the non-player character and the player character occurs.
In yet another aspect, it is detected whether the non-player region is within a forward range.
If there is overlap of the player region with the non-player region, the distance is less than or equal to the threshold, and the non-player region is within the forward range, a visual collision between the player character and the non-player character is determined.
Because transparent pixel points exist outside the player characters and the non-player characters, the pixel points can interfere with collision detection visually, and the embodiment can further improve the accuracy of collision detection by carrying out the collision detection through the visual features in multiple dimensions.
And 106, writing the information of the visual collision between the player character and the non-player character into a test report.
Upon a visual collision between a player character and a non-player character, relevant information may be read, such as the player character's ID, the non-player character's ID, the coordinates at which the visual collision occurred, the time at which the visual collision occurred, the path planned for the player character, etc., written into a test report, waiting for a technician to analyze whether the collision detection meets expectations.
When the application completes all the tests, the application is published through a designated channel (e.g., application mall, update) where the user can download and install the application.
In the embodiment, a virtual map is edited in a tile map editor, the virtual map is divided into a plurality of grids, and a non-player character in a moving state is edited in the virtual map; loading user-controlled player characters in the virtual map during the virtual map test; if a movement operation triggered by the player character is received, planning a path for avoiding the current non-player character for the player character in a plurality of grids; extracting visual features in the virtual map from the player character and the non-player character as visual features in the process of controlling the player character to move along the path; detecting whether a visual collision occurs between the non-player character and the player character according to the visual characteristics; and writing the information of the visual collision between the player character and the non-player character into a test report. According to the method and the device for detecting the collision of the player character and the non-player character, the frequency of collision detection can be reduced, the resources consumed by collision detection can be reduced, whether the visualized collision between the non-player character and the player character occurs or not can be detected depending on the visualized features of the player character and the non-player character, the visual characteristics of the player character and the non-player character are maintained in the collision detection, the occurrence of the situation that the player character and the non-player character are judged to not collide but visually occurs is reduced, and therefore the accuracy of the collision detection is improved.
Example two
Fig. 5 is a flowchart of a collision test method according to a second embodiment of the present invention, where operations of flicking a player character are added on the basis of the embodiment. As shown in fig. 5, the method includes:
step 501, editing a virtual map in a tile map editor.
The virtual map is divided into a plurality of grids, and non-player characters in a moving state are edited in the virtual map.
Step 502, loading a player character controlled by a user in the virtual map during the virtual map test.
Step 503, if a movement operation triggered by the player character is received, a path for avoiding the current non-player character is planned for the player character in a plurality of grids.
Step 504, extracting the visual features in the virtual map from the player character and the non-player character as the visual features in the process of controlling the player character to move along the path.
Step 505, detecting whether a visualized collision occurs between the non-player character and the player character according to the visualized characteristic.
Step 506, if a visual collision occurs between the player character and the non-player character, the player character is moved to the target position.
If visual collision between the player character and the non-player character is confirmed, the player character can be moved to a target position in a random movement mode, a reverse movement mode and the like, wherein the target position is other positions except for the position where the visual collision of the player character occurs, the effect of bouncing the player character is achieved, and reasonable change after the collision of the player character and the non-player character is met.
Illustratively, a direction opposite to the forward direction of the player character in the case of a visualized collision is identified as a target direction, a value is randomly extracted in a preset moving range as a length, the player character is moved to a target position outside the length along the target direction, that is, the direction in which the position of the player character in the visualized collision points to the target position is the target direction, and the distance of the length is spaced between the position of the player character in the visualized collision and the target position.
Step 507, a new movement operation is triggered for the player character under the condition of maintaining the endpoint unchanged, and the step 503 is executed again.
The position where the player character is visually collided is moved to the target position, so that the original path is deviated, and the path is invalid, at this time, the player character can stay at the target position for a preset time period, after the time period is exceeded, the endpoint is maintained unchanged, under the condition, a new movement operation is triggered for the player character, the execution returns to step 503, and the path for avoiding the current non-player character is planned for the player character in a plurality of grids again.
When the path is re-planned, the grid occupied by the non-player character is refreshed, and the player character moves to the target position, so that the probability of repeated collision of the player character and the non-player character can be reduced to a certain extent.
Step 508, information of a visual collision between the player character and the non-player character is written into the test report.
Example III
Fig. 6 is a flowchart of a collision detection method according to a third embodiment of the present invention, where the method may be applied to detecting whether a collision occurs between virtual characters in a tile map, and the method may be performed by a collision detection device, where the collision detection device may be implemented in hardware and/or software, and the collision detection device may be configured in an electronic device such as a personal computer, a notebook computer, a mobile terminal (e.g., a mobile phone, a tablet computer, etc.). As shown in fig. 6, the method includes:
step 601, loading a virtual map and loading a player character controlled by a user in the virtual map when entering a designated virtual map.
An operating system Windows, android (android), iOS, harmon, etc. may be installed in the electronic device, and various applications such as a functional game, a social application, a shopping application, etc. may be installed in these operating systems.
These applications have one or more virtual maps that a user operates in, and upon entering a virtual map, the virtual map may be loaded and the user-controlled player character may be loaded in the virtual map.
The virtual map is divided into a plurality of grids, and non-player characters in a moving state are edited in the virtual map.
Step 602, if a movement operation triggered by the player character is received, a path for avoiding the current non-player character is planned for the player character in a plurality of grids.
In one embodiment of the present invention, step 602 may include the steps of:
under the condition that the player character is simplified into particles, positioning a grid occupied by the player character in the virtual map as a first target grid;
positioning a grid currently occupied by an end point indicated by the moving operation in the virtual map as a second target grid;
under the condition that the non-player character is simplified into particles, positioning a grid occupied by the non-player character in the virtual map as a third target grid;
marking the third target table with an obstacle; in each grid in the virtual map, a path from the first target grid to the second target grid is searched for, wherein the path is used for avoiding obstacles.
Step 603, extracting the visual features in the virtual map from the player character and the non-player character as the visual features in the process of controlling the player character to move along the path.
In one embodiment of the invention, the visual features include player area, non-player area, distance and forward range; then in this embodiment, step 603 may include the steps of:
identifying a plurality of grids currently covered by the player character in the virtual map as player areas, and identifying a plurality of grids currently covered by the non-player character as non-player areas;
calculating the distance between the player area and the non-player area currently spaced in the virtual map;
the range of progress that the player character currently forms as it moves along the path in the virtual map is identified.
Further, identifying a plurality of grids currently covered by the player character in the virtual map as a player area, and identifying a plurality of grids currently covered by the non-player character as a non-player area includes:
inquiring player image data with player characters as content and non-player image data with non-player characters as content;
removing an invalid area from the non-player image data to obtain effective image data, wherein the invalid area is an area where a virtual element which is irrelevant to collision in a non-player character is located;
rounding down the ratio between the size of the player image data and the size of the grid to obtain a first number;
Filling a first number of grids around a first center point of the player image data in the virtual map to obtain a player area;
rounding down the ratio between the size of the effective image data and the size of the grid to obtain a second number;
a second number of grids satisfying the second number are filled around a second center point of the effective image data in the virtual map, and a non-player area is obtained.
Further, querying player image data with content of player character and non-player image data with content of non-player character includes:
inquiring multi-frame original image data with non-player characters as contents;
and if no virtual element except the player character is added to the original image data of a certain frame, extracting the original image data as player image data.
Further, calculating a distance between the player region and the non-player region currently spaced in the virtual map includes:
locating a first center point of the player area, a second center point of the non-player area;
the distance between the first center point and the second center point is calculated as the distance between the player region and the non-player region that is currently spaced in the virtual map.
Further, identifying a forward range that the player character currently forms as it moves along the path in the virtual map includes:
Identifying a grid where a player character is currently located in the virtual map as a first candidate grid;
identifying a grid positioned next to the first candidate grid as a second candidate grid when the player character moves along the path in the virtual map;
setting the direction of the first candidate grid pointing to the second candidate grid as the current advancing direction of the player character in the virtual map;
and expanding the designated angles to two sides on the basis of the advancing direction to obtain the advancing range formed when the player character moves along the path in the virtual map.
Step 604, detecting whether a visualized collision occurs between the non-player character and the player character according to the visualized characteristic.
In one embodiment of the present invention, step 604 may include the steps of:
detecting whether a player area overlaps a non-player area;
setting a threshold for the non-player character and the player character;
comparing the distance to a threshold;
detecting whether the non-player region is within a forward range;
if there is overlap of the player region with the non-player region, the distance is less than or equal to the threshold, and the non-player region is within the forward range, a visual collision between the player character and the non-player character is determined.
Further, setting a threshold for the non-player character and the player character includes:
adding a first minimum circumscribed circle to the player region and adding a second minimum circumscribed circle to the non-player region;
the radius of the first minimum bounding rectangle is summed with the radius of the second minimum bounding rectangle as a threshold.
In one embodiment of the invention, the method may further comprise the steps of:
if the test code is run to the test code and has comments, the test code is ignored, wherein the test code is used for adding a first layer identical to the player region and a second layer identical to the non-player region, the first layer is filled with a first color, the second layer is filled with a second color, and the first color is changed to a third color when a visualized collision occurs between the player character and the non-player character.
In one embodiment of the invention, the method may further comprise the steps of:
if visual collision occurs between the player character and the non-player character, the player character is moved to a target position, wherein the target position is other positions except the position where the visual collision occurs to the player character;
And under the condition of maintaining the end point unchanged, triggering a new movement operation aiming at the player character, and returning to execute the movement operation triggered by the player character, and planning a path for avoiding the current non-player character for the player character in the virtual map.
Further, moving the player character to the target location includes:
identifying a direction opposite to a forward direction at the time of a visualized collision of the player character as a target direction;
randomly extracting a numerical value in a preset moving range to be used as a length;
the player character is moved in a target direction to a target position outside the length.
In this embodiment, since the collision detection is basically similar to the application of the first and second embodiments, the description is relatively simple, and the relevant points are only needed by referring to the partial description of the first and second embodiments, and the detailed description of this embodiment is omitted here.
In this embodiment, when a specified virtual map is entered, loading the virtual map and loading a player character controlled by a user in the virtual map, the virtual map being divided into a plurality of grids, and a non-player character in a moving state being edited in the virtual map; if a movement operation triggered by the player character is received, planning a path for avoiding the current non-player character for the player character in a plurality of grids; extracting visual features in the virtual map from the player character and the non-player character as visual features in the process of controlling the player character to move along the path; whether a visual collision occurs between the non-player character and the player character is detected according to the visual characteristics. According to the method and the device for detecting the collision of the player character and the non-player character, the frequency of collision detection can be reduced, the resources consumed by collision detection can be reduced, whether the visualized collision between the non-player character and the player character occurs or not can be detected depending on the visualized features of the player character and the non-player character, the visual characteristics of the player character and the non-player character are maintained in the collision detection, the occurrence of the situation that the player character and the non-player character are judged to not collide but visually occurs is reduced, and therefore the accuracy of the collision detection is improved.
Example IV
Fig. 7 is a schematic structural diagram of a collision testing apparatus according to a fourth embodiment of the present invention. As shown in fig. 7, the apparatus includes:
a virtual map editing module 701, configured to edit a virtual map in a tile map editor, where the virtual map is divided into a plurality of grids, and a non-player character in a moving state is edited in the virtual map;
a player character loading module 702, configured to load a player character controlled by a user in the virtual map when testing the virtual map;
a path-finding module 703, configured to plan, for the player character, a path for avoiding the current non-player character in a plurality of grids if a movement operation triggered for the player character is received;
a visual feature extraction module 704, configured to extract, as visual features, features that are visible in the virtual map for the player character and the non-player character in a process of controlling the player character to move along the path;
a visual collision detection module 705, configured to detect whether a visual collision occurs between the non-player character and the player character according to the visual feature;
a test report generation module 706 configured to write information about a visualized collision between the player character and the non-player character into a test report.
In one embodiment of the present invention, the routing module 703 includes:
the first target grid positioning module is used for positioning the grid occupied by the player character currently in the virtual map as a first target grid under the condition that the player character is simplified into particles;
the second target grid positioning module is used for positioning the grid currently occupied by the end point indicated by the moving operation in the virtual map as a second target grid;
a third target grid positioning module, configured to, when the non-player character is simplified to a particle, position, in the virtual map, the grid currently occupied by the non-player character as a third target grid;
an obstacle marking module for marking the third target table with an obstacle;
and the path planning module is used for searching a path which starts from the first target grid and avoids the obstacle to reach the second target grid in each grid in the virtual map.
In one embodiment of the invention, the visual features include player area, non-player area, distance and forward range;
the visual feature extraction module 704 includes:
The area identifying module is used for identifying a plurality of grids currently covered by the player character in the virtual map, and identifying the grids currently covered by the non-player character as a non-player area;
an area distance calculation module for calculating a distance between the player area and the non-player area currently spaced in the virtual map;
and the advancing range identification module is used for identifying the advancing range formed when the player character moves along the path in the virtual map.
In one embodiment of the present invention, the area identifying module includes:
the image data query module is used for querying player image data with the content of the player character and non-player image data with the content of the non-player character;
an invalid region removing module, configured to remove an invalid region from the non-player image data, to obtain valid image data, where a virtual element that is unrelated to collision in the non-player character is located;
a first number calculation module configured to round down a ratio between a size of the player image data and a size of the grid to obtain a first number;
A player region generation module for filling the grid satisfying the first number around a first center point of the player image data in the virtual map to obtain a player region;
a second number calculation module, configured to round down a ratio between the size of the effective image data and the size of the grid to obtain a second number;
and the non-player area generating module is used for filling the grids meeting the second quantity around a second center point of the effective image data in the virtual map to obtain non-player areas.
In one embodiment of the present invention, the image data query module includes:
the original image data query module is used for querying multi-frame original image data with the content of the non-player character;
and the player image data extraction module is used for extracting the original image data into player image data if other virtual elements except the player characters are not added in the original image data of a certain frame.
In one embodiment of the present invention, the area distance calculation module includes:
a center point positioning module, configured to position a first center point of the player area and a second center point of the non-player area;
And the center point distance calculation module is used for calculating the distance between the first center point and the second center point as the distance between the player area and the non-player area, which is currently spaced in the virtual map.
In one embodiment of the present invention, the forward range identification module includes:
the first candidate grid identification module is used for identifying the grid where the player character is currently located in the virtual map and used as a first candidate grid;
a second candidate grid recognition module, configured to recognize, as a second candidate grid, the grid located next to the first candidate grid when the player character is currently moving along the path in the virtual map;
a forward direction setting module, configured to set a direction in which the first candidate grid points to the second candidate grid as a forward direction of the player character currently in the virtual map;
and the advancing direction expanding module is used for expanding the designated angles to two sides on the basis of the advancing direction to obtain the advancing range formed when the player character moves along the path in the virtual map.
In one embodiment of the present invention, the visual collision detection module 705 includes:
A region overlap detection module configured to detect whether the player region overlaps the non-player region;
a threshold setting module configured to set a threshold for the non-player character and the player character;
a distance comparison module for comparing the distance to the threshold;
a forward range detection module configured to detect whether the non-player region is within the forward range;
and the collision determining module is used for determining that the visualized collision occurs between the player character and the non-player character if the player region and the non-player region are overlapped, the distance is smaller than or equal to the threshold value and the non-player region is in the forward range.
In one embodiment of the present invention, the threshold setting module includes:
the minimum circumscribing circle adding module is used for adding a first minimum circumscribing circle to the player area and adding a second minimum circumscribing circle to the non-player area;
and the radius summation module is used for summing the radius of the first minimum circumscribed rectangle and the radius of the second minimum circumscribed rectangle to serve as a threshold value.
In one embodiment of the present invention, further comprising:
a test code calling module for calling a test code, adding a first layer identical to the player region and a second layer identical to the non-player region, wherein the first layer is filled with a first color, the second layer is filled with a second color, and the first color is changed into a third color when a visualized collision occurs between the player character and the non-player character;
And the annotation adding module is used for adding the annotation to the test code if the test is completed so as to ignore the test code.
In one embodiment of the present invention, further comprising:
a player character moving module, configured to move the player character to a target position if a visual collision occurs between the player character and the non-player character, where the target position is other than the position where the visual collision occurs;
and the mobile operation triggering module is used for triggering a new mobile operation aiming at the player character under the condition of maintaining the end point unchanged, and returning to execute the path finding module 703.
In one embodiment of the present invention, the player character movement module includes:
a target direction recognition module for recognizing a direction opposite to a forward direction at which the player character visually collides as a target direction;
the length extraction module is used for randomly extracting a numerical value in a preset moving range to be used as a length;
and the target position moving module is used for moving the player character to a target position outside the length along the target direction.
The collision test device provided by the embodiment of the invention can execute the collision test method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of executing the collision test method.
Example five
Fig. 8 is a schematic structural diagram of a collision detecting device according to a fifth embodiment of the present invention. As shown in fig. 8, the apparatus includes:
a map element loading module 801, configured to load a virtual map and load a player character controlled by a user in the virtual map when entering a specified virtual map, where the virtual map is divided into a plurality of grids, and a non-player character in a moving state is edited in the virtual map;
a path-finding module 802, configured to plan, for the player character, a path for avoiding the current non-player character in a plurality of grids if a movement operation triggered for the player character is received;
a visual feature extraction module 803, configured to extract, as visual features, features that are visible in the virtual map for the player character and the non-player character in a process of controlling the player character to move along the path;
a visual collision detection module 804, configured to detect whether a visual collision occurs between the non-player character and the player character according to the visual feature.
In one embodiment of the present invention, the routing module 802 includes:
The first target grid positioning module is used for positioning the grid occupied by the player character currently in the virtual map as a first target grid under the condition that the player character is simplified into particles;
the second target grid positioning module is used for positioning the grid currently occupied by the end point indicated by the moving operation in the virtual map as a second target grid;
a third target grid positioning module, configured to, when the non-player character is simplified to a particle, position, in the virtual map, the grid currently occupied by the non-player character as a third target grid;
an obstacle marking module for marking the third target table with an obstacle;
and the path planning module is used for searching a path which starts from the first target grid and avoids the obstacle to reach the second target grid in each grid in the virtual map.
In one embodiment of the invention, the visual features include player area, non-player area, distance and forward range;
the visual feature extraction module 803 includes:
the area identifying module is used for identifying a plurality of grids currently covered by the player character in the virtual map, and identifying the grids currently covered by the non-player character as a non-player area;
An area distance calculation module for calculating a distance between the player area and the non-player area currently spaced in the virtual map;
and the advancing range identification module is used for identifying the advancing range formed when the player character moves along the path in the virtual map.
In one embodiment of the present invention, the area identifying module includes:
the image data query module is used for querying player image data with the content of the player character and non-player image data with the content of the non-player character;
an invalid region removing module, configured to remove an invalid region from the non-player image data, to obtain valid image data, where a virtual element that is unrelated to collision in the non-player character is located;
a first number calculation module configured to round down a ratio between a size of the player image data and a size of the grid to obtain a first number;
a player region generation module for filling the grid satisfying the first number around a first center point of the player image data in the virtual map to obtain a player region;
a second number calculation module, configured to round down a ratio between the size of the effective image data and the size of the grid to obtain a second number;
And the non-player area generating module is used for filling the grids meeting the second quantity around a second center point of the effective image data in the virtual map to obtain non-player areas.
In one embodiment of the present invention, the image data query module includes:
the original image data query module is used for querying multi-frame original image data with the content of the non-player character;
and the player image data extraction module is used for extracting the original image data into player image data if other virtual elements except the player characters are not added in the original image data of a certain frame.
In one embodiment of the present invention, the area distance calculation module includes:
a center point positioning module, configured to position a first center point of the player area and a second center point of the non-player area;
and the center point distance calculation module is used for calculating the distance between the first center point and the second center point as the distance between the player area and the non-player area, which is currently spaced in the virtual map.
In one embodiment of the present invention, the forward range identification module includes:
The first candidate grid identification module is used for identifying the grid where the player character is currently located in the virtual map and used as a first candidate grid;
a second candidate grid recognition module, configured to recognize, as a second candidate grid, the grid located next to the first candidate grid when the player character is currently moving along the path in the virtual map;
a forward direction setting module, configured to set a direction in which the first candidate grid points to the second candidate grid as a forward direction of the player character currently in the virtual map;
and the advancing direction expanding module is used for expanding the designated angles to two sides on the basis of the advancing direction to obtain the advancing range formed when the player character moves along the path in the virtual map.
In one embodiment of the present invention, the visual collision detection module 804 includes:
a region overlap detection module configured to detect whether the player region overlaps the non-player region;
a threshold setting module configured to set a threshold for the non-player character and the player character;
a distance comparison module for comparing the distance to the threshold;
A forward range detection module configured to detect whether the non-player region is within the forward range;
and the collision determining module is used for determining that the visualized collision occurs between the player character and the non-player character if the player region and the non-player region are overlapped, the distance is smaller than or equal to the threshold value and the non-player region is in the forward range.
In one embodiment of the present invention, the threshold setting module includes:
the minimum circumscribing circle adding module is used for adding a first minimum circumscribing circle to the player area and adding a second minimum circumscribing circle to the non-player area;
and the radius summation module is used for summing the radius of the first minimum circumscribed rectangle and the radius of the second minimum circumscribed rectangle to serve as a threshold value.
In one embodiment of the present invention, further comprising:
a player character moving module, configured to move the player character to a target position if a visual collision occurs between the player character and the non-player character, where the target position is other than the position where the visual collision occurs;
and the mobile operation triggering module is used for triggering a new mobile operation aiming at the player character under the condition of maintaining the end point unchanged, and returning to execute the path searching module 802.
In one embodiment of the present invention, the player character movement module includes:
a target direction recognition module for recognizing a direction opposite to a forward direction at which the player character visually collides as a target direction;
the length extraction module is used for randomly extracting a numerical value in a preset moving range to be used as a length;
and the target position moving module is used for moving the player character to a target position outside the length along the target direction.
In one embodiment of the present invention, further comprising:
and the test code ignoring module is used for ignoring the test code if the test code is run to the test code and has comments, wherein the test code is used for adding a first layer identical to the player area and a second layer identical to the non-player area, the first layer is filled with a first color, the second layer is filled with a second color, and the first color is changed into a third color when a visualized collision occurs between the player character and the non-player character.
The collision detection device provided by the embodiment of the invention can execute the collision detection method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of executing the collision detection method.
Example six
Fig. 9 shows a schematic diagram of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 9, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the respective methods and processes described above, such as the collision test method or the collision detection method.
In some embodiments, the collision test method or the collision detection method may be implemented as a computer program, which is tangibly embodied on a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the collision test method or the collision detection method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the collision test method or the collision detection method in any other suitable way (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
Example seven
Embodiments of the present invention also provide a computer program product comprising a computer program which, when executed by a processor, implements a collision test method or a collision detection method as provided by any of the embodiments of the present invention.
Computer program product in the implementation, the computer program code for carrying out operations of the present invention may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (15)

1. A collision test method, comprising:
editing a virtual map in a tile map editor, wherein the virtual map is divided into a plurality of grids, and non-player characters in a moving state are edited in the virtual map;
loading a user-controlled player character in the virtual map when testing the virtual map;
if a movement operation triggered by the player character is received, planning a path for avoiding the current non-player character for the player character in a plurality of grids;
Extracting features visible in the virtual map as visual features for the player character and the non-player character in the process of controlling the player character to move along the path;
detecting whether a visualized collision occurs between the non-player character and the player character according to the visualized characteristics;
and writing the information of the visual collision between the player character and the non-player character into a test report.
2. The method of claim 1, wherein planning a path for the player character to avoid the current non-player character in the plurality of grids comprises:
positioning the grid currently occupied by the player character in the virtual map as a first target grid under the condition that the player character is simplified into particles;
positioning the grid currently occupied by the end point indicated by the moving operation in the virtual map as a second target grid;
positioning the grid currently occupied by the non-player character in the virtual map as a third target grid under the condition that the non-player character is simplified into particles;
marking the third target table with an obstacle;
And searching a path from the first target grid to the second target grid in each grid in the virtual map, wherein the path starts from the first target grid and avoids the obstacle.
3. The method of claim 1, wherein the visual features include player area, non-player area, distance, and forward range;
the extracting, as a visual feature, features that are visible in the virtual map for the player character and the non-player character includes:
identifying a plurality of grids currently covered by the player character in the virtual map as player areas, and identifying a plurality of grids currently covered by the non-player character as non-player areas;
calculating a distance between the player region and the non-player region currently spaced in the virtual map;
an extent of progress that the player character currently forms as it moves along the path in the virtual map is identified.
4. A method according to claim 3, wherein said identifying in said virtual map a plurality of said grids currently covered by said player character as player zones and a plurality of said grids currently covered by said non-player character as non-player zones comprises:
Inquiring player image data with the content of the player character and non-player image data with the content of the non-player character;
removing an invalid area from the non-player image data to obtain valid image data, wherein the invalid area is an area where a virtual element which is irrelevant to collision in the non-player character is located;
rounding down the ratio between the size of the player image data and the size of the grid to obtain a first number;
filling the grid satisfying the first number around a first center point of the player image data in the virtual map to obtain a player area;
rounding down the ratio between the size of the effective image data and the size of the grid to obtain a second number;
and filling the grids meeting the second quantity around a second center point of the effective image data in the virtual map to obtain a non-player region.
5. The method of claim 4, wherein the querying the player image data for the player character for the content and the non-player image data for the non-player character comprises:
inquiring multi-frame original image data with the content of the non-player character;
And if no virtual element except the player character is added to the original image data of a certain frame, extracting the original image data as player image data.
6. The method of claim 3, wherein the calculating a distance between the player region and the non-player region currently spaced in the virtual map comprises:
locating a first center point of the player region, a second center point of the non-player region;
a distance between the first center point and the second center point is calculated as a distance between the player region and the non-player region that is currently spaced in the virtual map.
7. A method according to claim 3, wherein said identifying a range of progress that the player character currently forms as moving along the path in the virtual map comprises:
identifying the grid where the player character is currently located in the virtual map as a first candidate grid;
identifying the grid next to the first candidate grid as a second candidate grid when the player character is currently moving along the path in the virtual map;
setting the direction of the first candidate grid pointing to the second candidate grid as the advancing direction of the player character in the virtual map currently;
And expanding a designated angle to two sides on the basis of the advancing direction to obtain an advancing range formed when the player character moves along the path in the virtual map.
8. A method according to claim 3, wherein said detecting whether a visualized collision between said player character and said non-player character occurs in accordance with said visualization characteristics comprises:
detecting whether the player region overlaps the non-player region;
setting a threshold for the non-player character and the player character;
comparing the distance to the threshold;
detecting whether the non-player region is within the forward range;
and if the player region and the non-player region overlap, the distance is less than or equal to the threshold value, and the non-player region is within the forward range, determining that a visual collision occurs between the player character and the non-player character.
9. The method of claim 8, wherein the thresholding the non-player character with the player character comprises:
adding a first minimum circumscribing circle to the player region and adding a second minimum circumscribing circle to the non-player region;
And summing the radius of the first minimum bounding rectangle and the radius of the second minimum bounding rectangle to serve as a threshold value.
10. A method according to claim 3, further comprising:
invoking test code, adding a first layer identical to the player region, a second layer identical to the non-player region, the first layer filling a first color, the second layer filling a second color, and changing the first color to a third color upon a visualized collision between the player character and the non-player character;
if the test is completed, annotating the test code to ignore the test code.
11. The method according to any one of claims 1-10, further comprising:
if the visualized collision occurs between the player character and the non-player character, the player character is moved to a target position, wherein the target position is other positions except the position where the visualized collision occurs to the player character;
and under the condition of maintaining the end point unchanged, triggering a new movement operation for the player character, and returning to execute the movement operation triggered by the player character, and planning a path for avoiding the current non-player character for the player character in the virtual map.
12. The method of claim 11, wherein the moving the player character to a target location comprises:
identifying a direction opposite to a forward direction at which the player character visually collides as a target direction;
randomly extracting a numerical value in a preset moving range to be used as a length;
and moving the player character to a target position outside the length along the target direction.
13. A collision detection method, characterized by comprising:
loading a virtual map and loading player characters controlled by a user in the virtual map when entering a specified virtual map, wherein the virtual map is divided into a plurality of grids, and non-player characters in a moving state are edited in the virtual map;
if a movement operation triggered by the player character is received, planning a path for avoiding the current non-player character for the player character in a plurality of grids;
extracting features visible in the virtual map as visual features for the player character and the non-player character in the process of controlling the player character to move along the path;
and detecting whether a visualized collision occurs between the non-player character and the player character according to the visualized characteristics.
14. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the collision test method of any one of claims 1 to 12 or the collision detection method of claim 13.
15. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program for causing a processor to implement the collision test method of any one of claims 1 to 12 or the collision detection method of claim 13 when executed.
CN202310586105.9A 2023-05-23 2023-05-23 Collision test and detection method, device and storage medium thereof Active CN116617669B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310586105.9A CN116617669B (en) 2023-05-23 2023-05-23 Collision test and detection method, device and storage medium thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310586105.9A CN116617669B (en) 2023-05-23 2023-05-23 Collision test and detection method, device and storage medium thereof

Publications (2)

Publication Number Publication Date
CN116617669A true CN116617669A (en) 2023-08-22
CN116617669B CN116617669B (en) 2024-06-04

Family

ID=87602018

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310586105.9A Active CN116617669B (en) 2023-05-23 2023-05-23 Collision test and detection method, device and storage medium thereof

Country Status (1)

Country Link
CN (1) CN116617669B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130109468A1 (en) * 2011-10-28 2013-05-02 Nintendo Co., Ltd. Game processing system, game processing method, game processing apparatus, and computer-readable storage medium having game processing program stored therein
JP2015024158A (en) * 2014-09-30 2015-02-05 株式会社カプコン Game program and game system
WO2018130135A1 (en) * 2017-01-13 2018-07-19 腾讯科技(深圳)有限公司 Method and device for controlling way-finding of simulation object, and server
CN110180182A (en) * 2019-04-28 2019-08-30 腾讯科技(深圳)有限公司 Collision checking method, device, storage medium and electronic device
CN112044074A (en) * 2020-09-04 2020-12-08 网易(杭州)网络有限公司 Method, device, storage medium and computer equipment for seeking path to non-player character
CN114470775A (en) * 2022-01-27 2022-05-13 腾讯科技(深圳)有限公司 Object processing method, device, equipment and storage medium in virtual scene
US20220203237A1 (en) * 2020-12-30 2022-06-30 Activision Publishing, Inc. Systems and Methods for Improved Collision Detection in Video Games
US20220305385A1 (en) * 2021-03-29 2022-09-29 Niantic, Inc. Travel of virtual characters

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130109468A1 (en) * 2011-10-28 2013-05-02 Nintendo Co., Ltd. Game processing system, game processing method, game processing apparatus, and computer-readable storage medium having game processing program stored therein
JP2015024158A (en) * 2014-09-30 2015-02-05 株式会社カプコン Game program and game system
WO2018130135A1 (en) * 2017-01-13 2018-07-19 腾讯科技(深圳)有限公司 Method and device for controlling way-finding of simulation object, and server
CN110180182A (en) * 2019-04-28 2019-08-30 腾讯科技(深圳)有限公司 Collision checking method, device, storage medium and electronic device
CN112044074A (en) * 2020-09-04 2020-12-08 网易(杭州)网络有限公司 Method, device, storage medium and computer equipment for seeking path to non-player character
US20220203237A1 (en) * 2020-12-30 2022-06-30 Activision Publishing, Inc. Systems and Methods for Improved Collision Detection in Video Games
US20220305385A1 (en) * 2021-03-29 2022-09-29 Niantic, Inc. Travel of virtual characters
CN114470775A (en) * 2022-01-27 2022-05-13 腾讯科技(深圳)有限公司 Object processing method, device, equipment and storage medium in virtual scene

Also Published As

Publication number Publication date
CN116617669B (en) 2024-06-04

Similar Documents

Publication Publication Date Title
CN108052662B (en) Webpage-based component layout method, device, equipment and storage medium
CN111744199B (en) Image processing method and device, computer readable storage medium and electronic equipment
CN110413276B (en) Parameter editing method and device, electronic equipment and storage medium
CN112560862B (en) Text recognition method and device and electronic equipment
WO2019114136A1 (en) H5 activity page production method, electronic device and readable storage medium
CN109712167A (en) Target detecting and method for tracing and system
CN112003729B (en) Heterogeneous cloud platform resource topology display method, system, terminal and storage medium
CN111228816A (en) Scene layout method and device in game
CN114063858A (en) Image processing method, image processing device, electronic equipment and storage medium
CN112100302A (en) Map information point display method, device, equipment and readable storage medium
CN113570727B (en) Scene file generation method and device, electronic equipment and storage medium
CN103809954A (en) Method and device for realizing interface element selection
CN116617669B (en) Collision test and detection method, device and storage medium thereof
CN111986229A (en) Video target detection method, device and computer system
CN117608869A (en) Transaction deadlock visualization method, device and equipment for low-code platform
US10713832B2 (en) Precomputed environment semantics for contact-rich character animation
WO2022247196A1 (en) Game positioning method and apparatus, and mobile terminal
CN116994122A (en) Building pickup method, device, equipment and storage medium
CN116832441A (en) Game display control method and device, storage medium and electronic equipment
CN113126866A (en) Object determination method and device, electronic equipment and storage medium
CN113763508B (en) Vector data processing method, device and medium based on virtual engine
CN112306346A (en) Set square drawing method and device, storage medium and electronic whiteboard
EP4343505A1 (en) Method and apparatus for sensing area separation during floating control, and floating control remote controller
CN116049505B (en) Screen space tag collision detection method and device, computer equipment and storage medium
CN114546174B (en) Handwriting processing method, display device and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant