Oh, it's ugly. No way. I'm not an artist ...... Raise your hand if you are an artist !!
This is the debugging window. The above part has already been okay. This time, the focus is on the following trace. We can see whether the effect is D. To be honest, this trace window has helped me debug and think about scheduling and action schedulers. multi-thread and synchronization are indeed difficult to adjust, and sometimes some inexplicable problems may occur, when you find that the breakpoint is too late, you cannot set the breakpoint before running (the problem will not occur ). At this time, it depends on the trace window and some temporarily added MessageBox. ShowCodeTo complete debugging.
Brief description: The tank #... it indicates that the think scheduler schedules tank # 0000001c for consideration, because I added a frmdebug statement in the think code of tank. instance. trace (...);, that is, the content of the Code is displayed.
The other sleep = 100... is the output of sleep of the Main Loop thread of the game. Currently, the game content is simple, and there are few objects, so the activity volume is very small. At this time, we cannot keep the CPU in a loop. We have to keep a basic speed or take a picture. I did not spend much time doing this. This line of output is for this debugging.
Sleep = 100 indicates a total of 100 ms of sleep. In fact, the cycle is limited to 100 ms, which means there is almost no amount of exercise. However, do not think that this is the initial result. The initial result is rather chaotic. Because the unit of sleep is ms, and the unit of ticks is 0.001 ms, there is always a problem (I did not find the unit is different), either it is often sleep, or the cycle is not fixed. In addition, the trace code has not been well optimized at the beginning, so almost every cycle consumes more than 100 ms. After an optimization, it is found that it will get slower and slower, because the tracking information is getting bigger and bigger. After another adjustment, the time consumed by each cycle is reduced to 20 to 30 ms. Finally, I performed update interval control on the trace (now the trace is output every second), and the above result is obtained-almost no consumption.
Of course, this tracer feature will become more and more comprehensive, and I hope to be able to surpass the trace capability of terrarium. But now we can make up and use it, so we do not plan to perform well-functional operations.