collision.txt
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:4k
- case TANK_DIR_RIGHT:
- dest.x = MIN(start.x + step,G_SCREEN_WIDTH-G_TANK_WIDTH);
- if(dest.x == G_SCREEN_WIDTH-G_TANK_WIDTH)
- goto endTest;
- if((start.x&0x000f)==0 ||
- (((dest.x-1)^start.x)&0x0010) != 0)
- {
- corX = (dest.x+32)>>5;
- corY = start.y>>5;
- block1 = pBlocks[corY][corX];
- corY = MIN(corY+1,19);
- block2 = pBlocks[corY][corX];
- flag = start.y & 0x001f;
- if(dest.x & 0x0010)
- ret = ParseBlock32(&block1,&block2,BLOCK_DIR_RIGHT,
- flag,ptk->dwEquip);
- else
- ret = ParseBlock32(&block1,&block2,BLOCK_DIR_LEFT,
- flag,ptk->dwEquip);
- if(ret & COL_PASS)
- {
- land.x = dest.x;
- TestTankOnIce(ret&COL_ICE,ptk);
- }
- else
- land.x = dest.x & 0xfffffff0;
- }
- else
- land.x = dest.x;
- SetRect(&rect,start.x+G_TANK_WIDTH,start.y,dest.x+G_TANK_WIDTH,
- start.y+G_TANK_HEIGHT);
- objret = GetObjectsInRect(rect,dir,pvoid,G_TANK,0);
- if(objret)
- {
- if(objret == TEST_RET_TANK)
- object.x = ((LPTANKOBJECT)*pvoid)->Left-G_TANK_WIDTH;
- else if(objret == TEST_RET_BASE)
- object.x = posBase[(int)*pvoid].x-G_TANK_WIDTH;
- else
- object.x = ((LPBULLETOBJECT)*pvoid)->Left-G_BULLET_WIDTH;
- dest.x = MIN(land.x,object.x);
- }
- else
- dest.x = land.x;
- break;
- ////////////////////////////////////////////////////
- case TANK_DIR_LEFT:
- dest.x = MAX(start.x - step,0);
- if(dest.x == 0)
- goto endTest;
- if((((dest.x-1)^start.x)&0x0010)!=0)
- {
- corX = dest.x>>5;
- corY = start.y>>5;
- block1 = pBlocks[corY][corX];
- corY = MIN(corY+1,19);
- block2 = pBlocks[corY][corX];
- flag = start.y & 0x001f;
- if(dest.x & 0x0010)
- ret = ParseBlock32(&block1,&block2,BLOCK_DIR_RIGHT,
- flag,ptk->dwEquip);
- else
- ret = ParseBlock32(&block1,&block2,BLOCK_DIR_LEFT,
- flag,ptk->dwEquip);
- if(ret & COL_PASS)
- {
- land.x = dest.x;
- TestTankOnIce(ret&COL_ICE,ptk);
- }
- else
- land.x = start.x & 0xfffffff0;
- }
- else
- land.x = dest.x;
- SetRect(&rect,dest.x,start.y,start.x,start.y+G_TANK_HEIGHT);
- objret = GetObjectsInRect(rect,dir,pvoid,G_TANK,0);
- if(objret)
- {
- if(objret == TEST_RET_TANK)
- object.x = ((LPTANKOBJECT)*pvoid)->Left+G_TANK_WIDTH;
- else if(objret == TEST_RET_BASE)
- object.x = posBase[(int)*pvoid].x+G_TANK_WIDTH;
- else
- object.x = ((LPBULLETOBJECT)*pvoid)->Left+G_BULLET_WIDTH;
- dest.x = MAX(land.x,object.x);
- }
- else
- dest.x = land.x;
- break;
- ////////////////////////////////////////////////////
- case TANK_DIR_UP:
- dest.y = MAX(start.y - step,0);
- if(dest.y == 0)
- goto endTest;
- if((((dest.y-1)^start.y)&0x0010) != 0)
- {
- corX = start.x>>5;
- corY = dest.y>>5;
- block1 = pBlocks[corY][corX];
- corX = MIN(corX+1,19);
- block2 = pBlocks[corY][corX];
- flag = start.x & 0x001f;
- if(dest.y&0x0010)
- ret = ParseBlock32(&block1,&block2,BLOCK_DIR_DOWN,
- flag,ptk->dwEquip);
- else
- ret = ParseBlock32(&block1,&block2,BLOCK_DIR_UP,
- flag,ptk->dwEquip);
- if(ret & COL_PASS)
- {
- land.y = dest.y;
- TestTankOnIce(ret&COL_ICE,ptk);
- }
- else
- land.y = start.y & 0xfffffff0;
- }
- else
- land.y = dest.y;
- SetRect(&rect,start.x,dest.y,start.x+G_TANK_WIDTH,start.y);
- objret = GetObjectsInRect(rect,dir,pvoid,G_TANK,0);
- if(objret)
- {
- if(objret == TEST_RET_TANK)
- object.y = ((LPTANKOBJECT)*pvoid)->Top+G_TANK_HEIGHT;
- else if(objret == TEST_RET_BASE)
- object.y = posBase[(int)*pvoid].y+G_TANK_HEIGHT;
- else
- object.y = ((LPBULLETOBJECT)*pvoid)->Top+G_BULLET_HEIGHT;
- dest.y = MAX(land.y,object.y);
- }
- else
- dest.y = land.y;
- break;