当前位置:网站首页>魔塔项目中的问题解决
魔塔项目中的问题解决
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);
边栏推荐
- Skywalking distributed system application performance monitoring tool - medium
- Code coverage statistical artifact -jacobo tool practice
- RS485接口的EMC设计方案
- 网络设备硬核技术内幕 路由器篇 14 从鹿由器到路由器 (中)
- Lecture 4: Longest ascending substring
- Web页面table表格,实现快速筛选
- Stm32f103c8t6 drives ssd1306 0.96 "IIC OLED display under Arduino frame
- Kubernetes CNI classification / operation mechanism
- What is the breakthrough point of digital transformation in the electronic manufacturing industry? Lean manufacturing is the key
- 终于有人把面试必考的动态规划、链表、二叉树、字符串全部撸完了
猜你喜欢

SkyWalking分布式系统应用程序性能监控工具-中

Skywalking distributed system application performance monitoring tool - medium

Do you really understand CMS garbage collector?

基于stm32的数字示波器设计方案

反射

Differences among CPU, GPU and NPU
![Detailed explanation of Telnet remote login AAA mode [Huawei ENSP]](/img/48/dd0fa3c494c45f604b7a93c707b808.png)
Detailed explanation of Telnet remote login AAA mode [Huawei ENSP]

视觉系统设计实例(halcon-winform)-10.PLC通讯

被动收入:回归原始且安全的两种赚取方法

Jmeter录制接口自动化
随机推荐
An example of building 3D effects on the web based on three.js
关于 CMS 垃圾回收器,你真的懂了吗?
深圳市人力资源和社会保障局关于发放脱贫人口就业有关补贴的通知
HDU3117 Fibonacci Numbers【数学】
Detailed explanation of Telnet remote login AAA mode [Huawei ENSP]
网络设备硬核技术内幕 路由器篇 20 DPDK (五)
【ManageEngine】什么是SIEM
终于有人把面试必考的动态规划、链表、二叉树、字符串全部撸完了
【云享读书会第13期】多媒体处理工具 FFmpeg 工具集
USB2.0接口的EMC设计方案
OBS 进阶之 DXGI 采集屏幕流程,并如何修改为自己的光标
FPGA timing constraint sharing 04_ Output delay constraint
Dynamic programming - stock trading 5
网络设备硬核技术内幕 路由器篇 11 CISCO ASR9900拆解 (五)
LeetCode 74. 搜索二维矩阵 二分/medium
视觉系统设计实例(halcon-winform)-9.文字显示
电子制造行业的数字化转型突破点在哪?精益制造是关键
网络设备硬核技术内幕 路由器篇 (10) CISCO ASR9900拆解 (四)
Differences among CPU, GPU and NPU
Notice of Shenzhen Municipal Bureau of human resources and social security on the issuance of employment related subsidies for people out of poverty