Open
Conversation
luckymark
reviewed
Mar 20, 2019
level1/p10_pushBoxes/pushBoxes.c
Outdated
| flag = 0; | ||
| for (int k = 1; k <= AimNum; ++k) | ||
| { | ||
| if (i == AimX[k] && j == AimY[k]) |
Author
There was a problem hiding this comment.
将判断修改进了原有的CheckStatus函数中
int CheckStatus(int x, int y)
{
if (x < 0 || x > h + 1 || y < 0 || y > w + 1)return -1;
if (Maze[x][y] == '#')return 0;
if (Maze[x][y] == 'o')return 1;
else
{
for (int k = 1; k <= AimNum; ++k)
{
if (x == AimX[k] && y == AimY[k])
return 2;
}
}
return 3;
}PrintMaze中修改为
if (i == NowX && j == NowY)printf("S");
else if (CheckStatus(i, j) == 2)printf("O");
else printf("%c", Maze[i][j]);
level1/p10_pushBoxes/pushBoxes.c
Outdated
| flag = CheckStatus(NowX + tx * 2, NowY + ty * 2); | ||
| if (flag == 2) | ||
| { | ||
| Maze[NowX + tx][NowY + ty] = ' '; |
Author
There was a problem hiding this comment.
新增函数MoveCharacter
int MoveCharacter(int tx, int ty)
{
int flag[2];
flag[0] = CheckStatus(NowX + tx, NowY + ty);
flag[1] = CheckStatus(NowX + tx * 2, NowY + ty * 2);
if (flag[0] == 1 && flag[1] >= 2)
{
Maze[NowX + tx][NowY + ty] = ' ';
Maze[NowX + tx * 2][NowY + ty * 2] = 'o';
NowX += tx; NowY += ty;
Score--;
}
else if (flag[0] >= 2)
{
NowX += tx;
NowY += ty;
Score--;
}
else return 1;
return 0;
}返回1则说明未移动,主函数中不进行刷新
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ヽ(○´∀`)ノ♪