当前位置:网站首页>The latest tank battle 2022 - full development notes-3
The latest tank battle 2022 - full development notes-3
2022-07-29 05:20:00 【CPP programming】
8、 ... and 、 Create a tour loop
8.1 Create the main loop of the game 、
int main(void) {
init();
createMyTank();
createEnemyTank();
while (1) {
updataMap();
updataAllTanks();
}
system("pause");
return 0;
}8.2 Use time counting to optimize the loop
The cycle structure of the previous step , Keep refreshing , It seriously consumes the performance of the system , It must be improved . The easiest way , Use time counting to process . Be careful , Use it directly Sleep It will affect the timely response of the game .
bool updata; // Whether to update , And in init Function is initialized to true
int main(void) {
init();
createMyTank();
createEnemyTank();
int time = 0;
while (1) {
time += getDelay();
if (time >= 20) {
updata = true;
time = 0;
}
if (updata) {
updata = false;
BeginBatchDraw();
updataMap();
updataAllTanks();
EndBatchDraw();
}
}
system("pause");
return 0;
} Today's sharing is here , Everyone should study hard C Language /C++ yo ~
Welcome to change careers and learn programming partners , Using more information to learn and grow faster than thinking about it yourself !
For preparing to learn C/C++ Programming partners , If you want to better improve your core programming skills ( Internal skill ) From now on !
Organize and share ( Years of learning source code 、 Project practice video 、 Project notes , Introduction to Basics ) Add the group below to get ~
C Language C++ Programming learning communication circle ,QQ Group :763855696 【 Click to enter 】
C Language from entry to mastery (C Introduction to language C Language course C Language zero basis C Language foundation C Language learning C
边栏推荐
- How to add traffic statistics codes to the legendary Development Zone website
- WDDM学习
- Youxuan database failed to start and reported network error
- 一文带你搞懂环绕通知@Around与最终通知@After的实现
- 力扣------对奇偶下标分别排序
- 浅谈AspectJ框架
- js(forEach)出现return无法结束函数的解决方法
- Google gtest事件机制
- [sudden] solve remote: support for password authentication was removed on August 13, 2021. please use a perso
- Unity metaverse (III), protobuf & socket realize multi person online
猜你喜欢

Sparksql inserts or updates in batches and saves data to MySQL

Pytorch learning notes

QT学习:使用JSON/XML等非ts文件实现多语言国际化

Deadlock analysis using jstack, jconsole, and jvisualvm

ARFoundation从零开始9-AR锚点(AR Anchor)
![[from_bilibili_DR_CAN][【Advanced控制理论】9_状态观测器设计][学习记录]](/img/9d/d9a4a3091c00ec65a9492ca49267db.png)
[from_bilibili_DR_CAN][【Advanced控制理论】9_状态观测器设计][学习记录]

Numpy Foundation

Young freshmen yearn for more open source | here comes the escape guide from open source to employment!

向往的开源之多YOUNG新生 | 从开源到就业的避坑指南来啦!

Network Security Learning - Intranet Security 1
随机推荐
2021-11-02
roLabelImg转DATO格式数据
ARFoundation从零开始3-创建ARFoundation项目
Scikit learn -- steps and understanding of machine learning application development
Solution | get the relevant information about the current employees' highest salary in each department |
How does WPS use smart fill to quickly fill data? WPS method of quickly filling data
7.2-function-overloading
Lenovo Savior r7000+ add ssd+ copy and partition the information of the original D disk to the new SSD
JS daily question (12)
The person who goes to and from work on time and never wants to work overtime has been promoted in front of me
pytorch学习笔记
Deep learning brush a bunch of tricks of SOTA
力扣------对奇偶下标分别排序
Open source Huizhi creates the future | the openeuler sub forum of 2022 open atom global open source summit was successfully held
Mysql的自连接和联合查询
那个准时上下班,从不愿意加班加点的人,在我前面升职了...
JS (in ES6) sync & await understanding
关于thymeleaf的配置与使用
P2181 diagonal
AUTOSAR from introduction to proficiency 100 lectures (78) -autosar-dem module