| @@ -39,7 +39,7 @@ DebugFps::DebugFps(int x, int y) | |||||
| for (int i = 0; i < 5; i ++) | for (int i = 0; i < 5; i ++) | ||||
| { | { | ||||
| data->lines[i] = new Text(NULL, "gfx/font/ascii.png"); | data->lines[i] = new Text(NULL, "gfx/font/ascii.png"); | ||||
| data->lines[i]->SetPos(Int3(x, y + (i ? 8 : 0) + 16 * i, 0)); | |||||
| data->lines[i]->SetPos(int3(x, y + (i ? 8 : 0) + 16 * i, 0)); | |||||
| Ticker::Ref(data->lines[i]); | Ticker::Ref(data->lines[i]); | ||||
| } | } | ||||
| } | } | ||||
| @@ -27,10 +27,10 @@ class EmitterData | |||||
| private: | private: | ||||
| int tiler; | int tiler; | ||||
| Float3 gravity; | |||||
| float3 gravity; | |||||
| int particles[100]; | int particles[100]; | ||||
| Float3 positions[100]; | |||||
| Float3 velocities[100]; | |||||
| float3 positions[100]; | |||||
| float3 velocities[100]; | |||||
| int nparticles; | int nparticles; | ||||
| }; | }; | ||||
| @@ -38,7 +38,7 @@ private: | |||||
| * Public Emitter class | * Public Emitter class | ||||
| */ | */ | ||||
| Emitter::Emitter(int tiler, Float3 gravity) | |||||
| Emitter::Emitter(int tiler, float3 gravity) | |||||
| : data(new EmitterData()) | : data(new EmitterData()) | ||||
| { | { | ||||
| data->tiler = tiler; | data->tiler = tiler; | ||||
| @@ -75,7 +75,7 @@ void Emitter::TickDraw(float deltams) | |||||
| data->positions[i].z, 0); | data->positions[i].z, 0); | ||||
| } | } | ||||
| void Emitter::AddParticle(int id, Float3 pos, Float3 vel) | |||||
| void Emitter::AddParticle(int id, float3 pos, float3 vel) | |||||
| { | { | ||||
| if (data->nparticles >= 100) | if (data->nparticles >= 100) | ||||
| return; | return; | ||||
| @@ -23,10 +23,10 @@ class EmitterData; | |||||
| class Emitter : public Entity | class Emitter : public Entity | ||||
| { | { | ||||
| public: | public: | ||||
| Emitter(int tiler, Float3 gravity); | |||||
| Emitter(int tiler, float3 gravity); | |||||
| virtual ~Emitter(); | virtual ~Emitter(); | ||||
| void AddParticle(int id, Float3 pos, Float3 vel); | |||||
| void AddParticle(int id, float3 pos, float3 vel); | |||||
| protected: | protected: | ||||
| virtual void TickGame(float deltams); | virtual void TickGame(float deltams); | ||||
| @@ -34,8 +34,8 @@ public: | |||||
| buttons(0, 0, 0) | buttons(0, 0, 0) | ||||
| { } | { } | ||||
| Int2 mouse; | |||||
| Int3 buttons; | |||||
| int2 mouse; | |||||
| int3 buttons; | |||||
| } | } | ||||
| inputdata; | inputdata; | ||||
| @@ -45,10 +45,10 @@ static InputData * const data = &inputdata; | |||||
| * Public Input class | * Public Input class | ||||
| */ | */ | ||||
| Float2 Input::GetAxis(int axis) | |||||
| float2 Input::GetAxis(int axis) | |||||
| { | { | ||||
| float invsqrt2 = sqrtf(0.5f); | float invsqrt2 = sqrtf(0.5f); | ||||
| Float2 f; | |||||
| float2 f; | |||||
| /* Simulate a joystick using the keyboard. This SDL call is free. */ | /* Simulate a joystick using the keyboard. This SDL call is free. */ | ||||
| Uint8 *keystate = SDL_GetKeyState(NULL); | Uint8 *keystate = SDL_GetKeyState(NULL); | ||||
| @@ -65,12 +65,12 @@ Float2 Input::GetAxis(int axis) | |||||
| return f; | return f; | ||||
| } | } | ||||
| void Input::SetMousePos(Int2 coord) | |||||
| void Input::SetMousePos(int2 coord) | |||||
| { | { | ||||
| data->mouse = coord; | data->mouse = coord; | ||||
| } | } | ||||
| Int2 Input::GetMousePos() | |||||
| int2 Input::GetMousePos() | |||||
| { | { | ||||
| return data->mouse; | return data->mouse; | ||||
| } | } | ||||
| @@ -85,7 +85,7 @@ void Input::UnsetMouseButton(int index) | |||||
| data->buttons[index] = 0; | data->buttons[index] = 0; | ||||
| } | } | ||||
| Int3 Input::GetMouseButtons() | |||||
| int3 Input::GetMouseButtons() | |||||
| { | { | ||||
| return data->buttons; | return data->buttons; | ||||
| } | } | ||||
| @@ -21,12 +21,12 @@ | |||||
| class Input | class Input | ||||
| { | { | ||||
| public: | public: | ||||
| static Float2 GetAxis(int axis); | |||||
| static void SetMousePos(Int2 coord); | |||||
| static Int2 GetMousePos(); | |||||
| static float2 GetAxis(int axis); | |||||
| static void SetMousePos(int2 coord); | |||||
| static int2 GetMousePos(); | |||||
| static void SetMouseButton(int index); | static void SetMouseButton(int index); | ||||
| static void UnsetMouseButton(int index); | static void UnsetMouseButton(int index); | ||||
| static Int3 GetMouseButtons(); | |||||
| static int3 GetMouseButtons(); | |||||
| }; | }; | ||||
| #endif // __DH_INPUT_H__ | #endif // __DH_INPUT_H__ | ||||
| @@ -97,8 +97,8 @@ template <typename T> struct Vec2 | |||||
| union { T y; T b; T j; }; | union { T y; T b; T j; }; | ||||
| }; | }; | ||||
| typedef Vec2<float> Float2; | |||||
| typedef Vec2<int> Int2; | |||||
| typedef Vec2<float> float2; | |||||
| typedef Vec2<int> int2; | |||||
| template <typename T> struct Vec3 | template <typename T> struct Vec3 | ||||
| { | { | ||||
| @@ -113,8 +113,25 @@ template <typename T> struct Vec3 | |||||
| union { T z; T c; T k; }; | union { T z; T c; T k; }; | ||||
| }; | }; | ||||
| typedef Vec3<float> Float3; | |||||
| typedef Vec3<int> Int3; | |||||
| typedef Vec3<float> float3; | |||||
| typedef Vec3<int> int3; | |||||
| template <typename T> struct Vec4 | |||||
| { | |||||
| inline Vec4() { x = y = z = w = 0; } | |||||
| inline Vec4(T val) { x = y = z = w = val; } | |||||
| inline Vec4(T _x, T _y, T _z, T _w) { x = _x; y = _y; z = _z; w = _w; } | |||||
| OPERATORS(4) | |||||
| union { T x; T a; T i; }; | |||||
| union { T y; T b; T j; }; | |||||
| union { T z; T c; T k; }; | |||||
| union { T w; T d; T l; }; | |||||
| }; | |||||
| typedef Vec4<float> float4; | |||||
| typedef Vec4<int> int4; | |||||
| #define SCALAR_GLOBAL(elems, op, U) \ | #define SCALAR_GLOBAL(elems, op, U) \ | ||||
| template<typename T> \ | template<typename T> \ | ||||
| @@ -139,6 +156,7 @@ typedef Vec3<int> Int3; | |||||
| GLOBALS(2) | GLOBALS(2) | ||||
| GLOBALS(3) | GLOBALS(3) | ||||
| GLOBALS(4) | |||||
| #endif // __DH_MATRIX_H__ | #endif // __DH_MATRIX_H__ | ||||
| @@ -48,7 +48,7 @@ void SdlInput::TickGame(float deltams) | |||||
| Entity::TickGame(deltams); | Entity::TickGame(deltams); | ||||
| /* Handle mouse input */ | /* Handle mouse input */ | ||||
| Int2 mouse; | |||||
| int2 mouse; | |||||
| if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) | if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) | ||||
| { | { | ||||
| SDL_GetMouseState(&mouse.x, &mouse.y); | SDL_GetMouseState(&mouse.x, &mouse.y); | ||||
| @@ -29,7 +29,7 @@ class TextData | |||||
| private: | private: | ||||
| int font; | int font; | ||||
| char *text; | char *text; | ||||
| Int3 pos; | |||||
| int3 pos; | |||||
| }; | }; | ||||
| /* | /* | ||||
| @@ -41,7 +41,7 @@ Text::Text(char const *text, char const *font) | |||||
| { | { | ||||
| data->font = Forge::Register(font); | data->font = Forge::Register(font); | ||||
| data->text = text ? strdup(text) : NULL; | data->text = text ? strdup(text) : NULL; | ||||
| data->pos = Int3(0, 0, 0); | |||||
| data->pos = int3(0, 0, 0); | |||||
| drawgroup = DRAWGROUP_HUD; | drawgroup = DRAWGROUP_HUD; | ||||
| } | } | ||||
| @@ -53,7 +53,7 @@ void Text::SetText(char const *text) | |||||
| data->text = text ? strdup(text) : NULL; | data->text = text ? strdup(text) : NULL; | ||||
| } | } | ||||
| void Text::SetPos(Int3 pos) | |||||
| void Text::SetPos(int3 pos) | |||||
| { | { | ||||
| data->pos = pos; | data->pos = pos; | ||||
| } | } | ||||
| @@ -27,7 +27,7 @@ public: | |||||
| virtual ~Text(); | virtual ~Text(); | ||||
| void SetText(char const *text); | void SetText(char const *text); | ||||
| void SetPos(Int3 pos); | |||||
| void SetPos(int3 pos); | |||||
| protected: | protected: | ||||
| virtual void TickDraw(float deltams); | virtual void TickDraw(float deltams); | ||||