Mercurial > LightClone
view LightClone/Source/Core.h @ 0:7e3a0ae9c016
Initial commit
author | koryspansel <koryspansel@bendbroadband.com> |
---|---|
date | Wed, 07 Sep 2011 12:36:37 -0700 |
parents | |
children | 6f227dd9a94f |
line wrap: on
line source
/* * Core */ #ifndef __CORE_H__ #define __CORE_H__ #include <d3d9.h> #include <d3dx9.h> #ifdef _DEBUG #include <stdio.h> #define DEBUG_PRINT printf #else #define DEBUG_PRINT(...) #endif /* * int8 */ typedef signed char int8; /* * int16 */ typedef signed short int16; /* * int32 */ typedef signed int int32; /* * uint8 */ typedef unsigned char uint8; /* * uint16 */ typedef unsigned short uint16; /* * uint32 */ typedef unsigned int uint32; /* * ErrorCode */ typedef int32 ErrorCode; /* * Error */ enum { Error_Success = 0, Error_Fail = -1, }; /* * Action */ enum { Action_Default, Action_Complete, Action_Forward, Action_RotateCW, Action_RotateCCW, Action_Jump, Action_Light, Action_FunctionA, Action_FunctionB, //Action_FunctionC, Action_Count = 7, }; /* * Direction */ enum Direction { Direction_North, Direction_East, Direction_South, Direction_West, Direction_Count, }; /* * Tower */ enum { Tower_Normal, Tower_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; /* * MaximumFunctionLength */ const uint32 MaximumFunctionLength = 16; /* * MainFunctionLength */ const uint32 MainFunctionLength = 14; /* * 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; } /* * InterpolateDirection */ float InterpolateDirection(uint32 nStart, uint32 nEnd, float fParameter); #endif //__CORE_H__