Mercurial > LightClone
view LightClone/Source/Core.h @ 67:8e7ebab350e7
Clean up memory leaks
author | koryspansel |
---|---|
date | Fri, 07 Oct 2011 01:15:28 -0700 |
parents | 1fe27776627e |
children | 40c0b5305de8 |
line wrap: on
line source
/* * Core */ #ifndef __CORE_H__ #define __CORE_H__ #define CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #include "Types.h" #include "Trace.h" #include "Debug.h" #include <d3d9.h> #include <d3dx9.h> #include <windows.h> #include <tchar.h> /* * WorldState */ enum { WorldState_Main, WorldState_Game, WorldState_Pause, WorldState_Help, WorldState_Confirm, WorldState_Exit, }; /* * LogicState */ enum { LogicState_LevelLoad, LogicState_LevelComplete, LogicState_GameActive, LogicState_GameOver, }; /* * SimulationState */ enum { SimulationState_Idle, SimulationState_Active, }; /* * Action */ enum { Action_None, Action_Forward, Action_RotateCW, Action_RotateCCW, Action_Jump, Action_Light, Action_FunctionA, Action_FunctionB, Action_Complete, Action_Count = 7, }; /* * Direction */ enum Direction { Direction_North, Direction_East, Direction_South, Direction_West, Direction_Count, }; /* * TowerType */ enum { TowerType_Normal, TowerType_Light, }; /* * ScreenSizeX */ const uint32 ScreenSizeX = 1280; /* * ScreenSizeY */ const uint32 ScreenSizeY = 720; /* * FacesPerCube */ const uint32 FacesPerCube = 6; /* * TrianglesPerFace */ const uint32 TrianglesPerFace = 2; /* * VerticesPerTriangle */ const uint32 VerticesPerTriangle = 3; /* * TrianglesPerBlock */ const uint32 TrianglesPerBlock = FacesPerCube * TrianglesPerFace; /* * VerticesPerBlock */ const uint32 VerticesPerBlock = FacesPerCube * TrianglesPerFace * VerticesPerTriangle; /* * MaximumFunctionCount */ const uint32 MaximumFunctionCount = 3; /* * MaximumInstructionCount */ const uint32 MaximumInstructionCount = 16; /* * Position * Represents the position of an object on a grid */ struct Position { /* * X */ uint32 X; /* * Y */ uint32 Y; }; /* * Size */ struct Size { /* * X */ uint32 X; /* * Y */ uint32 Y; }; /* * Rectangle2 */ struct Rectangle2 { /* * X */ float X; /* * Y */ float Y; /* * Width */ float Width; /* * Height */ float Height; public: /* * Rectangle2 */ Rectangle2() : X(0.0f), Y(0.0f), Width(0.0f), Height(0.0f) { } /* * Rectangle2 */ Rectangle2(float fX, float fY, float fWidth, float fHeight) : X(fX), Y(fY), Width(fWidth), Height(fHeight) { } /* * Contains */ bool Contains(float fX, float fY) { return (0.0f <= (fX - X) && (fX - X) < Width) && (0.0f <= (fY - Y) && (fY - Y) < Height); } }; /* * Min */ template<typename Type> inline Type Min(Type nValueA, Type nValueB) { return nValueB < nValueA ? nValueB : nValueA; } /* * Max */ template<typename Type> inline Type Max(Type nValueA, Type nValueB) { return nValueB > nValueA ? nValueB : nValueA; } /* * Clamp */ template<typename Type> inline Type Clamp(Type nValue, Type nMinimum, Type nMaximum) { return nValue < nMinimum ? nMinimum : nValue > nMaximum ? nMaximum : nValue; } /* * Abs */ template<typename Type> inline Type Abs(Type nValue) { return nValue < 0 ? -nValue : nValue; } /* * GetOffsetFromDirectionX */ int32 GetOffsetFromDirectionX(uint32 nDirection); /* * GetOffsetFromDirectionY */ int32 GetOffsetFromDirectionY(uint32 nDirection); /* * InterpolateDirection */ float InterpolateDirection(uint32 nStart, uint32 nEnd, float fParameter); /* * ComputePickRay */ void ComputePickRay(float fScreenX, float fScreenY, const D3DVIEWPORT9& kViewport, const D3DXMATRIX& kProjection, const D3DXMATRIX& kView, D3DXVECTOR3* pOrigin, D3DXVECTOR3* pDirection); /* * ComputeOrigin */ const D3DXVECTOR3 ComputeOrigin(float fScreenX, float fScreenY, const D3DVIEWPORT9& kViewport, const D3DXMATRIX& kProjection, const D3DXMATRIX& kView); #endif //__CORE_H__