This article will briefly introduce how to optimize the code of the agent. The simplest way to optimize the code of the agent is not to call the code first. This is not to say that you want to delete the code. Maybe you can use other methods to call them. The latter actually reduces the number of calls to it ).
J2-based code optimization
The simplest way to optimize the code is not to call the code first. This is not to say that you want to delete the code. Maybe you can use other methods to call them. The latter actually reduces the number of calls to it ). The main loop of a game is the primary task of running the game. You should consider whether you can use or reduce the call to the Code in this region. The following describes how to optimize the code based on other documents.
The technology for optimizing the code of j2_based architecture can be divided into two main aspects: Advanced optimization, Optimization Based on the overall algorithm and structure used; low-level optimization, focuses on the optimization of isolated code snippets, usually the code in the method. The following two optimizations are discussed:
I. Advanced j2_code Optimization
1. Feeling true
For movies, what we see through the camera is perfect, while what we see at the shooting scene is wood, foam and tape. So for a movie, the feeling is true.
The same is true for games. You only need to deal with what the game needs. It is practical in all aspects of game development. Focus on making the game interesting and running perfectly, always do what you need and discard other parts.
2. Do not create objects.
Reducing the total number and frequency of object creation can greatly improve the game performance. You must also be careful when generating String objects inadvertently.
Example: graphics. drawString (, "Score:" + score );
This code will generate a new String object each time it is called. Here, a New String object will be generated when each screenshot is displayed. Therefore, it is best to construct this String only when the score is changed.
3. Draw the screen
In general, after a lot of optimization work is done on the game, the result will be a game that spends a lot of time on screen plotting. This is because the main time consumption of a game is mostly focused on Image Rendering or some other basic drawing calls ). Therefore, if you can avoid plotting at the beginning, it will be a good optimization for the game.
There is also the need to reduce screen painting and check whether the screen image has changed in a certain part. If not, do not update the screen. The other method is to increase the size of the image to reduce the number of times the image is called.
4. Algorithms
The best and most used advanced optimization is the algorithm aspect of the game.