1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | #pragma once #include <SDL.h> #include <memory> using std::shared_ptr; using std::unique_ptr; class DisplayObject { private: shared_ptr<SDL_Renderer> renderer; shared_ptr<SDL_Texture> texture; SDL_Rect rect; double angle; SDL_Point center; SDL_RendererFlip flip; Uint8 alpha; Uint8 r, g, b; public: // (w && h) == 0 이면 tex의 w,h를 query한다. DisplayObject(shared_ptr<SDL_Renderer> ren, shared_ptr<SDL_Texture> tex, int x, int y, int w = 0, int h = 0, double angle = 0.0, SDL_RendererFlip flip = SDL_FLIP_NONE, Uint8 alpha = 255, Uint8 red = 255, Uint8 green = 255, Uint8 blue = 255); //기본 구현 정의되어있음 virtual void renderCopy() = 0; //getter const int X() const{ return rect.x; } const int Y() const{ return rect.y; } const int W() const{ return rect.w; } const int H() const{ return rect.h; } const SDL_RendererFlip Flip() const{ return flip; } const double Angle() const{ return angle; } const Uint8 Alpha() const{ return alpha; } const Uint8 R() const{ return r; } const Uint8 G() const{ return g; } const Uint8 B() const{ return b; } //center는 rect에 상대적인 좌표다. w/2면 중심 const int CenterX() const{ return center.x; } //center는 rect에 상대적인 좌표다. h/2면 중심 const int CenterY() const{ return center.y; } //setter void X(int x){ rect.x = x; } void Y(int y){ rect.y = y; } void XY(int x, int y){ rect.x = x; rect.y = y; } void W(int width){ rect.w = width; } void H(int height){ rect.h = height; } void WH(int width, int height){ rect.w = width; rect.h = height; } void Flip(SDL_RendererFlip f){ flip = f; } void Angle(double a){ angle = a; } void Alpha(Uint8 alp){ alpha = alp; } void R(Uint8 red){ r = red; } void G(Uint8 green){ g = green; } void B(Uint8 blue){ b = blue; } void setRGB(Uint8 red, Uint8 green, Uint8 blue){ //비프렌드 비멤버? 글쎄.. r = red; g = green; b = blue; } //center는 rect에 상대적인 좌표다. (w/2, h/2)면 중심 void CenterXY(int x, int y){ center.x = x; center.y = y; } }; | cs |
...
getter setter 자동 생성해주는 거 찾아봐야겠다.
setRGB는 RGB라는 매크로가 SDL에 정의되어 있더라..
게터세터 한가득ㅋㅋㅋㅋ