Disclosure of Invention
In order to solve the technical problem of low storage efficiency of background materials, the invention provides a high-efficiency storage method for leisure action hand-tour material data, which adopts the following technical scheme:
the invention provides a high-efficiency storage method of leisure action hand-free material data, which comprises the following steps:
acquiring a game foreground material and a background material, determining the background material to be read according to the background material being read at the current moment, taking the moment when the foreground material starts to move as an initial moment, and determining the moving speed of the foreground material and the average speed variation of all moments from the initial moment to each moment;
determining the inertia speed variation of the foreground material at the current moment according to the moving speed and the average speed variation of the foreground material at the current moment and the previous moment, and determining the predicted moving distance of the foreground material at the next moment according to the inertia speed variation of the current moment, the moving speed and the interval time of the adjacent moment;
determining the triggering distance of the foreground material from a preset triggering boundary at the next moment according to the position of the foreground material at the current moment, and determining the edge touching coefficients of the foreground material on different preset triggering boundaries at the next moment according to the predicted moving distance, the triggering distance and the average speed variation of the foreground material in the moving process;
and determining background reading possibility of the background material to be read at the next moment according to the touch edge coefficient, compressing the background material to be read according to the background reading possibility of the background material to be read to obtain compressed data, and storing the compressed data into a preset storage space.
Further, the determining the inertial velocity variation of the foreground material at the current moment according to the moving velocity of the foreground material and the average velocity variation at the current moment and the previous moment includes:
calculating a difference value between the moving speed of the foreground material at the current moment and the moving speed of the foreground material at the previous moment to serve as a moving speed variation of the current moment;
and calculating the sum of the average speed variation and the moving speed variation at the current moment to be used as the inertia speed variation of the foreground material at the current moment.
Further, the determining the predicted moving distance of the foreground material at the next moment according to the inertial velocity variation at the current moment, the moving velocity and the interval time between adjacent moments includes:
calculating the product of the interval time and the inertia speed variation as the speed variation of the next moment;
calculating the sum of the moving speed at the current moment and the speed variation at the next moment to be used as the predicted speed at the next moment;
and calculating the product of the predicted speed and the interval time as the predicted moving distance.
Further, the determining, according to the predicted moving distance, the triggering distance and the average speed variation of the foreground material in the moving process, the edge touching coefficients of the foreground material on different preset triggering boundaries at the next moment includes:
taking the predicted moving distance as a numerator, taking the sum of the triggering distance of the preset triggering boundary and a preset coefficient as a denominator, and calculating a triggering length ratio;
when the average speed variation is not 0, normalizing the product of the average speed variation and the triggering length ratio to obtain a triggering edge coefficient corresponding to a preset triggering boundary;
and when the average speed variation is 0, normalizing the trigger length ratio to obtain a touch edge coefficient corresponding to a preset trigger boundary.
Further, the determining, according to the touch edge coefficient, a background reading possibility of the background material to be read at the next moment includes:
and taking the touch edge coefficient of the preset trigger boundary as the background reading possibility of the background material to be read corresponding to the preset trigger boundary.
Further, the compressing the background material to be read according to the background reading possibility of the background material to be read to obtain compressed data includes:
when the background reading possibility of the background material to be read is smaller than or equal to a preset background reading threshold value, compressing the background material to be read in a first preset compression mode to obtain compressed data;
and when the background reading possibility of the background material to be read is larger than a preset background reading threshold, compressing the background material to be read by adopting a second preset compression mode to obtain compressed data, wherein the compression rate of the first preset compression mode is higher than that of the second preset compression mode.
Further, the storing the compressed data in a preset storage space includes:
and storing the compressed data into a preset storage space according to the sequence of the corresponding background reading possibility from high to low.
Further, the determining the background material to be read according to the background material being read at the current moment includes:
and determining other background materials which have direct connection relation with the background materials being read at the current moment as the background materials to be read.
Further, the determining the moving speed of the foreground material and the average speed variation of all the moments from the initial moment to the current moment includes:
determining position coordinates of foreground materials at different moments, and calculating the moving speed of the foreground materials at each moment according to the position coordinates of adjacent moments and the time interval of the adjacent moments;
calculating the difference value of the moving speed at each moment and the previous moment respectively according to a speed variation calculation formula to serve as the speed variation of the corresponding moment;
and calculating the average value of the speed variation of the foreground material at each time except the initial time as an average speed variation.
The invention has the following beneficial effects:
according to the method, the moving speed and the average speed variation of the foreground materials in the moving process at each moment are determined, so that the states of the foreground materials in the moving process can be effectively counted, the background materials to be read are determined through the background materials being read at the current moment, and the situation that the preset storage space is excessively bloated due to the fact that all the background materials are read into the preset storage space in advance can be effectively avoided, and therefore the storage efficiency of the preset storage space is affected; according to the invention, the change amount of the inertia speed of the foreground material at the current moment is calculated as the movement trend, the predicted movement distance at the next moment is determined, the predicted movement distance is determined through the inertia of the foreground material, so that the reality of game performance is effectively improved, meanwhile, reasonable prediction of the movement distance of the foreground material at the next moment can be realized through determining the predicted movement distance, so that the touch coefficients of different preset trigger boundaries are conveniently analyzed according to the predicted movement distance, then, the triggering probability of different preset trigger boundaries is realized according to the touch coefficients, the background reading possibility corresponding to different background materials to be read is obtained, the self-adaptive compression and storage of the background materials to be read can be carried out according to the background reading possibility, the compressed data can be directly read from the preset storage space in a self-adaptive compression and storage mode, the storage efficiency of the background materials to be read is further improved while the compression effect of the background materials to be read is ensured, the movement state of the foreground materials is analyzed according to the predicted, the touch coefficients are then, the background reading possibility corresponding to the different preset trigger boundaries is realized, the self-adaptive compression and the storage capacity of the background materials is reduced, and the storage capacity of the background materials to be read is guaranteed.
Detailed Description
In order to further describe the technical means and effects adopted by the invention to achieve the preset aim, the following is a method for efficiently storing the leisure action type hand-play material data according to the invention, which is provided by combining the accompanying drawings and the preferred embodiment, and the specific implementation, structure, characteristics and effects thereof are described in detail below. In the following description, different "one embodiment" or "another embodiment" means that the embodiments are not necessarily the same. Furthermore, the particular features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
The invention provides a specific scheme of a high-efficiency storage method for leisure action hand-free material data, which is specifically described below with reference to the accompanying drawings.
Referring to fig. 1, a flowchart of a method for efficiently storing leisure action hand-tour material data according to an embodiment of the present invention is shown, where the method includes:
s101: the method comprises the steps of obtaining a game foreground material and a background material, determining the background material to be read according to the background material being read at the current moment, taking the moment when the foreground material starts to move as an initial moment, and determining the moving speed of the foreground material at each moment from the initial moment to the current moment and the average speed variation of all moments.
It will be appreciated that the material read at the display interface may include foreground material that primarily includes objects operated by the game player or items controlled by the player, etc., and background material that may include non-player characters, independently modeled flowers and plants, a scene elevation drawing representing sky, land, sea, etc. When the target operated by the game player moves, the corresponding foreground material and background material may change on the display interface.
When the target operated by the game player moves, the corresponding foreground material reading and background material changing possibly occur, that is, the foreground material and the background material need to be stored in the memory in advance so as to be convenient for timely calling the foreground material and the background material.
Further, in the embodiment of the present invention, determining the background material to be read according to the background material being read at the current time includes: and determining other background materials which have direct connection relation with the background materials being read at the current moment as the background materials to be read.
The direct connection relationship may include a switching relationship, when the foreground material moves, a scene may be triggered to be switched to another scene, and the relationship between the background materials corresponding to the two corresponding scenes may be referred to as the switching relationship.
It can be appreciated that when the current Jing Sucai triggers a corresponding context switch condition, such as moving to a boundary or moving to a switch point, a new context may be read, and then the corresponding new context may be referred to as a context to be read. It will be appreciated that the background material to be read having a direct connection relationship with the background material being read at the present time may include at least one, without limitation.
In the embodiment of the present invention, when the foreground material starts to move, the time when the foreground material starts to move is taken as the initial time, and further, in the embodiment of the present invention, the moving speed of the foreground material from the initial time to each time in the current time and the average speed variation of all the times are determined, including: determining position coordinates of foreground materials at different moments, and calculating the moving speed of the foreground materials at each moment according to the position coordinates of adjacent moments and the time interval of the adjacent moments; calculating the difference value of the moving speed at each moment and the previous moment respectively according to a speed variation calculation formula to serve as the speed variation of the corresponding moment; and calculating the average value of the speed variation of the foreground material at each time except the initial time as an average speed variation.
In the embodiment of the present invention, the movement speed at the initial time may be 0.
The two-dimensional coordinate system can be built according to the scene so as to determine the position coordinates of the foreground materials in the scene at different moments.
In the embodiment of the invention, the moving speed of the foreground material at each moment can be calculated based on a speed calculation formula, that is, the distance between the position coordinates at adjacent moments can be calculated based on a distance formula between two points, and then the ratio of the distance to the time interval at the adjacent moments is calculated as the moving speed, so that the moving speeds corresponding to different moments are obtained, wherein the distance formula of the position coordinates at the adjacent moments is shown as follows:
wherein s is i The movement distance at the i-th time is represented, and the position coordinate corresponding to the i-th time is (x i ,y i ) The position coordinate corresponding to the (i-1) th time is (x) i-1 ,y i-1 ) I denotes an index of a time other than the initial time, that is, x i Represents the abscissa value, y, corresponding to the i-th moment i Represents the ordinate value, x, corresponding to the i-th moment i-1 Represents the abscissa value, y, corresponding to the (i-1) th moment i-1 The ordinate value corresponding to the (i-1) th time is shown.
And then calculating the ratio of the moving distance at the ith moment to the time interval from the (i-1) th moment to the ith moment as the moving speed at the ith moment.
After determining the moving speeds corresponding to different moments, the difference between the moving speeds at each moment and the previous moment can be calculated according to a speed change amount calculation formula as the speed change amount at the corresponding moment, wherein the corresponding calculation formula is as follows:
a i =v i -v i-1
wherein a is i Indicating the speed change amount at the i-th time, i indicating the index of the time other than the initial time, v i Indicating the movement speed at the ith moment, v i-1 The movement speed at the (i-1) th time is shown.
From this, calculate the initial time to the current time, the average value of the speed variation of the foreground material at each time except the initial time is taken as the average speed variation, the corresponding calculation formula is:
in an embodiment of the present invention,
representing the average speed from the initial time to the current timeDegree of change, a
i The I-th time is the speed change amount, I is the index of the time other than the initial time, I is the total number of all the time from the initial time to the current time, and may be the index value of the current time.
It can be appreciated that the average speed variation can be used to represent the overall movement variation of the foreground material at the current time, and then the movement trend of the foreground material can be determined according to the average speed variation, so as to facilitate the analysis of the reading of the background material according to the movement trend.
S102: and determining the inertia speed variation of the foreground material at the current moment according to the moving speed and the average speed variation of the foreground material at the current moment and determining the predicted moving distance of the foreground material at the next moment according to the inertia speed variation of the current moment, the moving speed and the interval time of the adjacent moment.
Further, in the embodiment of the present invention, according to the moving speed and the average speed variation of the foreground material at the current time and the previous time, determining the inertial speed variation of the foreground material at the current time includes: calculating a difference value between the moving speed of the foreground material at the current moment and the moving speed of the foreground material at the previous moment to serve as a moving speed variation of the current moment; and calculating the sum of the average speed variation and the moving speed variation at the current moment as the inertia speed variation of the foreground material at the current moment.
In the embodiment of the present invention, the difference between the moving speed at the current time and the moving speed at the previous time may be used as the moving speed variation of the current time, and it may be understood that the moving speed variation of the current time may be a positive value, a negative value or 0, when the moving speed variation of the current time is a positive value, it may indicate that the moving speed at the current time is increased, when the moving speed variation of the current time is a negative value, it may indicate that the moving speed at the current time is decreased, and when the moving speed variation of the current time is 0, it may indicate that the moving speed at the current time is unchanged.
The calculation formula corresponding to the inertial velocity variation comprises:
wherein k is
i Indicating the inertial velocity variation amount at the i-th time, i indicating the index of the time other than the initial time, a
i Indicating the amount of change in the movement speed at the i-th time,
indicating the average speed variation.
Therefore, the sum of the average speed variation and the moving speed variation at the current moment is calculated as the inertia speed variation of the foreground material at the current moment, and the overall inertia of the foreground material in the moving time and the moving inertia of the foreground material at the current moment can be effectively combined, so that the inertia speed variation at the current moment is obtained.
Further, in the embodiment of the present invention, determining a predicted moving distance of a foreground material at a next time according to an inertial velocity variation at a current time, a moving speed and an interval time between adjacent times includes: calculating the product of the interval time and the inertia speed variation as the speed variation of the next moment; calculating the sum of the moving speed at the current moment and the speed variation quantity at the next moment to be used as the predicted speed at the next moment; the product of the predicted speed and the interval time is calculated as the predicted moving distance.
It can be understood that, when the adjacent time is the interval time of continuously acquiring the foreground material twice, the interval time corresponding to the adjacent time continuously acquires the interval time of the foreground material twice, and the calculation formula corresponding to the predicted moving distance includes:
s I+1 =(v I +h*k I )*h
wherein s is I+1 Indicating the predicted movement distance for the next time (i+1), since I indicates the total number of all the times from the initial time to the current time, i.e., time I may indicate the current time, the corresponding (i+1) indicates the next time of the current time, v I Indicating the moving speed at the current time I, and h indicating the interval between adjacent timesBetween k I Indicating the change amount of inertial velocity at the current time I, h.times.k I Indicating the speed change amount (v) at the next time (I+1) I +h*k I ) The predicted speed at the next time (i+1) is shown.
The motion inertia of the foreground material can be accurately determined by calculating the predicted moving distance at the next moment through the inertia speed variation and the moving speed at the current moment, and the phenomena of material reading delay and the like caused by lack of inertia consideration of the foreground material are effectively avoided while the reality of a game is improved.
S103: and determining the triggering distance of the foreground material from a preset triggering boundary at the next moment according to the position of the foreground material at the current moment, and determining the touch edge coefficients of the foreground material to different preset triggering boundaries at the next moment according to the predicted moving distance, the triggering distance and the average speed variation of the foreground material in the moving process.
In the embodiment of the invention, the triggering boundary at the current moment can be preset, when the foreground material is overlapped with the triggering boundary, the corresponding background material is triggered to be switched and read, it can be understood that the preset triggering boundary can be determined based on the content being displayed by the display interface and the position of the foreground material at the current moment, for example, the edge of the display interface or a certain position in the display interface, the number of the preset triggering boundaries can be at least one, that is, a plurality of preset triggering boundaries can be arranged around the foreground material, and the method is not limited.
After determining the preset trigger boundary, the trigger distance between the position of the foreground material at the current time and the preset trigger boundary may be determined, and it may be understood that in some games, the moving manner of the foreground material includes forward and backward movement, and in other embodiments, the moving manner of the foreground material may further include jumping, flying, etc., so that the shortest distance between the position of the foreground material at the current time and the preset trigger boundary may be calculated as the trigger distance, which is not limited.
For example, as shown in fig. 2, fig. 2 is a schematic diagram of moving foreground materials provided by an embodiment of the present invention, the outer dashed border corresponds to 4 preset trigger boundaries, L1, L2, L3, L4 respectively represent trigger distances of the foreground materials at the current time from the 4 preset trigger boundaries, FI represents a position of the foreground materials at the current time, FI-1 represents a position of the foreground materials at the previous time, fi+1 represents a position for predicting the foreground materials at the next time, and si+1 represents a predicted moving distance at the next time.
Further, in the embodiment of the present invention, according to the predicted moving distance, the triggering distance and the average speed variation of the foreground material in the moving process, determining the touch edge coefficients of the foreground material for different preset triggering boundaries at the next moment includes: taking the predicted moving distance as a numerator, presetting the sum value of the triggering distance of the triggering boundary and the preset coefficient as a denominator, and calculating the triggering length ratio; when the average speed variation is not 0, carrying out normalization processing on the product of the average speed variation and the triggering length ratio to obtain a triggering coefficient corresponding to a preset triggering boundary; and when the average speed variation is 0, normalizing the trigger length ratio to obtain a touch edge coefficient corresponding to a preset trigger boundary.
The calculation formula corresponding to the touch edge coefficient is as follows:
wherein τ
(I+1)x The touch edge coefficient indicating that the next moment (I+1) touches the x-th preset trigger boundary, since I indicates the total number of all the moments from the initial moment to the current moment, that is, the moment I can indicate the current moment, the corresponding (I+1) indicates the next moment of the current moment, x indicates the index of the preset trigger boundary,
representing the average speed variation, s
I+1 Indicating the predicted movement distance, L, for the next time (I+1)
x The normalization function in the embodiment of the present invention may specifically be, for example, maximum and minimum normalization, where γ represents a preset coefficient, and γ represents a preset coefficient, where γ represents a preset coefficientIn order to prevent a safety value set by a denominator of 0, optionally, γ=0.01, +.>
Representing the trigger length ratio.
It can be understood that, because of uncertainty of player operation, an effective determination cannot be made on the moving angle of the foreground material at the next moment, the trigger length ratio is determined directly by predicting the moving distance and the trigger distance of the preset trigger boundary, and it can be understood that when the predicted moving distance is greater than or equal to the trigger distance of the preset trigger boundary, the foreground material has a greater probability of triggering the preset trigger boundary, that is, when the trigger length ratio is greater than or equal to 1, the corresponding touch edge coefficient is greater, and when the predicted moving distance is less than the trigger distance of the preset trigger boundary, the foreground material cannot reach the preset trigger boundary, that is, when the trigger length ratio is less than 1, the corresponding touch edge coefficient is smaller.
When the average speed variation is 0, it may indicate that the foreground material is in uniform motion in the overall motion trend, so that the touch edge coefficient may be determined directly according to the trigger length ratio, and when the average speed variation is not equal to 0, it may indicate that the corresponding foreground material is in variable motion in the overall motion trend, that is, the next moment may be affected by acceleration to trigger the preset trigger boundary, so that it is determined that the average speed variation is in direct proportion to the touch edge coefficient.
S104: and determining background reading possibility of the background material to be read triggered at the next moment according to the touch edge coefficient, compressing the background material to be read according to the background reading possibility of the background material to be read to obtain compressed data, and storing the compressed data into a preset storage space.
Further, in the embodiment of the present invention, determining, according to the touch edge coefficient, a background reading possibility of triggering a background material to be read at a next time includes: and taking the touch edge coefficient of the preset trigger boundary as the background reading possibility of the background material to be read corresponding to the preset trigger boundary.
It can be understood that, since the display interface may include a plurality of preset trigger boundaries, each preset trigger boundary has a corresponding touch edge coefficient and a background material to be read. In the embodiment of the invention, the touch edge coefficient of the preset trigger boundary can be directly used as the background reading possibility of the background material to be read corresponding to the preset trigger boundary. The greater the background reading possibility is, the greater the possibility that the corresponding background material to be read is read to the display interface at the next moment is.
Further, in the embodiment of the present invention, compressing the background material to be read according to the background reading possibility of the background material to be read to obtain compressed data, including: when the background reading possibility of the background material to be read is smaller than or equal to a preset background reading threshold value, compressing the background material to be read by adopting a first preset compression mode to obtain compressed data; when the background reading possibility of the background material to be read is larger than a preset background reading threshold, compressing the background material to be read by adopting a second preset compression mode to obtain compressed data, wherein the compression rate of the first preset compression mode is higher than that of the second preset compression mode.
The first preset compression mode and the second preset compression mode are different preset compression modes, the compression rate of the first preset compression mode is higher than that of the second preset compression mode, for example, the first preset compression mode can be specifically a lossy data compression mode, and the second preset compression mode can be specifically a lossless data compression mode, for example, without limitation.
The preset background reading threshold is a threshold of background reading possibility of the background material to be read, and optionally, the preset background reading threshold may be specifically, for example, 0.8, which is not limited.
When the background reading possibility of the background material to be read is smaller than or equal to a preset background reading threshold value, the possibility that the background material to be read needs to be read to the display interface at the next moment is lower, and the background material to be read is compressed in a first preset compression mode to obtain compressed data.
When the background reading possibility of the background material to be read is larger than the preset background reading threshold, the possibility that the background material to be read needs to be read to the display interface at the next moment is higher, and the background material to be read is compressed in a second preset compression mode to obtain compressed data.
It can be understood that, since the compression rate of the first preset compression mode is higher than that of the second preset compression mode, that is, for the same background material to be read, the storage occupation of the compressed data obtained by the first preset compression mode is lower, the storage occupation of the compressed data obtained by the second preset compression mode is higher, but the decompression speed and the decompression effect of the compressed data obtained by the second preset compression mode are better in the subsequent rendering process.
Further, in an embodiment of the present invention, storing compressed data in a preset storage space includes: and storing the compressed data into a preset storage space according to the sequence of the corresponding background reading possibility from high to low.
The running memory space for storing the background material can be called as a preset memory space, and compressed data is stored in the preset memory space according to the sequence of the background reading possibility from large to small, so that the data with the maximum background reading possibility can be preferentially identified and called, and the reading efficiency of the background material to be read is effectively improved.
According to the method, the moving speed and the average speed variation of the foreground materials in the moving process at each moment are determined, so that the states of the foreground materials in the moving process can be effectively counted, the background materials to be read are determined through the background materials being read at the current moment, and the situation that the preset storage space is excessively bloated due to the fact that all the background materials are read into the preset storage space in advance can be effectively avoided, and therefore the storage efficiency of the preset storage space is affected; according to the invention, the change amount of the inertia speed of the foreground material at the current moment is calculated as the movement trend, the predicted movement distance at the next moment is determined, the predicted movement distance is determined through the inertia of the foreground material, so that the reality of game performance is effectively improved, meanwhile, reasonable prediction of the movement distance of the foreground material at the next moment can be realized through determining the predicted movement distance, so that the touch coefficients of different preset trigger boundaries are conveniently analyzed according to the predicted movement distance, then, the triggering probability of different preset trigger boundaries is realized according to the touch coefficients, the background reading possibility corresponding to different background materials to be read is obtained, the self-adaptive compression and storage of the background materials to be read can be carried out according to the background reading possibility, the compressed data can be directly read from the preset storage space in a self-adaptive compression and storage mode, the storage efficiency of the background materials to be read is further improved while the compression effect of the background materials to be read is ensured, the movement state of the foreground materials is analyzed according to the predicted, the touch coefficients are then, the background reading possibility corresponding to the different preset trigger boundaries is realized, the self-adaptive compression and the storage capacity of the background materials is reduced, and the storage capacity of the background materials to be read is guaranteed.
It should be noted that: the sequence of the embodiments of the present invention is only for description, and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments.