Add MathEngineTest and Commects and clean ups
This commit is contained in:
@@ -33,7 +33,6 @@ namespace AudioEngine {
|
||||
/* Plays the music */
|
||||
void MusicPlay();
|
||||
|
||||
|
||||
/// Set
|
||||
/* Sets the rate */
|
||||
void setRate( const unsigned long int rate = 22050 );
|
||||
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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<EventEngine::cEvent*>& GetEvents();
|
||||
|
||||
|
||||
///Sets
|
||||
/// Sets
|
||||
|
||||
///Gets
|
||||
/// Gets
|
||||
/* Gets return true if Event was initialized */
|
||||
const bool IsInit() const;
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
std::vector<cEvent*> m_children;
|
||||
static cEventControl* sp_inst;// = nullptr
|
||||
};/// END CLASS DEFINITION cEventControl
|
||||
|
||||
@@ -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;
|
||||
|
||||
zoomSurface(surface, zoomx, zoomy, smooth);
|
||||
|
||||
texture = cRenderer::Inst().SurfaceToTexture(surface);
|
||||
SDL_Surface* zoom_sur = zoomSurface(surface, zoomx, zoomy, smooth);
|
||||
|
||||
SDL_FreeSurface(surface);
|
||||
surface = nullptr;
|
||||
|
||||
SDL_Texture* rtn = cRenderer::Inst().SurfaceToTexture(zoom_sur);
|
||||
|
||||
SDL_FreeSurface(zoom_sur);
|
||||
zoom_sur = nullptr;
|
||||
|
||||
return rtn;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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_
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace GUIHelpers {
|
||||
void LoadDefault() const;
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
bool m_loadDef;/// = false;
|
||||
bool m_debugXML;/// = false;
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace GUIEngine {
|
||||
void GenerateTexture();
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
VideoEngine::cImage* mp_texture;/// = nullptr
|
||||
VideoEngine::cImage* mp_texturePress;/// = nullptr
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ namespace GUIEngine {
|
||||
const bool IsInit() const;
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
static cGUI* sp_inst;/// = nullptr
|
||||
|
||||
unsigned long int m_debugLevel;/// = 0
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace GUIEngine {
|
||||
void SetSize();
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
VideoEngine::cSprite m_sprite;
|
||||
TextTypeEngine::cText* mp_text;/// = nullptr
|
||||
};/// END CLASS DEFINITION cLabel
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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_
|
||||
@@ -40,6 +40,7 @@ namespace GUIEngine {
|
||||
virtual const GUIHelpers::RGBA& getDebugColour() const;
|
||||
private:
|
||||
private:
|
||||
/// Variables
|
||||
};/// END CLASS DEFINITION cSizer
|
||||
}/// END NAMESPACE DEFINITION GUIEngine
|
||||
#endif/// END IFNDEF _CSIZER_HPP_
|
||||
@@ -56,6 +56,7 @@ namespace GUIEngine {
|
||||
void GenerateTexture();
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
cLabel m_label;/// = nullptr
|
||||
};/// END CLASS DEFINITION cButton
|
||||
}/// END NAMESPACE DEFINITION GUIEngine
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace InputEngine {
|
||||
const bool IsInit() const;
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
std::vector<InputEngine::cKeyboard*> m_keyboards;
|
||||
|
||||
SDL_Event m_event;
|
||||
|
||||
@@ -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_
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -24,7 +24,6 @@ EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::vector<InputEngine::cKey*,
|
||||
/*#pragma warning (default : 4231)*/
|
||||
|
||||
namespace InputEngine {
|
||||
/* Singleton */
|
||||
class EXPORT_FROM_MYDLL cKeyboard
|
||||
{
|
||||
public:
|
||||
@@ -47,6 +46,7 @@ namespace InputEngine {
|
||||
const cString& getLabel() const;
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
cString m_label;/// = ""
|
||||
|
||||
std::vector<InputEngine::cKey*> m_keys;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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_
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -28,13 +28,12 @@ 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
|
||||
|
||||
|
||||
/// Sets
|
||||
/* Sets the Directory of the TTF file */
|
||||
void setDir( const cString& dir );
|
||||
@@ -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<TextTypeHelpers::cFontHolder*> 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_
|
||||
@@ -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,38 +179,18 @@ 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);
|
||||
|
||||
//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();
|
||||
SDL_Texture* texture = cGFX::Inst().StringTexture(m_text, pos, m_colour);
|
||||
|
||||
if (texture != nullptr) {
|
||||
if (m_size > 8) {
|
||||
SDL_Texture* newTexture = cRenderer::Inst().NewTexture(((m_size / 4) * m_text.length()), m_size);
|
||||
|
||||
//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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,12 +168,12 @@ 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);
|
||||
|
||||
Render(tmp_texture, nullptr, mp_rendererSoftware, &rec); // Render to the mp_rendererSoftware
|
||||
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);
|
||||
|
||||
SDL_RenderReadPixels(mp_rendererSoftware, nullptr, SDL_PIXELFORMAT_RGBA32, rtn->pixels, rtn->pitch);
|
||||
ResetRenderTarget();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
void EventEngineTest();
|
||||
|
||||
#endif ///__EVENTENGINETEST__
|
||||
#endif /// __EVENTENGINETEST__
|
||||
@@ -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();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __COLLISIONTEST__
|
||||
#define __COLLISIONTEST__
|
||||
|
||||
void CollisionTest();
|
||||
|
||||
#endif /// __COLLISIONTEST__
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "MathEngineTest.hpp"
|
||||
|
||||
#include "CollisionTest.hpp"
|
||||
|
||||
void MathEngineTest()
|
||||
{
|
||||
CollisionTest();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __MATHENGINETEST__
|
||||
#define __MATHENGINETEST__
|
||||
|
||||
void MathEngineTest();
|
||||
|
||||
#endif /// __MATHENGINETEST__
|
||||
@@ -148,6 +148,8 @@
|
||||
<ClCompile Include="EventEngineTest\EventEngineTest.cpp" />
|
||||
<ClCompile Include="GUIEngineTest\GUIXMLTest.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="MathEngineTest\CollisionTest.cpp" />
|
||||
<ClCompile Include="MathEngineTest\MathEngineTest.cpp" />
|
||||
<ClCompile Include="UTest\UTest.cpp" />
|
||||
<ClCompile Include="UtilityEngineTest\StringTest.cpp" />
|
||||
<ClCompile Include="UtilityEngineTest\UtilityEngineTest.cpp" />
|
||||
@@ -159,6 +161,8 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="EventEngineTest\EventEngineTest.hpp" />
|
||||
<ClInclude Include="GUIEngineTest\GUIXMLTest.hpp" />
|
||||
<ClInclude Include="MathEngineTest\CollisionTest.hpp" />
|
||||
<ClInclude Include="MathEngineTest\MathEngineTest.hpp" />
|
||||
<ClInclude Include="UTest\UTest.hpp" />
|
||||
<ClInclude Include="UtilityEngineTest\StringTest.hpp" />
|
||||
<ClInclude Include="UtilityEngineTest\UtilityEngineTest.hpp" />
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
<Filter Include="EventEngineTest">
|
||||
<UniqueIdentifier>{30bb6c80-fc2a-4954-bf14-10c6dc5aceec}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="MathEngineTest">
|
||||
<UniqueIdentifier>{846ddb6a-bcb4-4e29-9be7-e3c249de1213}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="UTest\UTest.hpp">
|
||||
@@ -48,6 +51,12 @@
|
||||
<ClInclude Include="UtilityEngineTest\UtilityEngineTest.hpp">
|
||||
<Filter>UtitlityEngineTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MathEngineTest\CollisionTest.hpp">
|
||||
<Filter>MathEngineTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MathEngineTest\MathEngineTest.hpp">
|
||||
<Filter>MathEngineTest</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="UTest\UTest.cpp">
|
||||
@@ -78,6 +87,12 @@
|
||||
<ClCompile Include="UtilityEngineTest\UtilityEngineTest.cpp">
|
||||
<Filter>UtitlityEngineTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MathEngineTest\CollisionTest.cpp">
|
||||
<Filter>MathEngineTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MathEngineTest\MathEngineTest.cpp">
|
||||
<Filter>MathEngineTest</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="xml\GUI.xml">
|
||||
|
||||
@@ -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 <string>
|
||||
|
||||
using UtilityEngine::cString;
|
||||
|
||||
void CleanUp()
|
||||
@@ -44,19 +49,16 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf(cString("TrooperEngine V") + TrooperEngineCore::cTrooperEngineCore::Version() + "\n");
|
||||
|
||||
|
||||
VideoEngineTest();
|
||||
|
||||
UtilityEngineTest();
|
||||
|
||||
MathEngineTest();
|
||||
|
||||
|
||||
|
||||
GUIXMLTest();
|
||||
//GUIXMLTest();
|
||||
|
||||
//ImageTest();
|
||||
|
||||
|
||||
UTest::OverAllReport();
|
||||
SDL_Event event;
|
||||
bool run = true;
|
||||
@@ -90,7 +92,5 @@ int main(int argc, char *argv[])
|
||||
|
||||
CleanUp();
|
||||
|
||||
//system("pause");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -4,7 +4,7 @@
|
||||
<Layout>
|
||||
<!--<Include dir ="xml/" filename="include.xml"/>-->
|
||||
<Sizer />
|
||||
<Label>Sizer</Label>
|
||||
<Label fontsize="16">Sizer</Label>
|
||||
<Sizer />
|
||||
<Sizer />
|
||||
</Layout>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
Reference in New Issue
Block a user