实现 ComputeTarget 预测落点计算逻辑 实现函数18
This commit is contained in:
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
- [x] `14. Fixing` - `src/source/TetrisLogic.cpp`
|
- [x] `14. Fixing` - `src/source/TetrisLogic.cpp`
|
||||||
- [x] `17. GameOver` - `src/source/TetrisLogic.cpp`
|
- [x] `17. GameOver` - `src/source/TetrisLogic.cpp`
|
||||||
- [ ] `18. ComputeTarget` - `src/source/TetrisLogic.cpp`
|
- [x] `18. ComputeTarget` - `src/source/TetrisLogic.cpp`
|
||||||
- [ ] `19. Restart` - `src/source/TetrisLogic.cpp`
|
- [ ] `19. Restart` - `src/source/TetrisLogic.cpp`
|
||||||
|
|
||||||
## 第五阶段:消行与得分逻辑
|
## 第五阶段:消行与得分逻辑
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 147 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -334,9 +334,30 @@ bool GameOver()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 计算当前活动方块的预测落点位置。
|
||||||
|
*
|
||||||
|
* 该函数以当前活动方块的位置为起点,使用虚拟下落的方式不断尝试向下移动,
|
||||||
|
* 直到方块无法继续下落为止。最终得到的最低可达位置会写入 target,
|
||||||
|
* 供后续界面绘制瞄准器或落点提示时使用。
|
||||||
|
*
|
||||||
|
* 计算过程中不会改变当前方块的真实位置 point。
|
||||||
|
*/
|
||||||
void ComputeTarget()
|
void ComputeTarget()
|
||||||
{
|
{
|
||||||
// TODO(作业18): 计算瞄准器的预测落点。
|
Point originalPoint = point;
|
||||||
|
|
||||||
|
// 从当前方块位置开始向下试探
|
||||||
|
target = point;
|
||||||
|
|
||||||
|
while (CanMoveDown())
|
||||||
|
{
|
||||||
|
point.y++;
|
||||||
|
target = point;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 恢复当前方块的真实位置
|
||||||
|
point = originalPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Restart()
|
void Restart()
|
||||||
|
|||||||
Reference in New Issue
Block a user