diff --git a/TrooperEngineDLL/TrooperEngine/AudioEngine/cAudio.hpp b/TrooperEngineDLL/TrooperEngine/AudioEngine/cAudio.hpp index a503827..08425a1 100644 --- a/TrooperEngineDLL/TrooperEngine/AudioEngine/cAudio.hpp +++ b/TrooperEngineDLL/TrooperEngine/AudioEngine/cAudio.hpp @@ -31,8 +31,7 @@ namespace AudioEngine { /* Plays the sounds */ void SoundPlay(); /* Plays the music */ - void MusicPlay(); - + void MusicPlay(); /// Set /* Sets the rate */ diff --git a/TrooperEngineDLL/TrooperEngine/AudioEngine/cMusic.hpp b/TrooperEngineDLL/TrooperEngine/AudioEngine/cMusic.hpp index 39fe489..6aab376 100644 --- a/TrooperEngineDLL/TrooperEngine/AudioEngine/cMusic.hpp +++ b/TrooperEngineDLL/TrooperEngine/AudioEngine/cMusic.hpp @@ -40,8 +40,6 @@ namespace AudioEngine { Mix_Music* mp_music; unsigned char m_volume;/// = 255 - - };/// END CLASS DEFINITION cMusic }/// END NAMESPACE DEFINITION AudioEngine #endif/// END IFNDEF _CMUSIC_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/AudioEngine/cSound.hpp b/TrooperEngineDLL/TrooperEngine/AudioEngine/cSound.hpp index f823ed9..c5c3b84 100644 --- a/TrooperEngineDLL/TrooperEngine/AudioEngine/cSound.hpp +++ b/TrooperEngineDLL/TrooperEngine/AudioEngine/cSound.hpp @@ -79,13 +79,12 @@ namespace AudioEngine { cString m_dir;/// = "" cString m_fileName;/// = "" + unsigned char m_volume;/// = 255 + unsigned char m_distance;/// = 100 - unsigned char m_volume;// = 255 - unsigned char m_distance;// = 100 - - short int m_angle;// = 0 - long int m_channel;// = -1 - long int m_loops;// = 0 + short int m_angle;/// = 0 + long int m_channel;/// = -1 + long int m_loops;/// = 0 };/// END CLASS DEFINITION cSound }/// END NAMESPACE DEFINITION AudioEngine #endif/// END IFNDEF _CSOUND_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/EventEngine/cEvent.cpp b/TrooperEngineDLL/TrooperEngine/EventEngine/cEvent.cpp index 08f03cb..4385781 100644 --- a/TrooperEngineDLL/TrooperEngine/EventEngine/cEvent.cpp +++ b/TrooperEngineDLL/TrooperEngine/EventEngine/cEvent.cpp @@ -28,10 +28,10 @@ cEvent::cEvent() OnMouseMove(event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel, (event.motion.state&SDL_BUTTON(SDL_BUTTON_LEFT)) != 0, (event.motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0, (event.motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0); break; case SDL_MOUSEBUTTONDOWN: - OnMouseButtonUp(event); + OnMouseButtonDown(event); break; case SDL_MOUSEBUTTONUP: - OnMouseButtonDown(event); + OnMouseButtonUp(event); break; case SDL_JOYAXISMOTION: OnJoyAxis(event.jaxis.which, event.jaxis.axis, event.jaxis.value); diff --git a/TrooperEngineDLL/TrooperEngine/EventEngine/cEvent.hpp b/TrooperEngineDLL/TrooperEngine/EventEngine/cEvent.hpp index a425c58..e1972d1 100644 --- a/TrooperEngineDLL/TrooperEngine/EventEngine/cEvent.hpp +++ b/TrooperEngineDLL/TrooperEngine/EventEngine/cEvent.hpp @@ -67,6 +67,7 @@ namespace EventEngine { virtual void OnExit(); virtual void OnUser( Uint32 type, int code, void* data1, void* data2 ); + private: void OnWindowsEvent( const SDL_Event& event ); void OnMouseButtonDown( const SDL_Event& event ); diff --git a/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.hpp b/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.hpp index 1908d09..502e8c5 100644 --- a/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.hpp +++ b/TrooperEngineDLL/TrooperEngine/EventEngine/cEventControl.hpp @@ -24,7 +24,7 @@ namespace EventEngine { static cEventControl& Inst(); static void Delete(); - //Functions + /// Functions const bool Initialize() const; const bool Setup(); @@ -39,13 +39,14 @@ namespace EventEngine { std::vector& GetEvents(); - ///Sets + /// Sets - ///Gets + /// Gets /* Gets return true if Event was initialized */ const bool IsInit() const; private: + /// Variables std::vector m_children; static cEventControl* sp_inst;// = nullptr };/// END CLASS DEFINITION cEventControl diff --git a/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.cpp b/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.cpp index ba4867e..822c8a3 100644 --- a/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.cpp +++ b/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.cpp @@ -41,6 +41,13 @@ void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Co cUtility::Inst().Message("Unable to render text. stringRGBA():", __AT__, cUtility::eTypeSDL::GFX); } +void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Surface* surface ) const +{ + //cRenderer::Inst().SetRenderTarget(texture); + //StringDefault(text, pos, colour); + //cRenderer::Inst().ResetRenderTarget(); +} + void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const { cRenderer::Inst().SetRenderTarget(texture); @@ -48,6 +55,17 @@ void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Co cRenderer::Inst().ResetRenderTarget(); } +SDL_Texture* cGFX::StringTexture( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const +{ + SDL_Texture* rtn = cRenderer::Inst().NewTexture(8 * text.length(), 8, false, SDL_TEXTUREACCESS_TARGET); + + if (rtn != nullptr) + cGFX::Inst().StringDefault(text, pos, colour, rtn); + else + cUtility::Inst().Message("Unable to create NewTexture in StringTexture. cRenderer::NewTexture():", __AT__); + return rtn; +} + void cGFX::Box( const SDL_Rect& rect, const SDL_Colour& colour ) const { if (boxRGBA(cRenderer::Inst().getRenderer(), (Sint16)rect.x, (Sint16)rect.y, (Sint16)rect.w, (Sint16)rect.h, colour.r, colour.g, colour.b, colour.a) < 0) @@ -100,17 +118,28 @@ void cGFX::Rectangle( const SDL_Rect& rect, const SDL_Colour& colour, SDL_Textur cRenderer::Inst().ResetRenderTarget(); } -void cGFX::ZoomIn( SDL_Texture* texture, const double zoomx, const double zoomy, const unsigned long int smooth /*= SMOOTHING_ON*/ ) const +SDL_Surface* cGFX::ZoomIn( SDL_Surface* surface, const double zoomx, const double zoomy, const unsigned long int smooth /*= SMOOTHING_ON*/ ) const +{ + SDL_Surface* rtn = nullptr; + + rtn = zoomSurface(surface, zoomx, zoomy, smooth); + + return rtn; +} + +SDL_Texture* cGFX::ZoomIn( SDL_Texture* texture, const double zoomx, const double zoomy, const unsigned long int smooth /*= SMOOTHING_ON*/ ) const { SDL_Surface* surface = cRenderer::Inst().TextureToSurface(texture); - SDL_DestroyTexture(texture); - texture = nullptr; + SDL_Surface* zoom_sur = zoomSurface(surface, zoomx, zoomy, smooth); - zoomSurface(surface, zoomx, zoomy, smooth); - - texture = cRenderer::Inst().SurfaceToTexture(surface); - SDL_FreeSurface(surface); surface = nullptr; + + SDL_Texture* rtn = cRenderer::Inst().SurfaceToTexture(zoom_sur); + + SDL_FreeSurface(zoom_sur); + zoom_sur = nullptr; + + return rtn; } \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.hpp b/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.hpp index 9cb44e0..37e78b6 100644 --- a/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.hpp +++ b/TrooperEngineDLL/TrooperEngine/FXEngine/cGFX.hpp @@ -25,24 +25,42 @@ namespace FXEngine { static cGFX& Inst(); static void Delete(); + /* Render to the renderer with stringRGBA() from SDL2_gfx */ void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const; + void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Surface* surface ) const; + /* Sets texture to renderer and calls StringDefault(text, pos, colour) */ void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const; + /* Creates a Texture for use and calls StringDefault(text, pos, colour, texture) */ + SDL_Texture* StringTexture( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const; + + /* Render to the renderer with boxRGBA() from SDL2_gfx */ void Box( const SDL_Rect& rect, const SDL_Colour& colour ) const; + /* Sets texture to renderer and calls Box(rect, colour) */ void Box( const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture ) const; + /* Render to the renderer with roundedBoxRGBA() from SDL2_gfx */ void RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour ) const; + /* Sets texture to renderer and calls RoundedBox(rect, rad, colour) */ void RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour, SDL_Texture* texture ) const; + /* Render to the renderer with pixelRGBA() from SDL2_gfx */ void Pixel( const unsigned long int x, const unsigned long int y, const SDL_Colour& colour ) const; + /* Sets texture to renderer and calls Pixel(x, y, colour) */ void Pixel( const unsigned long int x, const unsigned long int y, const SDL_Colour& colour, SDL_Texture* texture ) const; + /* Render to the renderer with rectangleRGBA() from SDL2_gfx */ void Rectangle( const SDL_Rect& rect, const SDL_Colour& colour ) const; + /* Sets texture to renderer and calls Rectangle(rect, colour) */ void Rectangle( const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture ) const; - void ZoomIn( SDL_Texture* texture, const double zoomx, const double zoomy, const unsigned long int smooth = SMOOTHING_ON ) const; + /* Zooms in or out to stretch or shrink the surface and returns a new surface with zoomSurface() from SDL2_gfx */ + SDL_Surface* ZoomIn( SDL_Surface* surface, const double zoomx, const double zoomy, const unsigned long int smooth = SMOOTHING_ON ) const; + /* Zooms in or out to stretch or shrink the texture and returns a new texture with zoomSurface() from SDL2_gfx */ + SDL_Texture* ZoomIn( SDL_Texture* texture, const double zoomx, const double zoomy, const unsigned long int smooth = SMOOTHING_ON ) const; private: + /// Variables static cGFX* sp_inst;/// = nullptr };/// END CLASS DEFINITION cGFX }/// END NAMESPACE DEFINITION FXEngine diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/GUIUtility.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/GUIUtility.hpp index f6fbdb6..e56db8c 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/GUIUtility.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/GUIUtility.hpp @@ -38,7 +38,7 @@ namespace GUIHelpers { static const RGBA DEFAULT = WHITE; - const RGBA StringtoRGBA(const cString& colour); + const RGBA StringtoRGBA( const cString& colour ); }/// END NAMESPACE DEFINITION GUIHelpers #endif/// END IFNDEF _GUIUTILITY_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cObject.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cObject.hpp index e1b4bdf..99c0fd1 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cObject.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cObject.hpp @@ -16,16 +16,17 @@ namespace GUIHelpers { bool operator == ( const cObject& other ); - ///Functions + /// Functions - ///Sets + /// Sets const void setID( const signed int id ); - ///Gets + /// Gets const signed int getID() const; virtual const GUIHelpers::eType getType() const; private: + /// Variables signed int m_id;// = 0 };/// END CLASS DEFINITION cObject }/// END NAMESPACE DEFINITION GUIEngine diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cXMLoader.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cXMLoader.hpp index 9d4ad6f..501ff5b 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cXMLoader.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/GUIHelpers/cXMLoader.hpp @@ -62,6 +62,7 @@ namespace GUIHelpers { void LoadDefault() const; private: + /// Variables bool m_loadDef;/// = false; bool m_debugXML;/// = false; diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.hpp index d84b7b9..fc21892 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cButton.hpp @@ -53,6 +53,7 @@ namespace GUIEngine { void GenerateTexture(); private: + /// Variables VideoEngine::cImage* mp_texture;/// = nullptr VideoEngine::cImage* mp_texturePress;/// = nullptr diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cGUI.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cGUI.hpp index 17c6491..b1c5832 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cGUI.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cGUI.hpp @@ -82,6 +82,7 @@ namespace GUIEngine { const bool IsInit() const; private: + /// Variables static cGUI* sp_inst;/// = nullptr unsigned long int m_debugLevel;/// = 0 diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cLabel.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cLabel.hpp index d72ce61..4e9c1ec 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cLabel.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cLabel.hpp @@ -55,6 +55,7 @@ namespace GUIEngine { void SetSize(); private: + /// Variables VideoEngine::cSprite m_sprite; TextTypeEngine::cText* mp_text;/// = nullptr };/// END CLASS DEFINITION cLabel diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cLayout.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cLayout.hpp index 63113f6..c069489 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cLayout.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cLayout.hpp @@ -45,6 +45,7 @@ namespace GUIEngine { virtual const GUIHelpers::RGBA& getDebugColour() const; private: + /// Variables GUIHelpers::eOrientation m_orientation; };/// END CLASS DEFINITION cLayout }/// END NAMESPACE DEFINITION GUIEngine diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cPanel.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cPanel.hpp index 3563cad..ccce257 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cPanel.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cPanel.hpp @@ -37,6 +37,7 @@ namespace GUIEngine { virtual const GUIHelpers::RGBA& getDebugColour() const; private: + /// Variables };/// END CLASS DEFINITION cPanel }/// END NAMESPACE DEFINITION GUIEngine #endif/// END IFNDEF _CPANEL_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cSizer.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cSizer.hpp index 1049160..0931571 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cSizer.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cSizer.hpp @@ -39,7 +39,8 @@ namespace GUIEngine { virtual const GUIHelpers::eType getType() const; virtual const GUIHelpers::RGBA& getDebugColour() const; private: - private: + private: + /// Variables };/// END CLASS DEFINITION cSizer }/// END NAMESPACE DEFINITION GUIEngine #endif/// END IFNDEF _CSIZER_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.hpp index 1d1b6cf..2e49ba8 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cTextButton.hpp @@ -56,6 +56,7 @@ namespace GUIEngine { void GenerateTexture(); private: + /// Variables cLabel m_label;/// = nullptr };/// END CLASS DEFINITION cButton }/// END NAMESPACE DEFINITION GUIEngine diff --git a/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.hpp b/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.hpp index f068800..2ff8080 100644 --- a/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.hpp +++ b/TrooperEngineDLL/TrooperEngine/GUIEngine/cWindow.hpp @@ -114,6 +114,7 @@ namespace GUIEngine { void DebugDisplay() const; private: + /// Variables GUIHelpers::eOrientation m_orientation;/// = GUIHelper::eOrientation::NONE; GUIHelpers::eAlign m_align;/// = GUIHelper::eAlign::CENTER; GUIHelpers::eLayout m_layout;/// = GUIHelper::eLayout::FILL_PARENT; diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cInput.hpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cInput.hpp index b5160ee..b0f5930 100644 --- a/TrooperEngineDLL/TrooperEngine/InputEngine/cInput.hpp +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cInput.hpp @@ -61,6 +61,7 @@ namespace InputEngine { const bool IsInit() const; private: + /// Variables std::vector m_keyboards; SDL_Event m_event; diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cJoystick.hpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cJoystick.hpp index 2d3b2aa..36f3b54 100644 --- a/TrooperEngineDLL/TrooperEngine/InputEngine/cJoystick.hpp +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cJoystick.hpp @@ -32,7 +32,6 @@ namespace InputEngine { /// Used when looking for keys that have been add to the check list void JoystickCheck(); - };/// END CLASS DEFINITION cJoystick }/// END NAMESPACE DEFINITION InputEngine #endif/// END IFNDEF _CJOYSTICK_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cKey.hpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cKey.hpp index cc24690..5e94330 100644 --- a/TrooperEngineDLL/TrooperEngine/InputEngine/cKey.hpp +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cKey.hpp @@ -15,7 +15,7 @@ namespace InputEngine { cKey( const cKey& copy ); virtual ~cKey(); - /// Funtions + /// Functions /* Call to check if the key is pressed */ virtual void KeyPress(); /* Call to check if the key is released */ @@ -31,6 +31,7 @@ namespace InputEngine { private: private: + /// Variables SDL_Keycode m_key; };/// END CLASS DEFINITION cKey }/// END NAMESPACE DEFINITION InputEngine diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cKeyboard.hpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cKeyboard.hpp index 447e9c3..99ef5f1 100644 --- a/TrooperEngineDLL/TrooperEngine/InputEngine/cKeyboard.hpp +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cKeyboard.hpp @@ -24,7 +24,6 @@ EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::vector m_keys; diff --git a/TrooperEngineDLL/TrooperEngine/InputEngine/cTextInput.hpp b/TrooperEngineDLL/TrooperEngine/InputEngine/cTextInput.hpp index e1ba0ae..83b7f27 100644 --- a/TrooperEngineDLL/TrooperEngine/InputEngine/cTextInput.hpp +++ b/TrooperEngineDLL/TrooperEngine/InputEngine/cTextInput.hpp @@ -29,8 +29,10 @@ namespace InputEngine { virtual void KeyboardCheck( const SDL_Event& event ); /* Clears out the Text */ void ClearText(); + /// Sets void setText( const cString& text ); + /// Gets const cString& getText() const; @@ -38,6 +40,7 @@ namespace InputEngine { const char UnicodeValue( const SDL_Event& event ); private: + /// Variables cString m_text;/// = "" bool m_caps;/// = false bool m_shift;/// = false diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.cpp b/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.cpp index cd1793d..f842927 100644 --- a/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.cpp +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.cpp @@ -45,6 +45,21 @@ cCollision::~cCollision() return true; /// bounding boxes intersect } +/*static*/ const bool cCollision::BoundingBox(const iVector4& a, const iVector4& b) +{ + if ((b.x + b.z) < a.x) + return false; /// just checking if their + if ((a.x + a.z) < b.x) + return false; /// bounding boxes even touch + + if ((b.y + b.w) < a.y) + return false; + if ((a.y + a.w) < b.y) + return false; + + return true; /// bounding boxes intersect +} + /*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const Vector4& b ) { Vector4 temp = a; @@ -57,21 +72,6 @@ cCollision::~cCollision() return cCollision::BoundingBox(b, a); } -/*static*/ const bool cCollision::BoundingBox( const iVector4& a, const iVector4& b ) -{ - if ((b.x + b.z) < a.x) - return false; /// just checking if their - if ((a.x + a.z) < b.x ) - return false; /// bounding boxes even touch - - if ((b.y + b.w) < a.y) - return false; - if ((a.y + a.w) < b.y) - return false; - - return true; /// bounding boxes intersect -} - /*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const iVector4& b ) { iVector4 temp = a; @@ -96,28 +96,6 @@ cCollision::~cCollision() return cCollision::BoundingBox( b, a ); } -/*static*/ const Vector2 cCollision::Inside( const SDL_Rect& a, const SDL_Rect& b ) -{ - Vector2 rtn; - rtn.x = 0.0f; - rtn.y = 0.0f; - - /// Check if left side of b is inside of a - if (b.x < a.x) - rtn.x = (float)(b.x - a.x); - /// Check if right side of b is inside of a - if ((b.x + b.w) > (a.x + a.w)) - rtn.x = (float)((b.x + b.w) - (a.x + a.w)); - /// Check if top side of b is inside of a - if (b.y < a.y) - rtn.y = (float)(b.y - a.y); - /// Check if bottom side of b is inside of a - if ((b.y + b.h) > (a.y + a.h)) - rtn.y = (float)((b.y + b.h) - (a.y + a.h)); - - return rtn; -} - /*static*/ const Vector2 cCollision::Inside( const Vector4& a, const Vector4& b ) { Vector2 rtn; @@ -154,6 +132,44 @@ cCollision::~cCollision() return cCollision::Inside(a, temp); } +/*static*/ const bool cCollision::isInside( const signed long int x, const signed long int y, const SDL_Rect& inside ) +{ + iVector4 temp = inside; + return cCollision::isInside(x, y, temp); +} + +/*static*/ const bool cCollision::isInside( const signed long int x, const signed long int y, const iVector4& inside ) +{ + bool rtn = false; + if ((inside.x < x) && (inside.w > x)) { + if ((inside.y < y) && (inside.z > y)) + rtn = true; + } + return rtn; +} + +/*static*/ const iVector2 cCollision::Inside(const SDL_Rect& a, const SDL_Rect& b) +{ + iVector2 rtn; + rtn.x = 0.0f; + rtn.y = 0.0f; + + /// Check if left side of b is inside of a + if (b.x < a.x) + rtn.x = (float)(b.x - a.x); + /// Check if right side of b is inside of a + if ((b.x + b.w) > (a.x + a.w)) + rtn.x = (float)((b.x + b.w) - (a.x + a.w)); + /// Check if top side of b is inside of a + if (b.y < a.y) + rtn.y = (float)(b.y - a.y); + /// Check if bottom side of b is inside of a + if ((b.y + b.h) > (a.y + a.h)) + rtn.y = (float)((b.y + b.h) - (a.y + a.h)); + + return rtn; +} + /*static*/ const iVector2 cCollision::Inside( const iVector4& a, const iVector4& b ) { iVector2 rtn; diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.hpp b/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.hpp index a88f387..e7a6e02 100644 --- a/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.hpp +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/cCollision.hpp @@ -20,31 +20,52 @@ namespace MathEngine { private: cCollision(); ~cCollision(); + public: /// Functions + /* returns true if a is touching b */ static const bool BoundingBox( const SDL_Rect& a, const SDL_Rect& b ); + /* returns true if a is touching b */ static const bool BoundingBox( const Vector4& a, const Vector4& b ); - static const bool BoundingBox( const SDL_Rect& a, const Vector4& b ); - static const bool BoundingBox( const Vector4& a, const SDL_Rect& b ); + /* returns true if a is touching b */ + static const bool BoundingBox(const iVector4& a, const iVector4& b); - static const bool BoundingBox( const iVector4& a, const iVector4& b ); + /* returns true if a is touching b */ + static const bool BoundingBox( const SDL_Rect& a, const Vector4& b ); + /* returns true if a is touching b */ + static const bool BoundingBox( const Vector4& a, const SDL_Rect& b ); + /* returns true if a is touching b */ static const bool BoundingBox( const SDL_Rect& a, const iVector4& b ); + /* returns true if a is touching b */ static const bool BoundingBox( const iVector4& a, const SDL_Rect& b ); + /* returns true if a is touching b */ static const bool BoundingBox( const iVector4& a, const Vector4& b ); + /* returns true if a is touching b */ static const bool BoundingBox( const Vector4& a, const iVector4& b ); - - static const Vector2 Inside( const SDL_Rect& a, const SDL_Rect& b ); + /* returns the Vector2 were a over laps b */ static const Vector2 Inside( const Vector4& a, const Vector4& b ); + /* returns the Vector2 were a over laps b */ static const Vector2 Inside( const SDL_Rect& a, const Vector4& b ); + /* returns the Vector2 were a over laps b */ static const Vector2 Inside( const Vector4& a, const SDL_Rect& b ); + /* returns true if xy are inside SDL_Rect */ + static const bool isInside( const signed long int x, const signed long int y, const SDL_Rect& inside ); + /* returns true if xy are inside iVector4 */ + static const bool isInside( const signed long int x, const signed long int y, const iVector4& inside ); + + /* returns the iVector2 were a over laps b */ + static const iVector2 Inside(const SDL_Rect& a, const SDL_Rect& b); + /* returns the iVector2 were a over laps b */ static const iVector2 Inside( const iVector4& a, const iVector4& b ); + /* returns the iVector2 were a over laps b */ static const iVector2 Inside( const SDL_Rect& a, const iVector4& b ); + /* returns the iVector2 were a over laps b */ static const iVector2 Inside( const iVector4& a, const SDL_Rect& b ); + static const Vector2 Inside( const iVector4& a, const Vector4& b ); static const Vector2 Inside( const Vector4& a, const iVector4& b ); - };/// END CLASS DEFINITION cCollision }/// END NAMESPACE DEFINITION MathEngine #endif/// END IFNDEF _CCOLLISION_HPP_ diff --git a/TrooperEngineDLL/TrooperEngine/MathEngine/cRandom.hpp b/TrooperEngineDLL/TrooperEngine/MathEngine/cRandom.hpp index 8c2e9ff..c45aa08 100644 --- a/TrooperEngineDLL/TrooperEngine/MathEngine/cRandom.hpp +++ b/TrooperEngineDLL/TrooperEngine/MathEngine/cRandom.hpp @@ -26,6 +26,7 @@ namespace MathEngine { const float Rand( const float max, const float min = 0.0f ) const; private: + /// Variables static cRandom* sp_inst;/// = nullptr };/// END CLASS DEFINITION cRandom }/// END NAMESPACE DEFINITION MathEngine diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/TextTypeHelpers/cFontHolder.hpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/TextTypeHelpers/cFontHolder.hpp index a769e47..cdf4a9c 100644 --- a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/TextTypeHelpers/cFontHolder.hpp +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/TextTypeHelpers/cFontHolder.hpp @@ -21,6 +21,7 @@ namespace TextTypeHelpers { const unsigned long int getSize() const; private: + /// Variables TTF_Font* mp_font;/// = nullptr unsigned long int m_size;/// = 16 };/// END CLASS DEFINITION cFontHolder diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.cpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.cpp index 4a6f638..6022967 100644 --- a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.cpp +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.cpp @@ -7,7 +7,7 @@ using TextTypeEngine::cFont; using TextTypeHelpers::cFontHolder; using UtilityEngine::cUtility; -cFont::cFont( const cString& filename /*= ""*/, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/ ) +cFont::cFont( const cString& filename /*= ""*/, const cString& dir /*= ""*/, const unsigned long int size /*= 8*/ ) : m_dir(dir), m_fileName(filename), mpp_default(nullptr) { setSize(size); @@ -42,7 +42,7 @@ void cFont::setFileNameandDir( const cString& filename, const cString& dir /*= " setFileName(filename); } -void cFont::setSize( const unsigned long int size /*= 16*/ ) +void cFont::setSize( const unsigned long int size /*= 8*/ ) { while ((mpp_default == nullptr) || ((*mpp_default) == nullptr)) { getFont(size); diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.hpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.hpp index 29b9935..bdd07ca 100644 --- a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.hpp +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cFont.hpp @@ -28,12 +28,11 @@ namespace TextTypeEngine { class EXPORT_FROM_MYDLL cFont { public: - cFont( const cString& filename = "", const cString& dir = "", const unsigned long int size = 16 ); + cFont( const cString& filename = "", const cString& dir = "", const unsigned long int size = 8 ); cFont( const cFont& copy ); ~cFont(); - /// Functions - + /// Functions /// Sets /* Sets the Directory of the TTF file */ @@ -43,7 +42,7 @@ namespace TextTypeEngine { /* Sets the Filename and Directory of the TTF file */ void setFileNameandDir( const cString& filename, const cString& dir = "" ); /* Sets the size of the TTF. Default is 16 */ - void setSize( const unsigned long int size = 16 ); + void setSize( const unsigned long int size = 8 ); /// Gets /* Gets the Directory of the TTF file */ @@ -67,13 +66,13 @@ namespace TextTypeEngine { void UnloadFont(); private: + /// Variables std::vector m_fonts; //cFontHolder m_fonts; //cFont::cFontHolder m_fonts; TextTypeHelpers::cFontHolder** mpp_default;/// = nullptr cString m_dir;/// = "" cString m_fileName;/// = "" - };/// END CLASS DEFINITION cFont }/// END NAMESPACE DEFINITION TextTypeEngine #endif/// END IFNDEF _CFONT_HPP_ \ No newline at end of file diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.cpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.cpp index 4876254..8f1440f 100644 --- a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.cpp +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.cpp @@ -76,6 +76,7 @@ void cText::setSize( const unsigned long int size /*= 8*/ ) m_size = size; if ((mpp_font != nullptr) && ((*mpp_font) != nullptr)) (*mpp_font)->setSize(size); + Text(); } } @@ -157,6 +158,8 @@ const cText::eRender& cText::getRender() const /// private void cText::Text() { + /// if we have a font use SDL2_ttf to render the text. + /// else use SDL2_gfx to render text and use ZoomIn if it's size is larger then 8. if((mpp_font != nullptr) && (*mpp_font != nullptr)) { SDL_Surface* sur = nullptr; switch (m_render) @@ -176,39 +179,19 @@ void cText::Text() setImage(sur); } else { SDL_Rect pos = { 0, 0, 0, 0 }; - //m_size == 25; - SDL_Texture* texture = cRenderer::Inst().NewTexture(8 * m_text.length(), 8, false, SDL_TEXTUREACCESS_TARGET); - SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); + SDL_Texture* texture = cGFX::Inst().StringTexture(m_text, pos, m_colour); - //int t = SDL_SetTextureColorMod(texture, 0, 255, 0); - - // 376840196 - - - - //t = SDL_SetTextureAlphaMod(texture, 0); - //SDL_fill - //cRenderer::Inst().SetRenderTarget(texture); - //SDL_Colour col = { 0, 255, 255, 255}; - //SDL_Rect re= { 0, 0, 100, 100}; - //cGFX::Inst().RoundedRectangle(pos, 4, col, texture); - //cRenderer::Inst().RenderDrawColor(col); - //cRenderer::Inst().RenderDrawRect(re, texture); - - //cGFX::Inst().RoundedRectangle(pos, 4, col, texture); - - //cRenderer::Inst().Render( texture, nullptr, nullptr); - //SDL_RenderCopy(cRenderer::Inst().getRenderer(), texture, nullptr, nullptr); - - //cRenderer::Inst().Render(texture, nullptr, nullptr); - //cRenderer::Inst().ResetRenderTarget(); - if (texture != nullptr) { - - //cGFX::Inst().StringDefault(m_text, pos, m_colour); - cGFX::Inst().StringDefault(m_text, pos, m_colour, texture); - //cGFX::Inst().ZoomIn(texture, m_size * m_text.length(), m_size, SMOOTHING_ON); - setImage(texture); + if (m_size > 8) { + SDL_Texture* newTexture = cRenderer::Inst().NewTexture(((m_size / 4) * m_text.length()), m_size); + + double x = ((m_size / 4 ) * m_text.length()) / 8; + double y = m_size / 8; + setImage(cGFX::Inst().ZoomIn(texture, x, y, SMOOTHING_ON)); + SDL_DestroyTexture(texture); + } + else + setImage(texture); } } } diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.hpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.hpp index 5c9374b..552196f 100644 --- a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.hpp +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cText.hpp @@ -81,10 +81,11 @@ namespace TextTypeEngine { void Text(); private: + /// Variables TextTypeEngine::cFont** mpp_font;/// = nullptr cString m_text;/// = "" - unsigned long int m_size;// = 16 + unsigned long int m_size;/// = 16 SDL_Colour m_colour;/// = nullptr eRender m_render;/// = Solid };/// END CLASS DEFINITION cText diff --git a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cTextType.hpp b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cTextType.hpp index d2a6bf0..82aa9ee 100644 --- a/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cTextType.hpp +++ b/TrooperEngineDLL/TrooperEngine/TextTypeEngine/cTextType.hpp @@ -34,6 +34,7 @@ namespace TextTypeEngine { const bool IsInit() const; private: + /// Variables static cTextType* sp_inst;/// = nullptr };/// END CLASS DEFINITION cTextType }/// END NAMESPACE DEFINITION TextTypeEngine diff --git a/TrooperEngineDLL/TrooperEngine/UtilityEngine/cString.hpp b/TrooperEngineDLL/TrooperEngine/UtilityEngine/cString.hpp index 7e6aa12..f8163c0 100644 --- a/TrooperEngineDLL/TrooperEngine/UtilityEngine/cString.hpp +++ b/TrooperEngineDLL/TrooperEngine/UtilityEngine/cString.hpp @@ -75,9 +75,9 @@ namespace UtilityEngine { operator std::string () const; /// c++ string class private: + /// Variables char* mp_str = nullptr; size_t m_len = 0; - };/// END CLASS DEFINITION cString }/// END NAMESPACE DEFINITION UtilityEngine /// function overloads diff --git a/TrooperEngineDLL/TrooperEngine/UtilityEngine/cUtility.hpp b/TrooperEngineDLL/TrooperEngine/UtilityEngine/cUtility.hpp index a725993..94cbd11 100644 --- a/TrooperEngineDLL/TrooperEngine/UtilityEngine/cUtility.hpp +++ b/TrooperEngineDLL/TrooperEngine/UtilityEngine/cUtility.hpp @@ -46,7 +46,7 @@ namespace UtilityEngine { static cUtility& Inst(); static void Delete(); - void Message( const cString& msg, const cString& funcName = "", const eTypeSDL typeSDL = eTypeSDL::NONE ) const; + void Message( const cString& msg, const cString& debugInfo = "", const eTypeSDL typeSDL = eTypeSDL::NONE ) const; void PrintVersion( const eTypeSDL typeSDL = eTypeSDL::ALL ) const; diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cImage.hpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cImage.hpp index 3b759ea..5d41e8b 100644 --- a/TrooperEngineDLL/TrooperEngine/VideoEngine/cImage.hpp +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cImage.hpp @@ -83,7 +83,7 @@ namespace VideoEngine { private: /// Variables SDL_Texture* mp_texture;/// = nullptr - SDL_Surface* mp_surface;// = nullptr + SDL_Surface* mp_surface;/// = nullptr bool m_transparent;/// = false diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.cpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.cpp index f47d172..e7e18c8 100644 --- a/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.cpp +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.cpp @@ -47,7 +47,6 @@ const bool cRenderer::Setup() mp_renderer = cVideo::Inst().CreateRender(); SDL_Surface* surface = SDL_GetWindowSurface(cVideo::Inst().getWindow()); mp_rendererSoftware = SDL_CreateSoftwareRenderer(surface); - //mp_rendererCopy = cVideo::Inst().CreateRender(); if (mp_renderer != nullptr) rtn = true; } @@ -169,13 +168,13 @@ SDL_Surface* cRenderer::TextureToSurface( SDL_Texture* texture ) SDL_Rect rec = { 0, 0, w, h }; - SDL_Texture* tmp_texture = NewTexture(w, h, true); // Create a new texture with Software Renderer - CopyTexture(texture, tmp_texture, true); // Copy old texture to the Software Renderer Texture renderer + SetRenderTarget(texture); + + if (SDL_RenderReadPixels(mp_renderer, nullptr, SDL_PIXELFORMAT_RGBA32, rtn->pixels, rtn->pitch) < 0) + cUtility::Inst().Message("Unable to Read Texture's Pixels. SDL_RenderReadPixels():", __AT__, cUtility::eTypeSDL::SDL); + + ResetRenderTarget(); - Render(tmp_texture, nullptr, mp_rendererSoftware, &rec); // Render to the mp_rendererSoftware - - SDL_RenderReadPixels(mp_rendererSoftware, nullptr, SDL_PIXELFORMAT_RGBA32, rtn->pixels, rtn->pitch); - return rtn; } @@ -266,7 +265,6 @@ const bool cRenderer::AreEqual( SDL_Surface& one, SDL_Surface& two ) if (SDL_MUSTLOCK(&two) > 0) SDL_UnlockSurface(&two); - return rtn; } diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.hpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.hpp index 527c792..9070176 100644 --- a/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.hpp +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cRenderer.hpp @@ -40,11 +40,16 @@ namespace VideoEngine { void RenderDrawColor( const SDL_Colour& colour ); void RenderDrawRect( const SDL_Rect& rect, SDL_Texture* dst = nullptr ); + /* Takes a screen shot by copying the pixels from the Renderer to a new SDL_Surface and Calls SaveSurface(). */ void ScreenShot(const cString& filename, const cString& dir = ""); + /* Saves the SDL_Surface to the given file name and directory */ void SaveSurface( SDL_Surface* surface, const cString& fileName, const cString& dir = "" ); + /* Saves the SDL_Texture to the given file name and directory */ void SaveTexture( SDL_Texture* texture, const cString& fileName, const cString& dir = "" ); + /* Give it a SDL_Surface and it returns a SDL_Texture */ SDL_Texture* SurfaceToTexture( SDL_Surface* surface ); + /* Give it a SDL_Texture and it returns and SDL_Surface */ SDL_Surface* TextureToSurface( SDL_Texture* texture ); void CopyTexture( SDL_Texture* src, SDL_Texture* dst, bool software = false ); @@ -54,6 +59,7 @@ namespace VideoEngine { SDL_Surface* NewSurface( long int width = -1, long int height = -1 ) const; SDL_Texture* NewTexture( long int width = -1, long int height = -1, const bool copyRenderer = false, const unsigned long int access = SDL_TEXTUREACCESS_TARGET ) const; + /* Give it two SDL_Surface you wish to compare returns true if the pixels are the same. */ const bool AreEqual( SDL_Surface& one, SDL_Surface& two ); void SetRenderTarget( SDL_Renderer* renderer, SDL_Texture* target = nullptr ); @@ -67,6 +73,7 @@ namespace VideoEngine { SDL_Renderer* getRendererCopy(); private: + /// Variables SDL_Renderer* mp_renderer; SDL_Renderer* mp_rendererSoftware; diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.cpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.cpp index 9cff9ba..52a62a0 100644 --- a/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.cpp +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.cpp @@ -124,6 +124,17 @@ void cSprite::AddPosY( const signed long int y ) m_position.y += Sint16(y); } +void cSprite::AddPosXPosY( const signed long int x, const signed long int y ) +{ + AddPosX(x); + AddPosY(y); +} + +void VideoEngine::cSprite::AddPosXPosY( const MathEngine::iVector2& addPos /*= MathEngine::iVector2(0, 0)*/ ) +{ + AddPosXPosY(addPos.x, addPos.y); +} + void cSprite::SaveImage( const cString& fileName, const cString& dir /*= ""*/ ) { if (mpp_image != nullptr && *mpp_image != nullptr) { diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.hpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.hpp index b010c8b..1b6446c 100644 --- a/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.hpp +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cSprite.hpp @@ -44,9 +44,16 @@ namespace VideoEngine { /* Draws the sprite to the video buffer with out positioning it */ void DefaltDraw(); + /* Adds X to the position of the sprite */ void AddPosX( const signed long int x ); + /* Adds Y to the position of the sprite */ void AddPosY( const signed long int y ); + /* Adds X and Y to the position of the sprite */ + void AddPosXPosY( const signed long int x, const signed long int y ); + /* Adds X and Y to the Position of the sprite via iVector2 */ + void AddPosXPosY( const MathEngine::iVector2& addPos = MathEngine::iVector2(0, 0) ); + /* Saves the Image to the given file name and directory via cRenderer's SaveTextrue()*/ void SaveImage( const cString& fileName, const cString& dir = "" ); /// Sets diff --git a/TrooperEngineDLL/TrooperEngine/VideoEngine/cVideo.hpp b/TrooperEngineDLL/TrooperEngine/VideoEngine/cVideo.hpp index 92f2caa..9b6a7c7 100644 --- a/TrooperEngineDLL/TrooperEngine/VideoEngine/cVideo.hpp +++ b/TrooperEngineDLL/TrooperEngine/VideoEngine/cVideo.hpp @@ -122,18 +122,18 @@ namespace VideoEngine { static cVideo* sp_inst;/// = nullptr - /*SDL interprets each pixel as a 32-bit number, so our masks must depend + /* SDL interprets each pixel as a 32-bit number, so our masks must depend on the endianness (byte order) of the machine */ #if SDL_BYTEORDER == SDL_BIG_ENDIAN - const unsigned long int m_rmask;// = 0xff000000; - const unsigned long int m_gmask;// = 0x00ff0000; - const unsigned long int m_bmask;// = 0x0000ff00; - const unsigned long int m_amask;// = 0x000000ff; + const unsigned long int m_rmask;/// = 0xff000000; + const unsigned long int m_gmask;/// = 0x00ff0000; + const unsigned long int m_bmask;/// = 0x0000ff00; + const unsigned long int m_amask;/// = 0x000000ff; #else - const unsigned long int m_rmask;// = 0x000000ff; - const unsigned long int m_gmask;// = 0x0000ff00; - const unsigned long int m_bmask;// = 0x00ff0000; - const unsigned long int m_amask;// = 0xff000000; + const unsigned long int m_rmask;/// = 0x000000ff; + const unsigned long int m_gmask;/// = 0x0000ff00; + const unsigned long int m_bmask;/// = 0x00ff0000; + const unsigned long int m_amask;/// = 0xff000000; #endif };/// END CLASS DEFINITION cVideo }/// END NAMESPACE DEFINITION VideoEngine diff --git a/TrooperEngineTest/EventEngineTest/EventEngineTest.hpp b/TrooperEngineTest/EventEngineTest/EventEngineTest.hpp index 57c8562..49e5ab9 100644 --- a/TrooperEngineTest/EventEngineTest/EventEngineTest.hpp +++ b/TrooperEngineTest/EventEngineTest/EventEngineTest.hpp @@ -3,4 +3,4 @@ void EventEngineTest(); -#endif ///__EVENTENGINETEST__ \ No newline at end of file +#endif /// __EVENTENGINETEST__ \ No newline at end of file diff --git a/TrooperEngineTest/MathEngineTest/CollisionTest.cpp b/TrooperEngineTest/MathEngineTest/CollisionTest.cpp new file mode 100644 index 0000000..0e57e62 --- /dev/null +++ b/TrooperEngineTest/MathEngineTest/CollisionTest.cpp @@ -0,0 +1,98 @@ +#include "CollisionTest.hpp" + +#include "../UTest/UTest.hpp" + +/*** TrooperEngine DLL Header Files ***/ +#include "TrooperEngine.hpp" + +using MathEngine::cCollision; + +void CollisionTest() +{ + /// cCollision + printf("\nTesting cCollision -----\n\n"); + + UTest u("cCollision"); + SDL_Rect a = { 50, 50, 50, 50 }; + SDL_Rect bLeftTouch = { 0, 50, 50, 50 }; + SDL_Rect bRightTouch = { 100, 50, 50, 50 }; + SDL_Rect bTopTouch = { 50, 0, 50, 50 }; + SDL_Rect bBottomTouch = { 50, 100, 50, 50 }; + + SDL_Rect bxywhTouch = { 1, 1, 49, 49 }; + SDL_Rect bxnotTouch = { 101, 101, 50, 50 }; + + cString boundingbox = "BoundingBox(SDL_Rect a, SDL_Rect b) Check two SDL_Rect "; + + u.test(boundingbox + "that overlap, should return true.", cCollision::BoundingBox(a, a)); + + u.test(boundingbox + "that overlap on the left side only, should return true.", cCollision::BoundingBox(a, bLeftTouch)); + + u.test(boundingbox + "that overlap on the right side only, should return true.", cCollision::BoundingBox(a, bRightTouch)); + + u.test(boundingbox + "that overlap on the Top side only, should return true.", cCollision::BoundingBox(a, bTopTouch)); + + u.test(boundingbox + "that overlap on the Bottom side only, should return true.", cCollision::BoundingBox(a, bBottomTouch)); + + u.test(boundingbox + "one is inside the other, should return true.", cCollision::BoundingBox(a, bxywhTouch)); + + u.test(boundingbox + "that don't overlap, should return false.", !(cCollision::BoundingBox(a, bxnotTouch))); + + ////////////////////////////////////////////////////////////////////////// + /// Vector4 + ////////////////////////////////////////////////////////////////////////// + MathEngine::Vector4 Va = { 50.0, 50.0, 50.0, 50.0 }; + MathEngine::Vector4 VbLeftTouch = { 0.0, 50.0, 50.0, 50.0 }; + MathEngine::Vector4 VbRightTouch = { 100.0, 50.0, 50.0, 50.0 }; + MathEngine::Vector4 VbTopTouch = { 50.0, 0.0, 50.0, 50.0 }; + MathEngine::Vector4 VbBottomTouch = { 50.0, 100.0, 50.0, 50.0 }; + + MathEngine::Vector4 VbxywhTouch = { 1.0, 1.0, 49.0, 49.0 }; + MathEngine::Vector4 VbxnotTouch = { 101.0, 101.0, 50.0, 50.0 }; + + boundingbox = "BoundingBox( const Vector4& a, const Vector4& b ) Check two Vector4 "; + + u.test(boundingbox + "that overlap, should return true.", cCollision::BoundingBox(Va, Va)); + + u.test(boundingbox + "that overlap on the left side only, should return true.", cCollision::BoundingBox(Va, VbLeftTouch)); + + u.test(boundingbox + "that overlap on the right side only, should return true.", cCollision::BoundingBox(Va, VbRightTouch)); + + u.test(boundingbox + "that overlap on the Top side only, should return true.", cCollision::BoundingBox(Va, VbTopTouch)); + + u.test(boundingbox + "that overlap on the Bottom side only, should return true.", cCollision::BoundingBox(Va, VbBottomTouch)); + + u.test(boundingbox + "one is inside the other, should return true.", cCollision::BoundingBox(Va, VbxywhTouch)); + + u.test(boundingbox + "that don't overlap, should return false.", !(cCollision::BoundingBox(Va, VbxnotTouch))); + + ////////////////////////////////////////////////////////////////////////// + /// iVector4 + ////////////////////////////////////////////////////////////////////////// + MathEngine::iVector4 iVa = { 50, 50, 50, 50 }; + MathEngine::iVector4 iVbLeftTouch = { 0, 50, 50, 50 }; + MathEngine::iVector4 iVbRightTouch = { 100, 50, 50, 50 }; + MathEngine::iVector4 iVbTopTouch = { 50, 0, 50, 50 }; + MathEngine::iVector4 iVbBottomTouch = { 50, 100, 50, 50 }; + + MathEngine::iVector4 iVbxywhTouch = { 1, 1, 49, 49 }; + MathEngine::iVector4 iVbxnotTouch = { 101, 101, 50, 50 }; + + boundingbox = "BoundingBox( const iVector4& a, const iVector4& b ) Check two iVector4 "; + + u.test(boundingbox + "that overlap, should return true.", cCollision::BoundingBox(iVa, iVa)); + + u.test(boundingbox + "that overlap on the left side only, should return true.", cCollision::BoundingBox(iVa, iVbLeftTouch)); + + u.test(boundingbox + "that overlap on the right side only, should return true.", cCollision::BoundingBox(iVa, iVbRightTouch)); + + u.test(boundingbox + "that overlap on the Top side only, should return true.", cCollision::BoundingBox(iVa, iVbTopTouch)); + + u.test(boundingbox + "that overlap on the Bottom side only, should return true.", cCollision::BoundingBox(iVa, iVbBottomTouch)); + + u.test(boundingbox + "one is inside the other, should return true.", cCollision::BoundingBox(iVa, iVbxywhTouch)); + + u.test(boundingbox + "that don't overlap, should return false.", !(cCollision::BoundingBox(iVa, iVbxnotTouch))); + + u.report(); +} \ No newline at end of file diff --git a/TrooperEngineTest/MathEngineTest/CollisionTest.hpp b/TrooperEngineTest/MathEngineTest/CollisionTest.hpp new file mode 100644 index 0000000..8c970b4 --- /dev/null +++ b/TrooperEngineTest/MathEngineTest/CollisionTest.hpp @@ -0,0 +1,6 @@ +#ifndef __COLLISIONTEST__ +#define __COLLISIONTEST__ + +void CollisionTest(); + +#endif /// __COLLISIONTEST__ \ No newline at end of file diff --git a/TrooperEngineTest/MathEngineTest/MathEngineTest.cpp b/TrooperEngineTest/MathEngineTest/MathEngineTest.cpp new file mode 100644 index 0000000..f2ac401 --- /dev/null +++ b/TrooperEngineTest/MathEngineTest/MathEngineTest.cpp @@ -0,0 +1,8 @@ +#include "MathEngineTest.hpp" + +#include "CollisionTest.hpp" + +void MathEngineTest() +{ + CollisionTest(); +} \ No newline at end of file diff --git a/TrooperEngineTest/MathEngineTest/MathEngineTest.hpp b/TrooperEngineTest/MathEngineTest/MathEngineTest.hpp new file mode 100644 index 0000000..25e8e5f --- /dev/null +++ b/TrooperEngineTest/MathEngineTest/MathEngineTest.hpp @@ -0,0 +1,6 @@ +#ifndef __MATHENGINETEST__ +#define __MATHENGINETEST__ + +void MathEngineTest(); + +#endif /// __MATHENGINETEST__ diff --git a/TrooperEngineTest/TrooperEngineTest.vcxproj b/TrooperEngineTest/TrooperEngineTest.vcxproj index 91ec715..e748ada 100644 --- a/TrooperEngineTest/TrooperEngineTest.vcxproj +++ b/TrooperEngineTest/TrooperEngineTest.vcxproj @@ -148,6 +148,8 @@ + + @@ -159,6 +161,8 @@ + + diff --git a/TrooperEngineTest/TrooperEngineTest.vcxproj.filters b/TrooperEngineTest/TrooperEngineTest.vcxproj.filters index 32af47e..4f1db0a 100644 --- a/TrooperEngineTest/TrooperEngineTest.vcxproj.filters +++ b/TrooperEngineTest/TrooperEngineTest.vcxproj.filters @@ -19,6 +19,9 @@ {30bb6c80-fc2a-4954-bf14-10c6dc5aceec} + + {846ddb6a-bcb4-4e29-9be7-e3c249de1213} + @@ -48,6 +51,12 @@ UtitlityEngineTest + + MathEngineTest + + + MathEngineTest + @@ -78,6 +87,12 @@ UtitlityEngineTest + + MathEngineTest + + + MathEngineTest + diff --git a/TrooperEngineTest/main.cpp b/TrooperEngineTest/main.cpp index 66ff722..e46ee38 100644 --- a/TrooperEngineTest/main.cpp +++ b/TrooperEngineTest/main.cpp @@ -28,9 +28,14 @@ see license.txt for details /*** Utility Engine Test ***/ #include "UtilityEngineTest/UtilityEngineTest.hpp" +/*** Math Engine Test ***/ +#include "MathEngineTest/MathEngineTest.hpp" + /*** GUI Engine Test ***/ #include "GUIEngineTest/GUIXMLTest.hpp" +#include + using UtilityEngine::cString; void CleanUp() @@ -43,19 +48,16 @@ int main(int argc, char *argv[]) argc, argv; printf(cString("TrooperEngine V") + TrooperEngineCore::cTrooperEngineCore::Version() + "\n"); - - + VideoEngineTest(); - UtilityEngineTest(); - + UtilityEngineTest(); - + MathEngineTest(); - GUIXMLTest(); + //GUIXMLTest(); //ImageTest(); - UTest::OverAllReport(); SDL_Event event; @@ -90,7 +92,5 @@ int main(int argc, char *argv[]) CleanUp(); - //system("pause"); - return 0; } \ No newline at end of file diff --git a/TrooperEngineTest/unzoom.bmp b/TrooperEngineTest/unzoom.bmp new file mode 100644 index 0000000..037e9b9 Binary files /dev/null and b/TrooperEngineTest/unzoom.bmp differ diff --git a/TrooperEngineTest/xml/GUIXMLSizerTest.xml b/TrooperEngineTest/xml/GUIXMLSizerTest.xml index 773a5f8..5ab978e 100644 --- a/TrooperEngineTest/xml/GUIXMLSizerTest.xml +++ b/TrooperEngineTest/xml/GUIXMLSizerTest.xml @@ -4,7 +4,7 @@ - + diff --git a/TrooperEngineTest/zoom.bmp b/TrooperEngineTest/zoom.bmp new file mode 100644 index 0000000..ccd55c2 Binary files /dev/null and b/TrooperEngineTest/zoom.bmp differ