GAMEUTIL.H 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*******************************************************************************
  2. FILE: GAMEUTIL.H
  3. DESCRIPTION: This header file contains prototypes and inline
  4. declarations for utilities functions dealing with the
  5. BUILD engine.
  6. AUTHOR: Peter M. Freese
  7. CREATED: 07-08-95
  8. COPYRIGHT: Copyright (c) 1995 Q Studios Corporation
  9. *******************************************************************************/
  10. #ifndef __GAMEUTIL_H
  11. #define __GAMEUTIL_H
  12. #include "engine.h"
  13. #include "typedefs.h"
  14. struct POINT2D
  15. {
  16. int x, y;
  17. };
  18. struct VECTOR2D
  19. {
  20. int dx, dy;
  21. };
  22. struct POINT3D
  23. {
  24. int x, y, z;
  25. };
  26. struct VECTOR3D
  27. {
  28. long dx, dy, dz;
  29. };
  30. struct HITINFO {
  31. short hitsect;
  32. short hitwall;
  33. short hitsprite;
  34. long hitx;
  35. long hity;
  36. long hitz;
  37. };
  38. /***********************************************************************
  39. * Inline functions
  40. **********************************************************************/
  41. // Euclidean 3D distance
  42. inline int Dist3d(int dx, int dy, int dz)
  43. {
  44. dx >>= 4;
  45. dy >>= 4;
  46. dz >>= 8;
  47. return ksqrt(dx * dx + dy * dy + dz * dz);
  48. }
  49. /***********************************************************************
  50. * GetSpriteExtents()
  51. *
  52. * Report the vertical size of a sprite in z units (works for all
  53. * sprite types)
  54. **********************************************************************/
  55. inline void GetSpriteExtents( SPRITE *pSprite, int *zTop, int *zBot )
  56. {
  57. *zTop = *zBot = pSprite->z;
  58. if ( (pSprite->cstat & kSpriteRMask) == kSpriteFloor )
  59. return;
  60. int nTile = pSprite->picnum;
  61. *zTop -= (picanm[nTile].ycenter + tilesizy[nTile] / 2) * (pSprite->yrepeat << 2);
  62. *zBot += (tilesizy[nTile] - (tilesizy[nTile] / 2 + picanm[nTile].ycenter)) * (pSprite->yrepeat << 2);
  63. }
  64. BOOL AreSectorsNeighbors(int sect1, int sect2);
  65. BOOL FindSector(int x, int y, int z, short *nSector);
  66. void CalcFrameRate( void );
  67. BOOL CheckProximity( SPRITE *pSprite, int x, int y, int z, int nSector, int dist );
  68. int GetWallAngle( int nWall );
  69. void GetWallNormal( int nWall, int *nx, int *ny );
  70. int HitScan( SPRITE *pSprite, int startZ, int dx, int dy, int dz, HITINFO *hitInfo );
  71. int VectorScan( SPRITE *pSprite, int z, int dx, int dy, int dz, HITINFO *hitInfo );
  72. void GetZRange( SPRITE *pSprite, long *ceilZ, long *ceilHit, long *floorZ, long *floorHit,
  73. int clipdist, char cliptype );
  74. unsigned ClipMove( long *px, long *py, long *pz, short *pnSector, long dx, long dy,
  75. int wallDist, int ceilDist, int floorDist, char clipType );
  76. #endif