Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <d3d9.h> // directx header files
- #include <d3dx9.h>
- #include <d3dx9mesh.h>
- #include <dinput.h>
- #include "dxdbg.h"
- #include "CMesh.h"
- #include "MP3.h"
- #include "bsp.h"
- using namespace std;
- class Game
- {
- public:
- ///////////////////////////////
- ////////////////////////////////////////////////////////
- //Preprocessor #defines
- ////////////////////////////////////////////////////////
- #define SZ_FILE_BSP "maze5.bsp" // Quake 3 Type BSP Level File
- #define _NUMOFMAPOBJECTS 10
- #define __NUMOFGAMETRIGGERS 3
- #define _TYPE_LANTERN 1
- #define _TYPE_AK47 2
- #define _TYPE_BODY 3
- #define _TYPE_CLIPBOARD 4
- ////////////////////////////////////////////////////////
- //Global DirectX Variables
- ////////////////////////////////////////////////////////
- static ID3DXEffect* g_pEffect;
- static ID3DXEffect* g_pEffectMesh;
- static LPDIRECTINPUT8 g_lpdi;
- static LPDIRECTINPUT8 pDI;
- static LPDIRECTINPUTDEVICE8 pMouse;
- static LPDIRECT3D9 g_pD3D;
- static LPDIRECT3DDEVICE9 g_pd3dDevice;
- static IDirect3DTexture9* cubetex;
- static IDirect3DTexture9* cubetex2;
- static IDirect3DTexture9* AKTex;
- static IDirect3DTexture9* clipboardTex;
- static IDirect3DTexture9* g_Inv_LanternTex;
- static IDirect3DTexture9* g_Inv_ClipboardTex;
- static IDirect3DTexture9* g_Inv_ClipboardTex2;
- static IDirect3DTexture9* flashlightTex;
- static D3DXVECTOR3 g_vCamPosition;
- static D3DXVECTOR3 g_vNewPosition;
- static D3DXVECTOR3 g_vCamDir;
- static D3DXVECTOR3 g_vBallPos;
- static D3DXVECTOR3 g_vNewBallPos;
- static D3DXVECTOR3 g_vNewMonsterPos;
- static D3DXVECTOR3 g_vMonsterPos;
- static D3DXVECTOR3 vMonsterDir;
- static D3DXVECTOR3 vTemp2;
- static D3DXVECTOR3 vHitWallPos2;
- static D3DXVECTOR3 vHitWallNormal2;
- static D3DXVECTOR3 vGunPosVar;
- static D3DXVECTOR3 vGunRotate;
- static D3DXVECTOR3 vGunPos;
- static D3DXVECTOR3 pNose;
- static D3DXMATRIX world, view, proj;
- static HWND g_hwnd;
- ////////////////////////////////////////////////////////
- //MP3 Class Globals
- ////////////////////////////////////////////////////////
- Mp3 static g_Mp3Horror1;
- Mp3 static g_Mp3Horror2;
- Mp3 static g_Mp3Horror3;
- Mp3 static g_Mp3Breathing;
- Mp3 static g_Mp3Roar;
- Mp3 static MP3PLAYER2;
- Mp3 static MP3PLAYER3;
- Mp3 static g_Mp3ClipBoard;
- ////////////////////////////////////////////////////////
- //Globals
- ////////////////////////////////////////////////////////
- static float fLengthFromMonster;
- static float g_fSpinX;
- static float g_fSpinY;
- static float g_fZoom;
- static float g_fLine;
- static float g_fHeight;
- static float fShipFloat;
- static float Start; // Linear fog distances
- static float End;
- static bool g_bWire;
- static bool g_bTopView;
- static bool g_bDrawShadowLevel;
- static bool g_bGravity; //gravity set to false for now
- static bool g_bShowMonster;
- static bool g_bDebugSphere;
- static bool g_bMonsterChase;
- static bool g_bShowConsole;
- static bool g_bPlayMusic;
- static bool g_bGunFire;
- static bool g_bGunPickedUp;
- static bool g_bMonsterChangeDir;
- static bool g_bShowClipBoard;
- static bool g_bClipboardShowed;
- static bool g_bShowSecondHint;
- static bool g_bTextShowed;
- static bool g_bWithinMonsterView;
- static bool g_bSurpriseDirChange;
- static bool g_bShowingDiary;
- static bool g_bShowedDiary;
- static bool g_bShowFlashlight;
- static bool g_bRunning;
- static bool g_bBallChangeDir;
- static int g_nTotalTris;
- static int g_nDrawnTris;
- static int g_iInvLanterns;
- static float fDensity;
- static float gunscale;
- static float rotconstant;
- static float fDistance;
- static float rotx;
- static float roty;
- static float xangle;
- static float yangle;
- static float LIGHT_RADIUS;
- static float LIGHT_SPOT_INNER_CONE;
- static float LIGHT_SPOT_OUTER_CONE;
- static bool g_bInitLoaded;
- static bool g_bLoadingThread;
- static bool g_bWaitingOnChange;
- static int iSongIndex;
- static bool g_bScarySoundPlayed;
- static bool g_bBreathingSoundPlayed;
- static bool g_bMonsterAwake;
- static bool g_bMonsterAwaking;
- static bool g_bMonsterAwoke;
- static float att0;
- static float att1;
- static float att2;
- static float falloff;
- static float g_sceneAmbient[4]; //init in constuctor
- static int width, height;
- static int g_iInvPages;
- static bool bIntro;
- static bool bCrazy;
- unsigned long static int iIndex;
- static bool bAssigned;
- static char g_ConsoleLog[100000];
- static int g_iNumofMeshes;
- static float fShipRotate;
- static clock_t clockTicksTaken;
- static clock_t endTime;
- static double timeInSeconds;
- std::clock_t start;
- static int starttime;
- static int g_iLightLevel;
- static clock_t firstTime;
- static clock_t firstTime2;
- static clock_t firstTimeHorror;
- ////////////////////////////////////////////////////////
- //Meshes
- ////////////////////////////////////////////////////////
- static CMesh m_mesh;
- static CMesh m_meshAK47;
- static CMesh m_meshDeadBody;
- static CMesh m_meshShip;
- static CMesh m_meshClipboard;
- static CMesh m_meshEyes;
- static CMesh m_meshTeapot;
- static CMesh m_meshLantern;
- static CMeshInstance* m_pMeshes;
- static CMeshInstance* m_pShip;
- static CMeshInstance* m_pMapMeshes;
- ////////////////////////////////////////////////////////
- //BSP Class Globals
- ////////////////////////////////////////////////////////
- static CBSP bsp;
- static CBSP lightbsp;
- ////////////////////////////////////////////////////////
- //Function Prototypes
- ////////////////////////////////////////////////////////
- D3DXVECTOR3 FindDirection(D3DXVECTOR3 *target, D3DXVECTOR3 *firer);
- void MovePlayer(CBSP * bsp,
- D3DXVECTOR3 * vStart,
- D3DXVECTOR3 * vEnd);
- void MoveMonster(CBSP * bsp,
- D3DXVECTOR3 * vStart,
- D3DXVECTOR3 * vEnd);
- void MoveBall(CBSP * bsp,
- D3DXVECTOR3 * vStart,
- D3DXVECTOR3 * vEnd);
- static int ObtainFPS();
- bool MonsterInView(CBSP *bsp, D3DXVECTOR3 *vEnd);
- static void FootSteps();
- static void ShowDiary();
- static void RenderLoading();
- static void CreateMouse();
- static void Mouse();
- static void ShowClipboard();
- static void Console(char buf[200]);
- static void ShowConsole();
- static void ShowDebugConsole();
- static void FlashLight();
- static void UpdateEffect();
- static bool LoadShader(const char *pszFilename, LPD3DXEFFECT &pEffect);
- static void SetupVertexFog(DWORD Color, DWORD Mode, BOOL UseRange, FLOAT Density);
- static void MouseActions2(int x, int y, int lmb, int rmb, int mmb);
- static void MonsterChase(CBSP *bsp);
- static void Gravity(CBSP *bsp);
- static void SetCameraTopView();
- static void SetCameraLevelView();
- static void RenderInventory();
- static void SetMaterial();
- static void RenderPosition();
- static void SetLight();
- static void ShowGameHints();
- static void RenderInfo();
- static void WakeMonster();
- static void ObjectPickup();
- static void BallMovement();
- static void PlayHorror();
- static void KeyBoard();
- static void PlayBreathing();
- static void PlayPaperSound();
- static void PlayScarySound();
- static bool LoadAll();
- static bool Release();
- ////////////////////////////////////////////////////////
- //Thread Function Prototypes
- ////////////////////////////////////////////////////////
- static DWORD WINAPI KeyBoardThread(LPVOID lpParam);
- static DWORD WINAPI RenderMeshes(LPVOID lpParam);
- static DWORD WINAPI BreathingSoundTimer(LPVOID lpParam);
- static DWORD WINAPI SurpiseDirChange(LPVOID lpParam);
- static DWORD WINAPI ScarySoundTimer(LPVOID lpParam);
- static DWORD WINAPI WakingTimer(LPVOID lpParam);
- static DWORD WINAPI SongTimer(LPVOID lpParam);
- static DWORD WINAPI GameHintsThread(LPVOID lpParam);
- static DWORD WINAPI TextTimer(LPVOID lpParam);
- static DWORD WINAPI LoadingThread(LPVOID lpParam);
- ////////////////////////////////////////////////////////
- //structs
- ////////////////////////////////////////////////////////
- struct Light
- {
- enum { DIR_LIGHT, POINT_LIGHT, SPOT_LIGHT };
- int type;
- float dir[3];
- float pos[3];
- float ambient[4];
- float diffuse[4];
- float specular[4];
- float spotInnerCone;
- float spotOuterCone;
- float radius;
- };
- struct Material
- {
- float ambient[4];
- float diffuse[4];
- float emissive[4];
- float specular[4];
- float shininess;
- };
- Light static g_light;//init in constuctor
- Material static g_material; //init in constuctor
- enum { DIR_LIGHT, POINT_LIGHT, SPOT_LIGHT };
- struct Vertex
- {
- float pos[3];
- float texCoord[2];
- float normal[3];
- };
- struct DebugConsole {
- char sData[5000];
- static bool bDisplayed;
- DebugConsole *next;
- };
- DebugConsole static *root; // This won't change, or we would lose the list in memory
- DebugConsole static *conductor; // This will point to each node as it traverses the list
- struct GameHintTrigger
- {
- static char sData[100];
- static bool bDisplayed;
- static bool bDisplay;
- };
- GameHintTrigger static GameHintTriggers[__NUMOFGAMETRIGGERS];
- struct GameHints
- {
- static char Data[200];
- static bool bDisplay;
- };
- GameHints static *GameHintsDisplay[3];
- class MapObject
- {
- public:
- CMeshInstance *pMapMesh;
- static bool pickedup;
- static float xpos, ypos, zpos; //Position of Map Object
- static int ObjType; //Type of Object i.e. _TYPE_LANTERN, gun, etc.
- MapObject::MapObject() {};
- MapObject::MapObject(int type, float x, float y, float z);
- static void MapObject::Render();
- };
- MapObject static *MapObjects[_NUMOFMAPOBJECTS];
- ////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////
- Game::Game();
- static bool CreateDX(HWND hWnd);
- static void Render();
- static void ShowMessage(char buff[500]) { MessageBoxA(NULL, buff, buff, MB_OK); }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement