collision.txt
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:4k
源码类别:

游戏

开发平台:

Visual C++

  1. case TANK_DIR_RIGHT:
  2. dest.x = MIN(start.x + step,G_SCREEN_WIDTH-G_TANK_WIDTH);
  3. if(dest.x == G_SCREEN_WIDTH-G_TANK_WIDTH)
  4. goto endTest;
  5. if((start.x&0x000f)==0 || 
  6. (((dest.x-1)^start.x)&0x0010) != 0)
  7. {
  8. corX = (dest.x+32)>>5;
  9. corY = start.y>>5;
  10. block1 = pBlocks[corY][corX];
  11. corY = MIN(corY+1,19);
  12. block2 = pBlocks[corY][corX];
  13. flag = start.y & 0x001f;
  14. if(dest.x & 0x0010)
  15. ret = ParseBlock32(&block1,&block2,BLOCK_DIR_RIGHT,
  16. flag,ptk->dwEquip);
  17. else
  18. ret = ParseBlock32(&block1,&block2,BLOCK_DIR_LEFT,
  19. flag,ptk->dwEquip);
  20. if(ret & COL_PASS)
  21. {
  22. land.x = dest.x;
  23. TestTankOnIce(ret&COL_ICE,ptk);
  24. }
  25. else
  26. land.x = dest.x & 0xfffffff0;
  27. }
  28. else
  29. land.x = dest.x;
  30. SetRect(&rect,start.x+G_TANK_WIDTH,start.y,dest.x+G_TANK_WIDTH,
  31. start.y+G_TANK_HEIGHT);
  32. objret = GetObjectsInRect(rect,dir,pvoid,G_TANK,0);
  33. if(objret)
  34. {
  35. if(objret == TEST_RET_TANK)
  36. object.x = ((LPTANKOBJECT)*pvoid)->Left-G_TANK_WIDTH;
  37. else if(objret == TEST_RET_BASE)
  38. object.x = posBase[(int)*pvoid].x-G_TANK_WIDTH;
  39. else
  40. object.x = ((LPBULLETOBJECT)*pvoid)->Left-G_BULLET_WIDTH;
  41. dest.x = MIN(land.x,object.x);
  42. }
  43. else
  44. dest.x = land.x;
  45. break;
  46. ////////////////////////////////////////////////////
  47. case TANK_DIR_LEFT:
  48. dest.x = MAX(start.x - step,0);
  49. if(dest.x == 0)
  50. goto endTest;
  51. if((((dest.x-1)^start.x)&0x0010)!=0)
  52. {
  53. corX = dest.x>>5;
  54. corY = start.y>>5;
  55. block1 = pBlocks[corY][corX];
  56. corY = MIN(corY+1,19);
  57. block2 = pBlocks[corY][corX];
  58. flag = start.y & 0x001f;
  59. if(dest.x & 0x0010)
  60. ret = ParseBlock32(&block1,&block2,BLOCK_DIR_RIGHT,
  61. flag,ptk->dwEquip);
  62. else
  63. ret = ParseBlock32(&block1,&block2,BLOCK_DIR_LEFT,
  64. flag,ptk->dwEquip);
  65. if(ret & COL_PASS)
  66. {
  67. land.x = dest.x;
  68. TestTankOnIce(ret&COL_ICE,ptk);
  69. }
  70. else
  71. land.x = start.x & 0xfffffff0;
  72. }
  73. else
  74. land.x = dest.x;
  75. SetRect(&rect,dest.x,start.y,start.x,start.y+G_TANK_HEIGHT);
  76. objret = GetObjectsInRect(rect,dir,pvoid,G_TANK,0);
  77. if(objret)
  78. {
  79. if(objret == TEST_RET_TANK)
  80. object.x = ((LPTANKOBJECT)*pvoid)->Left+G_TANK_WIDTH;
  81. else if(objret == TEST_RET_BASE)
  82. object.x = posBase[(int)*pvoid].x+G_TANK_WIDTH;
  83. else
  84. object.x = ((LPBULLETOBJECT)*pvoid)->Left+G_BULLET_WIDTH;
  85. dest.x = MAX(land.x,object.x);
  86. }
  87. else
  88. dest.x = land.x;
  89. break;
  90. ////////////////////////////////////////////////////
  91. case TANK_DIR_UP:
  92. dest.y  = MAX(start.y - step,0);
  93. if(dest.y == 0)
  94. goto endTest;
  95. if((((dest.y-1)^start.y)&0x0010) != 0)
  96. {
  97. corX = start.x>>5;
  98. corY = dest.y>>5;
  99. block1 = pBlocks[corY][corX];
  100. corX = MIN(corX+1,19);
  101. block2 = pBlocks[corY][corX];
  102. flag = start.x & 0x001f;
  103. if(dest.y&0x0010)
  104. ret = ParseBlock32(&block1,&block2,BLOCK_DIR_DOWN,
  105. flag,ptk->dwEquip);
  106. else
  107. ret = ParseBlock32(&block1,&block2,BLOCK_DIR_UP,
  108. flag,ptk->dwEquip);
  109. if(ret & COL_PASS)
  110. {
  111. land.y = dest.y;
  112. TestTankOnIce(ret&COL_ICE,ptk);
  113. }
  114. else
  115. land.y = start.y & 0xfffffff0;
  116. }
  117. else
  118. land.y = dest.y;
  119. SetRect(&rect,start.x,dest.y,start.x+G_TANK_WIDTH,start.y);
  120. objret = GetObjectsInRect(rect,dir,pvoid,G_TANK,0);
  121. if(objret)
  122. {
  123. if(objret == TEST_RET_TANK)
  124. object.y = ((LPTANKOBJECT)*pvoid)->Top+G_TANK_HEIGHT;
  125. else if(objret == TEST_RET_BASE)
  126. object.y = posBase[(int)*pvoid].y+G_TANK_HEIGHT;
  127. else
  128. object.y = ((LPBULLETOBJECT)*pvoid)->Top+G_BULLET_HEIGHT;
  129. dest.y = MAX(land.y,object.y);
  130. }
  131. else
  132. dest.y = land.y;
  133. break;