当前位置:网站首页>魔塔项目中的问题解决
魔塔项目中的问题解决
2022-07-27 14:15:00 【傻子是小傲娇】
地图数据读取:
void Map::init_map(){//初始化地图 /*当前关卡*/ current_index = 0; /*位置地图*/ memset(pos_map, 0, sizeof(pos_map)); /*地图文件读取*/ FILE *fp; fp = fopen("map_data.txt", "r"); if (fp == NULL)cout << "open failed!" << endl; int i = 0, j = 0; while (!feof(fp)){ fscanf(fp, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &this->g_map[i][j][0], &this->g_map[i][j][1], &this->g_map[i][j][2], &this->g_map[i][j][3], &this->g_map[i][j][4], &this->g_map[i][j][5], &this->g_map[i][j][6], &this->g_map[i][j][7], &this->g_map[i][j][8], &this->g_map[i][j][9], &this->g_map[i][j][10], &this->g_map[i][j][11], &this->g_map[i][j][12]); j++; if (j == 13){ j = 0; i++; } } fclose(fp); }任务数据读取:
void TaskSystem::init(){ FILE *f1 = fopen("taskData.txt", "r+"); while (!feof(f1)){ Task now; fscanf(f1, "%s %d %d %d\n", &(now.taskName), &(now.id), &(now.award), &(now.mark)); taskList.push_back(now); } fclose(f1); }搜索模块:
void AutoPathFinding::Dfs(Point p, int step, vector<Point> S, int type,Map* map){ //cout << "in dfs" << endl; if ((int)map->g_map[map->current_index][p.x][p.y] == type){ if (ANS > step){ ANS = step; MT.push_back(S); } return; } if (step > ANS)return; for (int i = 0; i < 4; i++){ Point p1; p1.x = p.x + dx[i]; p1.y = p.y + dy[i]; if (check(map, p1,type)){ map->vis[p1.x][p1.y] = 1; S.push_back(p1); Dfs(p1, step + 1, S, type, map); map->vis[p1.x][p1.y] = 0; S.pop_back(); } } }PlaySound音乐播放:
//需要的头文件 #include<windows.h> #include<Mmsystem.h> #pragma comment(lib,"winmm.lib") using namespace std; //播放函数 PlaySound(TEXT("C:\\SoundEffect\\bg.wav"), NULL, SND_FILENAME | SND_ASYNC);输出光标的位置改变:
//定义光标位置 COORD coord; coord.X = 30; //第3行 coord.Y = 15; //第3列 //获取控制台缓冲区句柄,固定写法 HANDLE ConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE); //设置光标位置,固定写法 //coord.Y += 1; SetConsoleCursorPosition(ConsoleHandle, coord);
边栏推荐
- 代码覆盖率统计神器-jacoco工具实战
- Hdu3117 Fibonacci numbers [mathematics]
- Visual system design example (Halcon WinForm) -9. text display
- 反射
- 【云享读书会第13期】多媒体处理工具 FFmpeg 工具集
- 视觉系统设计实例(halcon-winform)-9.文字显示
- NEFU118 n! How many zeros are there after [basic theorem of arithmetic]
- 多表查询_练习1&练习2&练习3
- Nokia's patent business was hit for the first time, and Chinese enterprises are not so easy to knead
- LeetCode 341.扁平化嵌套列表迭代器 dfs,栈/ Medium
猜你喜欢

如何做好企业系统漏洞评估

【WORK】关于技术架构

LeetCode 74. 搜索二维矩阵 二分/medium

【ManageEngine】什么是SIEM

反射

Idea makes jar packages and introduces jar packages

Nokia's patent business was hit for the first time, and Chinese enterprises are not so easy to knead
MOS管防止电源反接的原理

See "sense of security" in uncertainty Volvo asked in 2022

基于stm32的数字示波器设计方案
随机推荐
一文搞懂 Redis 架构演化之路
【云享读书会第13期】视频文件的封装格式
Code coverage statistical artifact -jacobo tool practice
Skywalking distributed system application performance monitoring tool - medium
LeetCode 1143. 最长公共子序列 动态规划/medium
如果我们是那晚负责修复 B 站崩了的开发人员
网络设备硬核技术内幕 路由器篇 18 DPDK及其前传(三)
How to help enterprises optimize office management
Graphical SQL is too vivid
电子制造行业的数字化转型突破点在哪?精益制造是关键
Disk troubleshooting of kubernetes node
What is tor? What is the use of tor browser update?
Automatically configure SSH password free login and cancel SSH password free configuration script
The interviewer asked: how to judge whether an element is in the visible area?
网络设备硬核技术内幕 路由器篇 14 从鹿由器到路由器 (中)
Visual system design example (Halcon WinForm) -10. PLC communication
Kotlin的基础用法
Dialog manager Chapter 3: create controls
移动端使用vantUI的list组件,多个tab项来回切换时,列表加载多次导致数据无法正常展示
LeetCode 190. 颠倒二进制位 位运算/easy