当前位置:网站首页>The latest tank battle 2022 - full development notes-3
The latest tank battle 2022 - full development notes-3
2022-07-06 13:27:00 【Programmer rock】
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;
}边栏推荐
- 【九阳神功】2020复旦大学应用统计真题+解析
- 7.数组、指针和数组的关系
- 阿里云微服务(四) Service Mesh综述以及实例Istio
- MYSQL索引钟B-TREE ,B+TREE ,HASH索引之间的区别和应用场景
- A brief introduction to the database of tyut Taiyuan University of technology in previous years
- Summary of multiple choice questions in the 2022 database of tyut Taiyuan University of Technology
- Smart classroom solution and mobile teaching concept description
- Aurora system model of learning database
- Tyut Taiyuan University of technology 2022 introduction to software engineering summary
- [中国近代史] 第五章测验
猜你喜欢

2.初识C语言(2)

MySQL 30000 word essence summary + 100 interview questions, hanging the interviewer is more than enough (Collection Series

6.函数的递归

2-year experience summary, tell you how to do a good job in project management

6. Function recursion

(超详细二)onenet数据可视化详解,如何用截取数据流绘图

View UI plus released version 1.2.0 and added image, skeleton and typography components

Experience summary of autumn recruitment of state-owned enterprises

Abstract classes and interfaces

Introduction and use of redis
随机推荐
阿里云微服务(三)Sentinel开源流控熔断降级组件
3.猜数字游戏
Inheritance and polymorphism (I)
How do architects draw system architecture blueprints?
Ten minutes to thoroughly master cache breakdown, cache penetration, cache avalanche
MySQL 30000 word essence summary + 100 interview questions, hanging the interviewer is more than enough (Collection Series
Experience summary of autumn recruitment of state-owned enterprises
Questions and answers of "basic experiment" in the first semester of the 22nd academic year of Xi'an University of Electronic Science and technology
7. Relationship between array, pointer and array
Common method signatures and meanings of Iterable, collection and list
View UI Plus 發布 1.3.1 版本,增强 TypeScript 使用體驗
(超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)
9.指针(上)
Several high-frequency JVM interview questions
Introduction pointer notes
Differences and application scenarios between MySQL index clock B-tree, b+tree and hash indexes
Share a website to improve your Aesthetics
3.C语言用代数余子式计算行列式
Tyut Taiyuan University of technology 2022 introduction to software engineering summary
TYUT太原理工大学2022数据库大题之E-R图转关系模式