当前位置:网站首页>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
边栏推荐
- Cache penetration, cache breakdown, cache avalanche and Solutions
- How to solve the problem of configuring the progress every time Office2010 is opened?
- Create a mindscore environment in modelars, install mindvision, and conduct in-depth learning and training (Huawei)
- Self join and joint query of MySQL
- ARFoundation从零开始5-AR图像跟踪
- Introduction of JDBC preparestatement+ database connection pool
- Visual Basic .Net 如何获取命令参数
- Network Security Learning - Intranet Security 1
- JS daily question (10)
- ODOO开发教程之透视表
猜你喜欢

Mapper agent development

Create a mindscore environment in modelars, install mindvision, and conduct in-depth learning and training (Huawei)

ODOO开发教程之透视表

Solution | get the relevant information about the current employees' highest salary in each department |

Understand activity workflow

ARFoundation从零开始8-Geospatial API(地理空间)开发

ARFoundation从零开始9-AR锚点(AR Anchor)

7.2-function-overloading

Unity Metaverse(三)、Protobuf & Socket 实现多人在线

Modification of annotation based three-tier project and the way of adding package scanning
随机推荐
How does WPS take quick screenshots? WPS quick screenshot method
MySQL many to many relationship, grouping and splicing to query multiple data to one data
What if the office prompts that the system configuration cannot run?
On AspectJ framework
小鲁客栈---预告篇
How to add traffic statistics codes to the legendary Development Zone website
P5714 [deep foundation 3. Case 7] obesity
Mysql多对多关系,分组拼接把多个数据查询到一条数据上
Functions in MySQL statements
AttributeError: ‘module‘ object has no attribute ‘create_ connection‘
源码编译pytorch坑
2021-10-11
AUTOSAR从入门到精通100讲(七十八)-AUTOSAR-DEM模块
Rimworld通过SteamCMD上传创意工坊的方法
JS (foreach) return cannot end the function solution
学习数据库的第一个程序
Mysql把查询到的结果集按指定顺寻进行排序
Qml类型:MouseArea
一文带你搞懂环绕通知@Around与最终通知@After的实现
小白高薪捷径-Qt开发游戏—贪吃蛇