Guest User

collide.h

a guest
May 12th, 2013
60
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2. #include "types.h"
  3.  
  4. // useful macro for encoding single bits
  5. #define BIT( X ) (1<<(X))
  6.  
  7. // map bit codes
  8. const uint8 cQUpper  = BIT( 0 ); // can push up
  9. const uint8 cQLower  = BIT( 1 ); // can push down
  10. const uint8 cQLeft   = BIT( 2 ); // can push left
  11. const uint8 cQRight  = BIT( 3 ); // can push right
  12. const uint8 cWall    = BIT( 7 ); // is a wall
  13.  
  14. //
  15. struct sCollideMap
  16. {
  17.     // map size and scale
  18.     uint32  width, height;
  19.     uint32  tileSize;
  20.     // tile data encoded as above
  21.     uint8  *data;
  22. };
  23.  
  24. //
  25. struct sCollideObject
  26. {
  27.     // rectangle area
  28.     sint32 x1, y1, x2, y2;
  29.     // resolution vector
  30.     sint32 r_x, r_y;
  31. };
  32.  
  33. // check for a collision between and object and the map
  34. extern bool collide_test
  35. (
  36.     sCollideMap    *map,
  37.     sCollideObject *object
  38. );
  39.  
  40. // preprocess a map with bit encoded gradients
  41. extern void collide_preprocess
  42. (
  43.     sCollideMap *map
  44. );
RAW Paste Data