SDXFrameWork  0.13
SDXFrameWork
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Point.h
1 //Copyright © 2014 SDXFramework
2 //[License]GNU Affero General Public License, version 3
3 //[Contact]http://sourceforge.jp/projects/dxframework/
4 #pragma once
5 
6 #include <Framework/IShape.h>
7 #include <SDL.h>
8 
9 namespace SDX
10 {
11  class Complex;
12  class Point;
13  class Line;
14  class Circle;
15  class Rect;
16 
17  class Camera;
18  class Color;
19 
22  class Point : public IShape
23  {
24  public:
25  double x = 0;
26  double y = 0;
27 
28  Point(){}
29 
31  Point(double X座標, double Y座標) :
32  x(X座標),
33  y(Y座標)
34  {}
35 
36  template<class TA, class TB>
38  Point(TA X座標, TB Y座標) :
39  x(X座標),
40  y(Y座標)
41  {}
42 
43  IShape* Clone(double X座標, double Y座標) const override
44  {
45  auto shape = new Point(X座標, Y座標);
46  shape->zoomX = this->zoomX;
47  shape->zoomY = this->zoomY;
48  return shape;
49  }
50 
51  void SetPos(double X座標, double Y座標) override
52  {
53  this->x = X座標;
54  this->y = Y座標;
55  }
56 
57  void Move(double X移動量, double Y移動量) override
58  {
59  this->x += X移動量;
60  this->y += Y移動量;
61  }
62 
63  double GetX() const override
64  {
65  return x;
66  }
67 
68  double GetY() const override
69  {
70  return y;
71  }
72 
73  double GetW() const override
74  {
75  return 1;
76  }
77 
78  double GetH() const override
79  {
80  return 1;
81  }
82 
83  void MultiZoom(double X倍率, double Y倍率) override
84  {
85  zoomX *= X倍率;
86  zoomY *= Y倍率;
87  }
88 
89  void Rotate(double 回転する角度) override
90  {
91  }
92 
93  void Draw(const Color &描画色) const override;
94 
95  bool Hit(const IShape *shape) const override
96  {
97  return shape->Hit(this);
98  }
99  bool Hit(const Complex *complex) const override
100  {
101  for (auto it : complex->shapes)
102  {
103  if (it->Hit(this)) return true;
104  }
105  return false;
106  }
107  bool Hit(const Point *point) const override
108  {
109  return (point->x == this->x && point->y == this->y);
110  }
111  bool Hit(const Line *line) const override;
112  bool Hit(const Rect *rect) const override;
113  bool Hit(const Circle *circle) const override;
114 
116  operator SDL_Point() const
117  {
118  return{ (int)x, (int)y };
119  }
120 
122  Point operator +(const Point &加算値) const
123  {
124  return {this->x + 加算値.x , this->y + 加算値.y};
125  }
126 
127  Point operator -(const Point &加算値) const
128  {
129  return{ this->x - 加算値.x, this->y - 加算値.y };
130  }
131  };
132 }
矩形を表す図形クラス.
Definition: Rect.h:22
double y
座標
Definition: Point.h:26
太さのある線を表す図形クラス.
Definition: Line.h:20
Point(double X座標, double Y座標)
コンストラクタ.
Definition: Point.h:31
double GetW() const override
幅を取得.
Definition: Point.h:73
bool Hit(const Point *point) const override
衝突判定.
Definition: Point.h:107
std::vector< IShape * > shapes
保持するShape
Definition: Complex.h:23
double GetY() const override
Y座標を取得.
Definition: Point.h:68
Point(TA X座標, TB Y座標)
コンストラクタ.
Definition: Point.h:38
Point operator+(const Point &加算値) const
座標の加算.
Definition: Point.h:122
点を表す図形クラス.
Definition: Point.h:22
衝突判定可能な図形の抽象クラス.
Definition: IShape.h:21
virtual bool Hit(const IShape *iShape) const =0
衝突判定.
複合図形を表すクラス.
Definition: Complex.h:20
void Draw(const Color &描画色) const override
描画する.
Definition: ShapeDraw.h:18
色を表すクラス.
Definition: Color.h:11
void SetPos(double X座標, double Y座標) override
指定座標に移動.
Definition: Point.h:51
double GetH() const override
高さを取得.
Definition: Point.h:78
void Rotate(double 回転する角度) override
回転する.
Definition: Point.h:89
bool Hit(const IShape *shape) const override
衝突判定.
Definition: Point.h:95
double zoomX
図形の拡大率
Definition: IPosition.h:14
double x
座標
Definition: Point.h:25
void Move(double X移動量, double Y移動量) override
相対座標で移動.
Definition: Point.h:57
IShape * Clone(double X座標, double Y座標) const override
同じ形の図形を作る.
Definition: Point.h:43
円を表す図形クラス.
Definition: Circle.h:20
void MultiZoom(double X倍率, double Y倍率) override
縦横別で拡大率を掛け算する.
Definition: Point.h:83
double zoomY
図形の拡大率
Definition: IPosition.h:15
bool Hit(const Complex *complex) const override
衝突判定.
Definition: Point.h:99
double GetX() const override
X座標を取得.
Definition: Point.h:63