当前位置:网站首页>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;
}
边栏推荐
- E-R graph to relational model of the 2022 database of tyut Taiyuan University of Technology
- 凡人修仙学指针-1
- View UI Plus 发布 1.3.0 版本,新增 Space、$ImagePreview 组件
- Interview Essentials: talk about the various implementations of distributed locks!
- 2.初识C语言(2)
- 系统设计学习(三)Design Amazon‘s sales rank by category feature
- A brief introduction to the database of tyut Taiyuan University of technology in previous years
- 用栈实现队列
- Rich Shenzhen people and renting Shenzhen people
- View UI Plus 发布 1.3.1 版本,增强 TypeScript 使用体验
猜你喜欢
The overseas sales of Xiaomi mobile phones are nearly 140million, which may explain why Xiaomi ov doesn't need Hongmeng
2-year experience summary, tell you how to do a good job in project management
2.C语言矩阵乘法
TYUT太原理工大学2022软工导论大题汇总
阿里云微服务(一)服务注册中心Nacos以及REST Template和Feign Client
Introduction and use of redis
3.C语言用代数余子式计算行列式
Inheritance and polymorphism (Part 2)
凡人修仙学指针-2
Data manipulation language (DML)
随机推荐
View UI Plus 發布 1.3.1 版本,增强 TypeScript 使用體驗
4.30动态内存分配笔记
3.C语言用代数余子式计算行列式
Atomic and nonatomic
View UI Plus 发布 1.1.0 版本,支持 SSR、支持 Nuxt、增加 TS 声明文件
Arduino+ water level sensor +led display + buzzer alarm
165. Compare version number - string
(ultra detailed onenet TCP protocol access) arduino+esp8266-01s access to the Internet of things platform, upload real-time data collection /tcp transparent transmission (and how to obtain and write L
阿里云微服务(三)Sentinel开源流控熔断降级组件
Database operation of tyut Taiyuan University of technology 2022 database
Tyut Taiyuan University of technology 2022 introduction to software engineering examination question outline
最新坦克大战2022-全程开发笔记-2
【九阳神功】2019复旦大学应用统计真题+解析
2-year experience summary, tell you how to do a good job in project management
IPv6 experiment
View UI plus released version 1.3.1 to enhance the experience of typescript
分支语句和循环语句
5. Download and use of MSDN
Ten minutes to thoroughly master cache breakdown, cache penetration, cache avalanche
六种集合的遍历方式总结(List Set Map Queue Deque Stack)