SDXFrameWork 0.12 SDXFrameWork

- Main Page
- Related Pages
- Classes

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 &加算値)
123 {
124 return {this->x + 加算値.x , this->y + 加算値.y};
125 }
126
127 };
128 }
SDX::Rect
矩形を表す図形クラス.
Definition: Rect.h:22
SDX::Point::y
double y
座標
Definition: Point.h:26
SDX::Line
太さのある線を表す図形クラス.
Definition: Line.h:20
SDX::Point::operator+
Point operator+(const Point &加算値)
座標の加算.
Definition: Point.h:122
SDX::Point::Point
Point(double X座標, double Y座標)
コンストラクタ.
Definition: Point.h:31
SDX::Point::GetW
double GetW() const override
幅を取得.
Definition: Point.h:73
SDX::Point::Hit
bool Hit(const Point *point) const override
衝突判定.
Definition: Point.h:107
SDX::Complex::shapes
std::vector< IShape * > shapes
保持するShape
Definition: Complex.h:23
SDX::Point::GetY
double GetY() const override
Y座標を取得.
Definition: Point.h:68
SDX::Point::Point
Point(TA X座標, TB Y座標)
コンストラクタ.
Definition: Point.h:38
SDX::Point
点を表す図形クラス.
Definition: Point.h:22
SDX::IShape
衝突判定可能な図形の抽象クラス.
Definition: IShape.h:21
SDX::IShape::Hit
virtual bool Hit(const IShape *iShape) const =0
衝突判定.
SDX::Complex
複合図形を表すクラス.
Definition: Complex.h:20
SDX::Point::Draw
void Draw(const Color &描画色) const override
描画する.
Definition: ShapeDraw.h:18
SDX::Color
色を表すクラス.
Definition: Color.h:11
SDX::Point::SetPos
void SetPos(double X座標, double Y座標) override
指定座標に移動.
Definition: Point.h:51
SDX::Point::GetH
double GetH() const override
高さを取得.
Definition: Point.h:78
SDX::Point::Rotate
void Rotate(double 回転する角度) override
回転する.
Definition: Point.h:89
SDX::Point::Hit
bool Hit(const IShape *shape) const override
衝突判定.
Definition: Point.h:95
SDX::IPosition::zoomX
double zoomX
図形の拡大率
Definition: IPosition.h:14
SDX::Point::x
double x
座標
Definition: Point.h:25
SDX::Point::Move
void Move(double X移動量, double Y移動量) override
相対座標で移動.
Definition: Point.h:57
SDX::Point::Clone
IShape * Clone(double X座標, double Y座標) const override
同じ形の図形を作る.
Definition: Point.h:43
SDX::Circle
円を表す図形クラス.
Definition: Circle.h:20
SDX::Point::MultiZoom
void MultiZoom(double X倍率, double Y倍率) override
縦横別で拡大率を掛け算する.
Definition: Point.h:83
SDX::IPosition::zoomY
double zoomY
図形の拡大率
Definition: IPosition.h:15
SDX::Point::Hit
bool Hit(const Complex *complex) const override
衝突判定.
Definition: Point.h:99
SDX::Point::GetX
double GetX() const override
X座標を取得.
Definition: Point.h:63