constants.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef _constants_h
  2. #define _constants_h
  3. #define PB_CONSTEXPR constexpr
  4. #define PI 3.14159265358979323846
  5. // Key pinout
  6. #define USE_INPUT_PULLUP
  7. #define K_LEFT 6
  8. #define K_RIGHT 7
  9. #define K_UP 8
  10. #define K_DOWN 3
  11. #define K_FIRE 10
  12. // SNES Controller
  13. // uncomment following line to enable snes controller support
  14. // #define SNES_CONTROLLER
  15. const uint8_t DATA_CLOCK = 11;
  16. const uint8_t DATA_LATCH = 12;
  17. const uint8_t DATA_SERIAL = 13;
  18. // Sound
  19. const uint8_t SOUND_PIN = 9; // do not change, belongs to used timer
  20. // GFX settings
  21. #define OPTIMIZE_SSD1306 // Optimizations for SSD1366 displays
  22. #define FRAME_TIME 66.666666 // Desired time per frame in ms (66.666666 is ~15 fps)
  23. #define RES_DIVIDER 2
  24. /* Higher values will result in lower horizontal resolution when rasterize and lower process and memory usage
  25. Lower will require more process and memory, but looks nicer
  26. */
  27. #define Z_RES_DIVIDER 2 // Zbuffer resolution divider. We sacrifice resolution to save memory
  28. #define DISTANCE_MULTIPLIER 20
  29. /* Distances are stored as uint8_t, multiplying the distance we can obtain more precision taking care
  30. of keep numbers inside the type range. Max is 256 / MAX_RENDER_DEPTH
  31. */
  32. #define MAX_RENDER_DEPTH 12
  33. #define MAX_SPRITE_DEPTH 8
  34. #define ZBUFFER_SIZE SCREEN_WIDTH / Z_RES_DIVIDER
  35. // Level
  36. #define LEVEL_WIDTH_BASE 6
  37. #define LEVEL_WIDTH (1 << LEVEL_WIDTH_BASE)
  38. #define LEVEL_HEIGHT 57
  39. #define LEVEL_SIZE LEVEL_WIDTH / 2 * LEVEL_HEIGHT
  40. // scenes
  41. #define INTRO 0
  42. #define GAME_PLAY 1
  43. // Game
  44. #define GUN_TARGET_POS 18
  45. #define GUN_SHOT_POS GUN_TARGET_POS + 4
  46. #define ROT_SPEED .12
  47. #define MOV_SPEED .2
  48. #define MOV_SPEED_INV 5 // 1 / MOV_SPEED
  49. #define JOGGING_SPEED .005
  50. #define ENEMY_SPEED .02
  51. #define FIREBALL_SPEED .2
  52. #define FIREBALL_ANGLES 45 // Num of angles per PI
  53. #define MAX_ENTITIES 10 // Max num of active entities
  54. #define MAX_STATIC_ENTITIES 28 // Max num of entities in sleep mode
  55. #define MAX_ENTITY_DISTANCE 200 // * DISTANCE_MULTIPLIER
  56. #define MAX_ENEMY_VIEW 80 // * DISTANCE_MULTIPLIER
  57. #define ITEM_COLLIDER_DIST 6 // * DISTANCE_MULTIPLIER
  58. #define ENEMY_COLLIDER_DIST 4 // * DISTANCE_MULTIPLIER
  59. #define FIREBALL_COLLIDER_DIST 2 // * DISTANCE_MULTIPLIER
  60. #define ENEMY_MELEE_DIST 6 // * DISTANCE_MULTIPLIER
  61. #define WALL_COLLIDER_DIST .2
  62. #define ENEMY_MELEE_DAMAGE 8
  63. #define ENEMY_FIREBALL_DAMAGE 20
  64. #define GUN_MAX_DAMAGE 20
  65. // display
  66. const uint8_t SCREEN_WIDTH = 128;
  67. const uint8_t SCREEN_HEIGHT = 64;
  68. const uint8_t HALF_WIDTH = SCREEN_WIDTH / 2;
  69. const uint8_t RENDER_HEIGHT = 56; // raycaster working height (the rest is for the hud)
  70. const uint8_t HALF_HEIGHT = SCREEN_HEIGHT / 2;
  71. #endif