Add class Point.

This commit is contained in:
Kirigaya Kazuto 2017-02-18 01:46:18 +08:00 committed by GitHub
parent fa85782ae7
commit 7668ef5756

View File

@ -11,6 +11,7 @@ namespace MiniEngine
{ {
using namespace std; using namespace std;
class Rect class Rect
{ {
public: public:
@ -30,6 +31,34 @@ namespace MiniEngine
return r; return r;
} }
}; };
class Point
{
public:
int x,y;
Point(int X,int Y)
{
x=X;y=Y;
}
Point()
{
x=y=0;
}
SDL_Point toSDLPoint()
{
SDL_Point p;
p.x=x;
p.y=y;
return p;
}
bool inRect(Rect rect)
{
auto p=toSDLPoint();
auto r=rect.toSDLRect();
return SDL_PointInRect(&p,&r);
}
};
class RGBA class RGBA
{ {
public: public:
@ -46,8 +75,9 @@ namespace MiniEngine
{ {
SDL_Color c; SDL_Color c;
c.r = r;c.g = g;c.b = b;c.a = a; c.r = r;c.g = g;c.b = b;c.a = a;
return c;
} }
}; };
class NonCopyable class NonCopyable
{ {
@ -145,13 +175,13 @@ namespace MiniEngine
RGBA pack(r, g, b, a); RGBA pack(r, g, b, a);
return pack; return pack;
} }
int Renderer::fillRect(Rect rect) int fillRect(Rect rect)
{ {
auto inr = rect.toSDLRect(); auto inr = rect.toSDLRect();
return SDL_RenderFillRect(rnd.get(), &inr); return SDL_RenderFillRect(rnd.get(), &inr);
} }
int Renderer::drawRect(Rect rect) int drawRect(Rect rect)
{ {
auto inr = rect.toSDLRect(); auto inr = rect.toSDLRect();
return SDL_RenderDrawRect(rnd.get(), &inr); return SDL_RenderDrawRect(rnd.get(), &inr);
@ -357,14 +387,14 @@ namespace MiniEngine
Mix_Quit(); Mix_Quit();
} }
void Init() static void Init()
{ {
SDLInit(); SDLInit();
IMGInit(); IMGInit();
TTFInit(); TTFInit();
MixInit(); MixInit();
} }
void Quit() static void Quit()
{ {
MixQuit(); MixQuit();
TTFQuit(); TTFQuit();
@ -378,6 +408,6 @@ namespace MiniEngine
} }
}; };
}/// End of namespace MiniEngine }/// End of namespace MiniEngine