c++ - 将网格中的 2 个项目交换为三消游戏
问题描述
我刚刚初始化了一个随机值的网格,现在我想创建一个名为 SwapItem 的函数,它将交换我的网格的 2 个元素
这是我的网格初始化:
CPlateau::CPlateau()
: m_iColonnes(8)
, m_iLignes(8)
, m_arrPlateau(NULL)
void CPlateau::CreatePlateau()
{
m_arrPlateau = new int*[m_iLignes];
for (int ligne = 0; ligne < m_iLignes; ligne++)
{
m_arrPlateau[ligne] = new int[m_iColonnes];
for (int col = 0; col < m_iColonnes; col++)
m_arrPlateau[ligne][col] = 0;
}
}
void CPlateau::SetupPlateau()
{
if (m_arrPlateau == NULL)
CreatePlateau();
for (int ligne = 0; ligne < m_iLignes; ligne++)
for (int col = 0; col < m_iColonnes; col++)
m_arrPlateau[ligne][col] = (rand() % 7);
}
我正在使用带有 MFC 应用程序的 Visual c++,我将在 View.cpp 中管理鼠标单击,但在我需要创建将交换网格的 2 个值的函数之前,虽然任务看起来很简单,但我不知道如何要做到这一点,你能帮我吗?许多想法
解决方案
推荐阅读
- c++ - 编译时未定义 C++ 基类
- c++ - 如何连接Cpp中的变量名称?
- swift - 领域(10.1.0)“找不到框架领域同步”
- php - WooCommerce - 如何调用 Xero 操作
- sql - SQL查询多个表以找到对应/相关的值
- python - _tkinter.TclError:找不到包通讯
- discord - 如何使用 discord.py 创建文本频道?
- scala - com.lightbend.lagom.internal.scaladsl.registry.ScalaServiceRegistryClient [] - 未找到 serviceName=[elastic-search]
- php - 如何将 wordpress 内容导出/导入到另一个模板
- python - PyCharm 中的错误,但不是 Jupyter Lab:numpy.linalg.LinAlgError:SVD 未在线性最小二乘中收敛