1. // Beginning Game Programming, 2nd Edition
  2. // Chapter 8
  3. // Tiled_Sprite program header file
  4.  
  5.  
  6. #ifndef GAME_H
  7. #define GAME_H
  8.  
  9. #ifndef DIRECTINPUT_VERSION
  10.     #define DIRECTINPUT_VERSION 0x0800
  11. #endif
  12.  
  13. //windows/directx headers
  14. #include <d3d9.h>
  15. #include <d3dx9.h>
  16. #include <d3dx9math.h>
  17. #include <dxerr9.h>
  18. #include <dsound.h>
  19. #include <dinput.h>
  20. #include <windows.h>
  21. #include <time.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24.  
  25. #include <string>
  26. #include <iostream>
  27. #include <iomanip>
  28. #include <fstream>
  29. #include <assert.h>
  30. #include <sstream>
  31. using namespace std;
  32.  
  33. //framework-specific headers
  34.  
  35. #include "dxaudio.h"
  36. #include "dxinput.h"
  37. #include "dxgraphics.h"
  38. #include "csprite.h"
  39.  
  40. // misc utility functions
  41. #include "util.h"
  42.  
  43. /* ------ DEFINE(s) ------ */
  44.  
  45. //application title
  46. #define APPTITLE "Yaskus - Game AI example"
  47.  
  48. #define DEBUG_ON false
  49. #define _DEBUG 1
  50.  
  51. //Window setup
  52. #define FULLSCREEN 0       //0 = windowed, 1 = fullscreen
  53. #define WINDOW_WIDTH  640
  54. #define WINDOW_HEIGHT 640
  55.  
  56. // tile info
  57. #define TILEWIDTH  32
  58. #define TILEHEIGHT 32      
  59. #define BACK_PER_ROW 6  // number of brackground tiles per row
  60.  
  61. // map
  62. #define MAPWIDTH   20
  63. #define MAPHEIGHT  20 //  768 / 16 = 48
  64. #define GAMEWORLDWIDTH  (TILEWIDTH * MAPWIDTH)
  65. #define GAMEWORLDHEIGHT (TILEHEIGHT * MAPHEIGHT)
  66.  
  67. // scrolling window size
  68. #define WINDOWWIDTH  (WINDOW_WIDTH / TILEWIDTH)   * TILEWIDTH
  69. #define WINDOWHEIGHT (WINDOW_HEIGHT / TILEHEIGHT) * TILEHEIGHT
  70.  
  71. // Path finding
  72. #define MAX_PATHS (MAPWIDTH * MAPHEIGHT)
  73.  
  74. // Enemy AIs
  75. #define NUM_ENEMY 4
  76.  
  77. /* --------- STRUCTURES ------------- */
  78. struct listType
  79. {
  80.      int x;
  81.      int y;
  82.      int cnt;
  83. };
  84.  
  85. struct SCOREtype
  86. {
  87.      int deaths;
  88.      int carrots;
  89. } ;
  90.  
  91.  
  92. /* ------ function prototypes ------ */
  93.  int Game_Init(HWND);
  94. void Game_Run(HWND);
  95. void Game_End(HWND);
  96.  
  97. // dynamic scrolling map support functions
  98. void DrawSprite(LPDIRECT3DTEXTURE9, int,int,int,int, int, int);
  99. void DrawTilesBack();
  100. void DrawSprites();
  101.  
  102. // roll dice
  103. int rollDice(int , int);
  104.  
  105. // for drawing text and numbers using DX font
  106. void drawText(string outText, int windowX, int windowY);
  107.  
  108. // used for debug purposes, writing numbers to Window
  109. // draw numbers to Window
  110. void drawNumbers(int number, int windowX, int windowY);
  111.  
  112. // returns the value at map location
  113. int getMap( int x, int y);
  114.  
  115. // executes the AI code, for pathfinding and such
  116. void checkAI();
  117.  
  118. template<class T>
  119.     std::string toString(const T& t)
  120. {
  121.      std::ostringstream stream;
  122.      stream << t;
  123.      return stream.str();
  124. }
  125.  
  126. #endif