2048当中移动方法的写法
来源:互联网 发布:js特效很好看的网站 编辑:程序博客网 时间:2024/05/17 01:13
moveUp{
for(int col =0; col < Game_Cols; col++){//行是不用变得
for(int row = Game_Rows -1; row >=0 ;row--){//每次取出一列就是从3开始去取到0
if(map[row][col] > 0){//如果这个位置的值是大于0的那么就判断这个位置的上面的值是不是为空
for(int row1 = row; row1< Game_Rows -1; row1++){
if(map[row1+1][col] == 0){//如果为空可以直接将当前的位置进行上移,
map[row1+1][col] = map[row1][col];
map[row1][col] = 0;
m_allTiled.at(map[row1+1][col] -1);
moveTo(row1 +1,col);//就是执行这个方法。进行的上移操作
}
}
}
}
}
}
//移动就是要传递过来相应的行还有列数
moveTo(int r, int c){
this->m_row = r;
}
for(int col =0; col < Game_Cols; col++){//行是不用变得
for(int row = Game_Rows -1; row >=0 ;row--){//每次取出一列就是从3开始去取到0
if(map[row][col] > 0){//如果这个位置的值是大于0的那么就判断这个位置的上面的值是不是为空
for(int row1 = row; row1< Game_Rows -1; row1++){
if(map[row1+1][col] == 0){//如果为空可以直接将当前的位置进行上移,
map[row1+1][col] = map[row1][col];
map[row1][col] = 0;
m_allTiled.at(map[row1+1][col] -1);
moveTo(row1 +1,col);//就是执行这个方法。进行的上移操作
}else{
//判断是可以消除
int numObj = m_allTiled.at(map[row1+1][col]-1)->m_number;
int numNow = m_allTiled.at(map[row1][col]-1)->m_number;
if(numObj ==numNow){//说明这两个数字是相同的
m_allTiled.at(map[row1+1][col] - 1)->doubleNumber();
m_allTiled.at(map[row1][col] - 1)->removeFromParent();
int index = map[row1][col];
m_allTiled.earse(map[row1][col]-1);
for(int r=0; r< Game_rows; r++){
for(int c=0;c<gameCols;c++){
if(map[r][c]> index){
map[r][c]--;//其他元素的位置要做相应的调整。
}
}
}
map[row1][col] =0;
}
}
}
}
}
}
}
//移动就是要传递过来相应的行还有列数
moveTo(int r, int c){
this->m_row = r;
this->m_col = c;
//设置位置的时候要进行相应的处理,就是将这个位置放的更加合理。
this->setposition(point(m_col *Game_Tiled_with+Game_tiled_board_width*(m_col+ 1), m_row*Game_Tiled_height+Game_Tiled_Board_width*(M_row+1))));}
0 0
- 2048当中移动方法的写法
- Hibernate当中*.hbm.xml的写法
- UITableViewHeaderFooterView当中的方法
- netty当中的release方法
- asp.net web.config当中的配置标记写法
- LaTex语法学习-公式编辑当中空格的写法
- 存取Oracle当中扫描数据的方法
- MAC当中显示隐藏文件的方法
- svg当中g元素的变形方法
- javascrip当中删除节点的方法
- Openstack当中xvpvnc的连接方法
- OC当中字符串常用的方法
- OC当中常用的字符串方法
- 理解ThinkPHP当中的D方法
- ionic 开发当中,有一些常用的方法。
- java当中获取各个路径的方法
- ionic 开发当中,有一些常用的方法。
- Android开发当中常用的方法集锦
- snmputil 执行命令报 error on SnmpMgrRequest 40错误的解决办法
- 用C代码实现des加密算法
- blocksit.js绘制移动端瀑布流样式
- IOS7 IOS8 tableview分割线的不能顶左边的处理方式
- Java web把文本,绘图输出到浏览器
- 2048当中移动方法的写法
- 网站发展过程中的技术架构
- C++类中静态函数的构造
- Linux下使用git命令及github项目
- datagrid分页转换设置
- 测试网站负载能力工具
- 数字图像处理-算法学习
- listview去掉光晕,嵌套listview
- 杭电2841 Visible Trees(容斥原理第二题)