2 Star 58 Fork 0

fg/Game-superMary-superMario

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
master.cpp 3.86 KB
一键复制 编辑 原始数据 按行查看 历史
fg 提交于 2021-04-06 22:58 . project initialized
#include "master.h"
#include"mary.h"
#include"QDebug"
Master::Master() {
Master_Init();
}
void Master::Master_Init() {
die_state = 0;
direction = "left";
QVector<int> v;
int arr[10][2] = {{2370, 460},
{2670, 460},
{3000, 460},
{3200, 460},
{3230, 460},
{3600, 460},
{4000, 460},
{4500, 460},
{5500, 460},
{6200, 460}};
for (int i = 0; i < 10; i++) {
v.push_back(arr[i][0]);
v.push_back(arr[i][1]);
v.push_back(1);
v.push_back(0);//0代表左
v.push_back(0);//0代表没有展示压扁的master
v1.push_back(v);
v.clear();
}
m.insert(1, v1);
v1.clear();
}
void Master::Master_State(Mary *m, Pipe *p, Brick *r) {
mary = m;
pipe = p;
brick = r;
}
void Master::Master_Move() {
if (die_state != 0) {
die_state++;
}
for (itm = m.begin()->begin(); itm != m.begin()->end(); itm++) {
if (die_state == 25 && *(itm->begin() + 4) == 1) {
die_state = 0;
*(itm->begin() + 4) = 2;
}
if (*itm->begin() - mary->x > -40 && *(itm->begin()) - mary->x < 800 && *(itm->begin() + 2) == 1) {
if (*itm->begin() - mary->x <= 340 && (*itm->begin() - mary->x >= 270) && mary->y > 410 && mary->y < 455 &&
!mary->is_jump) {
die_state = 1;
*(itm->begin() + 4) = 1;
mary->is_jump_end = false;//跳跃状态开始
mary->distance = 1;
*(itm->begin() + 2) = 0;
return;
}
if (((*itm->begin() - mary->x >= 330 && *itm->begin() - mary->x <= 340) ||
(*itm->begin() - mary->x >= 270 && *itm->begin() - mary->x <= 280)) && mary->y == 455) {
if (mary->colour == 1 && !mary->is_invincible) {
mary->is_die = true;
} else if (mary->colour != 1 && !mary->is_invincible) {
mary->colour = 1;
mary->is_invincible = true;
}
}
if (*(itm->begin() + 3) == 1) {
*itm->begin() += 1;
} else if (*(itm->begin() + 3) == 0) {
*(itm->begin()) -= 1;
}
for (QVector < QVector < int >> ::iterator it = brick->m.begin()->begin(); it != brick->m.begin()->end();
it++)
{
if (*it->begin() - *itm->begin() == 40 && *(it->begin() + 2) == 1 && *(it->begin() + 1) == 460) {
*(itm->begin() + 3) = 0;
return;
} else if (*it->begin() - *itm->begin() == -60 && *(it->begin() + 2) == 1 &&
*(it->begin() + 1) == 460) {
*(itm->begin() + 3) = 1;
return;
}
}
for (QVector < QVector < int >> ::iterator it = pipe->long_m.begin()->begin(); it != pipe->long_m.begin()->end();
it++)
{
if (*it->begin() - *itm->begin() == 30) {
*(itm->begin() + 3) = 0;
return;
} else if (*it->begin() - *itm->begin() == -70) {
*(itm->begin() + 3) = 1;
return;
}
}
for (QVector < QVector < int >> ::iterator it = pipe->short_m.begin()->begin(); it != pipe->short_m.begin()->end();
it++)
{
if (*it->begin() - *itm->begin() == 30) {
*(itm->begin() + 3) = 0;
return;
} else if (*it->begin() - *itm->begin() == -70) {
*(itm->begin() + 3) = 1;
return;
}
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/wenyanghe/supermary.git
git@gitee.com:wenyanghe/supermary.git
wenyanghe
supermary
Game-superMary-superMario
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385