-
Notifications
You must be signed in to change notification settings - Fork 0
/
dxManager.h
218 lines (164 loc) · 5.63 KB
/
dxManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/************************************************************************************
* DirectX 10 Manager Class
* ----------------------------------------
* code by : bobby anguelov - [email protected]
* downloaded from : takinginitiative.wordpress.org
*
* code is free for use in whatever way you want, however if you work for a game
* development firm you are obliged to offer me a job :P (haha i wish)
************************************************************************************/
#ifndef DXMANAGER
#define DXMANAGER
#include <iostream>
#include <fstream>
#include <windows.h>
#include <d3d10.h>
#include <d3dx10.h>
#include <map>
#include "Globals.h"
#include "Camera.h"
#include "Trap.h"
#include <vector>
#include "CheckPointManager.h"
using namespace std;
class Wall;
//create a basic vertex container
struct vertex
{
D3DXVECTOR3 pos;
D3DXVECTOR4 color;
vertex( D3DXVECTOR3 p, D3DXVECTOR4 c )
{
pos = p;
color = c;
}
};
// Lets us determine the current state of the game
enum GameState
{
StartMenu, TMenu, IMenu, Overview, PlayingGame, Lobby, ControllerSelect, Paused, GameOver, Exit
};
// Lets us determine which menu Item is selected
enum MenuSelector
{
PlayGame, BestTimes, Instructions, Menu, OnePlayer, TwoPlayer
};
class dxManager
{
/*******************************************************************
* Members
********************************************************************/
private:
//window handle
HWND* hWnd;
//device vars
ID3D10Device* pD3DDevice;
IDXGISwapChain* pSwapChain;
ID3D10RenderTargetView* pRenderTargetView;
D3D10_VIEWPORT viewPort;
ID3D10RasterizerState* pRS;
//input layout and vertex buffer
ID3D10Buffer* pVertexBuffer;
ID3D10InputLayout* pVertexLayout;
//effects and techniques
ID3D10Effect* pBasicEffect;
ID3D10EffectTechnique* pBasicTechnique;
//effect variable pointers
ID3D10EffectMatrixVariable* pViewMatrixEffectVariable;
ID3D10EffectMatrixVariable* pProjectionMatrixEffectVariable;
ID3D10EffectMatrixVariable* pWorldMatrixEffectVariable;
//projection and view matrices
D3DXMATRIX viewMatrix;
//D3DXMATRIX projectionMatrix;
D3DXMATRIX orthoMatrix;
//font variable
ID3DX10Font *d3dxFont;
RECT fontPosition;
//WCHAR* windowText;
LPCSTR preTextSix;
LPCSTR textSix;
// sprite information
//ID3D10ShaderResourceView** textures;
//ID3DX10Sprite** sprites;
SimpleSprite** sSprites; //array of simple sprites
int numSprites; //number of sprites loaded in
int numActors; //number of actors created
int numTraps; //number of traps created
int numMenuSprites; // number of menu items created
int numInstructSprites; // number of Instruction menu pics
int playerIndex; //where in the sprite list the player is
int frameCount; // frame rate of the program
IActor** actors; //array of actors
list<ICollidable*> walls; //array of walls
vector<Trap*> traps; //array of traps
SimpleSprite** menuSprites; // array of sprites in the menu
SimpleSprite** instructPicSprites; // array of sprites the instructions menu uses
/*******************************************************************
* Methods
********************************************************************/
void drawBestTimesText(void);
public:
//constructor and destructor
dxManager();
~dxManager();
//initialize directx device
bool initialize(HWND*, float, float);
void toggleFullscreen();
// lets us exit the program while in fullscreen
void exitProgram();
void cleanup();
int NumSprites();
int NumActors();
int NumTraps();
int NumMenuSprites();
int PlayerIndex();
SimpleSprite* getSprite(int index);
SimpleSprite* getMenuSprite(int index);
HRESULT MakeSprite(WCHAR* textureName, SimpleSprite** sprite);
HRESULT MakeSprite(WCHAR* textureName);
HRESULT MakeMenuSprite(WCHAR* textureName, SimpleSprite** sprite, SpriteType type);
HRESULT MakeInstructSprite(WCHAR* textureName, SimpleSprite** sprite, SpriteType type);
// uses a txt file which is passed in as a param and loads the pics listed
void loadPicsFromTextFile(char* fileName);
void setFrame(int fCnt);
//renderScene
void renderScene();
//actor code which was moved into dxManager instead of the main class
void initializeActors();
void addActor(IActor* actor);
void updateActor(int index, float timePassed);
void updateTrap(int index, float timePassed);
IActor* getActor(int index);
list<ICollidable*>* GetWalls();
vector<Trap*>* GetTraps();
void AddWall(ICollidable* wall);
void AddTrap(Trap* wall);
void clearActors();
void clearSprites();
Texture* getTexture(WCHAR* name);
ID3D10Device* getPD3DDevice();
GameState* gameState;
int* winningPlayer;
int* numOfPlayers;
string* winnerName;
// info used in displaying best times
string* bestTimesNames;
float* bestTimesNum;
int bestTimesCount;
float gameTime; // how long the game has been running
char** instructTips;
int currentInstructPage;
int numOfInstructPages;
int numControllersSelected;
float adjustX;
float adjustY;
CheckPointManager* cpm; //deal with the checkpoint system using this
void KillPlayer(PlayerActor* p, int pnumber);
private:
// this is also stored in the main class, but DX also needs a reference
TextureManager* textures;
void drawText(LPCSTR, int, int);
//fatal error handler
bool fatalError(LPCWSTR msg);
};
#endif