GS测试DEMO---连连看
来源:互联网 发布:戈尔巴乔夫知乎 编辑:程序博客网 时间:2024/04/30 11:21
今天有空,写了一个测试程序,通过此程序,发现并修正了几个错误:
1、[修正]后缀自增、自减计算错误
2、[修正]浮点数求余错误,更改为:所有浮点数转为整数再求余,结果为整数。
3、[增加]内置函数 mod 浮点数求模
4、[增加]内置函数 StrFormat 字符串格式化
连连看检查两点之间是否可连接的核心算法(GScript 源码)
protected bool CheckMatch(int x1, int y1, int x2, int y2)//检查两点之间是否可到达,重要的逻辑函数 { ArrayClear(this.arTraceMatch); if(this.SimpleMatch(x1, y1, x2, y2) || this.LineMatch(x1, y1, x2, y2)) { this.arTraceMatch[]=["x":x1*BMP_WIDTH+DRAW_LEFT+BMP_WIDTH/2,"y":y1*BMP_HEIGHT+DRAW_TOP+BMP_HEIGHT/2]; this.arTraceMatch[]=["x":x2*BMP_WIDTH+DRAW_LEFT+BMP_WIDTH/2,"y":y2*BMP_HEIGHT+DRAW_TOP+BMP_HEIGHT/2]; return true; } else { int cornerX,cornerY; if(this.OneCornerMatch(x1, y1, x2, y2,cornerX,cornerY)) { this.arTraceMatch[]=["x":x1*BMP_WIDTH+DRAW_LEFT+BMP_WIDTH/2,"y":y1*BMP_HEIGHT+DRAW_TOP+BMP_HEIGHT/2]; this.arTraceMatch[]=["x":cornerX*BMP_WIDTH+DRAW_LEFT+BMP_WIDTH/2,"y":cornerY*BMP_HEIGHT+DRAW_TOP+BMP_HEIGHT/2]; this.arTraceMatch[]=["x":x2*BMP_WIDTH+DRAW_LEFT+BMP_WIDTH/2,"y":y2*BMP_HEIGHT+DRAW_TOP+BMP_HEIGHT/2]; return true; } else { int cornerX2,cornerY2; if(this.TwoCornerMatch(x1, y1, x2, y2,cornerX,cornerY,cornerX2,cornerY2)) { this.arTraceMatch[]=["x":x1*BMP_WIDTH+DRAW_LEFT+BMP_WIDTH/2,"y":y1*BMP_HEIGHT+DRAW_TOP+BMP_HEIGHT/2]; this.arTraceMatch[]=["x":cornerX*BMP_WIDTH+DRAW_LEFT+BMP_WIDTH/2,"y":cornerY*BMP_HEIGHT+DRAW_TOP+BMP_HEIGHT/2]; this.arTraceMatch[]=["x":cornerX2*BMP_WIDTH+DRAW_LEFT+BMP_WIDTH/2,"y":cornerY2*BMP_HEIGHT+DRAW_TOP+BMP_HEIGHT/2]; this.arTraceMatch[]=["x":x2*BMP_WIDTH+DRAW_LEFT+BMP_WIDTH/2,"y":y2*BMP_HEIGHT+DRAW_TOP+BMP_HEIGHT/2]; return true; } } } return false; } protected bool SimpleMatch(int x1, int y1, int x2, int y2) { if((x1==x2)) return (Abs(y2-y1)==1); else if((y1==y2)) return (Abs(x2-x1)==1); return false; } protected bool LineMatch(int x1, int y1, int x2, int y2) { if (! ( x1==x2 || y1 == y2 ) ) return false ; if( x1==x2) { if( y1 > y2 ) { int nItem=(y1-1)* VIRTUAL_LINE+x1; for(int i=y1-1 ; i>y2 ; --i) { if((this.Map[nItem]&0x3)!=ITEM_DEATH) return false; nItem-=VIRTUAL_LINE; } } else { int nItem=(y2-1)* VIRTUAL_LINE+x2; for(int i=y2-1 ; i>y1 ; --i) { if((this.Map[nItem]&0x3)!=ITEM_DEATH) return false; nItem-=VIRTUAL_LINE; } } } else { if( x1>x2) { int nItem=y1* VIRTUAL_LINE+(x1-1); for(int i = x1 - 1 ; i>x2 ; --i ) { if((this.Map[nItem--]&0x3)!=ITEM_DEATH) return false; } } else { int nItem=y2* VIRTUAL_LINE+(x2-1); for(int i =x2 -1 ; i>x1 ; --i ) { if((this.Map[nItem--]&0x3)!=ITEM_DEATH) return false; } } } return true ; } protected bool OneCornerMatch(int x1, int y1, int x2, int y2,int& cornerX,int& cornerY) { int nItem=y2* VIRTUAL_LINE+x1; if(((this.Map[nItem]&0x3)==ITEM_DEATH) && this.LineMatch(x1,y1,x1,y2) && this.LineMatch(x2,y2,x1,y2)) { cornerX=x1; cornerY=y2; return true ; } int nItem=y1* VIRTUAL_LINE+x2; if(((this.Map[nItem]&0x3)==ITEM_DEATH) && this.LineMatch(x1,y1,x2,y1) && this.LineMatch(x2,y2,x2,y1)) { cornerX=x2; cornerY=y1; return true ; } return false ; } protected bool TwoCornerMatch( int x1, int y1, int x2, int y2,int& cornerX,int& cornerY,int& cornerX2,int& cornerY2) { int nItem=y1* VIRTUAL_LINE+(x1 -1); for( int i=x1 -1 ; i>=0 ; --i ) { if((this.Map[nItem--]&0x3)!=ITEM_DEATH) break; else if( this.OneCornerMatch( i,y1 , x2, y2,cornerX2,cornerY2) ) { cornerX=i; cornerY=y1; return true ; } } int nItem=y1* VIRTUAL_LINE+(x1 +1); for(int i = x1 +1 ; i<VIRTUAL_LINE ; ++i ) { if((this.Map[nItem++]&0x3)!=ITEM_DEATH) break; else if( this.OneCornerMatch(i,y1 , x2, y2 ,cornerX2,cornerY2) ) { cornerX=i; cornerY=y1; return true ; } } int nItem=(y1-1)* VIRTUAL_LINE+x1; for( int i = y1 - 1 ; i>=0 ; --i ) { if((this.Map[nItem]&0x3)!=ITEM_DEATH) break; else if( this.OneCornerMatch( x1,i ,x2, y2,cornerX2,cornerY2) ) { cornerX=x1; cornerY=i; return true ; } nItem-=VIRTUAL_LINE; } int nItem=(y1+1)* VIRTUAL_LINE+x1; for( i = y1 + 1 ; i< VIRTUAL_ROW ; ++i ) { if((this.Map[nItem]&0x3)!=ITEM_DEATH) break; else if( this.OneCornerMatch( x1,i ,x2, y2,cornerX2,cornerY2) ) { cornerX=x1; cornerY=i; return true ; } nItem+=VIRTUAL_LINE; } return false ; }
最后上几张Demo图片
- GS测试DEMO---连连看
- 自动化测试 (二) 连连看外挂
- 自动化测试 (二) 连连看外挂
- code4app的cocos2d连连看demo源代码笔记
- 关于《连连看》的算法研究和演示Demo
- 连连看
- 连连看.
- 连连看
- 连连看
- 连连看
- 连连看
- 连连看
- 连连看
- 连连看
- 连连看
- 连连看
- 连连看
- 连连看
- android UI进阶之弹窗的使用(2)--实现通讯录的弹窗效果
- 网易游戏2011.10.15校园招聘会笔试题
- 预报天气那是相当不准
- Android low memory killer 详解
- 如何修改MFC界面风格
- GS测试DEMO---连连看
- java中遍历properties属性文件的方法
- 搭建hbase
- 实现复选框的全选与反选
- apache POI导出excel文件 及单元格合并 、样式的设置
- 关于vs2010中小插件VAssistX的卸载
- java操作excel
- 关于mfc CSplitterWnd的几点理解
- 装配线调度(动态规划)