SDXFrameWork 0.09 SDXFrameWork

- Main Page
- Related Pages
- Classes

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
SDX::IShape Class Referenceabstract

位置情報を持つ図形の抽象クラス. More...

`#include <IShape .h>`

Inherited by SDX::Circle, SDX::Complex, SDX::Line, SDX::Point, and SDX::Rect.

## Public Member Functions
virtual bool | Hit (const IShape *IShape) const =0
| 衝突判定. More...
virtual bool | Hit (const Complex *complex) const =0
virtual bool | Hit (const Point *point) const =0
virtual bool | Hit (const Line *line) const =0
virtual bool | Hit (const Rect *rect) const =0
virtual bool | Hit (const Circle *circle) const =0
virtual void | SetPos (double X座標, double Y座標)=0
| 指定座標に移動. More...
virtual IShape * | Clone (double x, double y) const =0
| 同じ形の図形を作る. More...
void | SetZoom (double X拡大率, double Y拡大率)
| 拡大率を設定. More...
void | MultiZoom (double 倍率)
| 拡大率を掛け算する. More...
virtual void | MultiZoom (double X倍率, double Y倍率)=0
| 縦横別で拡大率を掛け算する. More...
virtual void | Move (double X移動量, double Y移動量)=0
| 相対座標で移動. More...
void | MoveA (double 距離, double 方向)
| 極座標で移動. More...
virtual void | Draw (Color 描画色, int 透過率, Camera *座標変換Camera=nullptr) const =0
| 描画する. More...
virtual void | Rotate (double 回転する角度)=0
| 回転する. More...
virtual void | SetAngle (double 指定角度)=0
| 角度を指定する. More...
double | GetDirect (IShape *比較対象)
| 対象との角度を取得. More...
double | GetDistance (IShape *比較対象)
| 対象との相対座標を取得. More...
virtual double | GetX () const =0
| X座標を取得. More...
virtual double | GetY () const =0
| Y座標を取得. More...
virtual double | GetW () const =0
| 幅を取得. More...
virtual double | GetH () const =0
| 高さを取得. More...

## Static Protected Member Functions
static bool | RectRect (double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
| 矩形の交差判定. More...
static bool | LineLine (double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
| 線分の交差判定. More...
static int | PointPoint (double x1, double y1, double x2, double y2)
| 二点間の距離を計算. More...

## Protected Attributes
double | zoomX
double | zoomY

## Detailed Description

位置情報を持つ図形の抽象クラス.

//©SDXFramework http://sourceforge.jp/projects/dxframework/
//🍣図形の当たり判定をする
bool SampleShape()
{
using namespace SDX;
System::Initialise("sample", 600, 400);
//図形を宣言する
Circle circle(10, 10, 100);
Rect rect(60, 60, 100, 100);
Line line(200, 100, PAI / 4, 300, 5);
//共通のインターフェースを持っている
IShape* shapes[3];
shapes[0] = &circle;
shapes[1] = &rect;
shapes[2] = &line;
while (System::Update())
{
circle.SetPos(Input::mouse.x, Input::mouse.y);
//Lineは回転可能
line.Rotate(0.01);
//ダブルディスパッチによる当たり判定
bool isHit[3];
isHit[0] = circle.Hit(&rect) || circle.Hit(&line);
isHit[1] = shapes[1]->Hit(shapes[0]) || shapes[1]->Hit(shapes[2]);
isHit[2] = shapes[2]->Hit(shapes[0]) || shapes[2]->Hit(shapes[1]);
for (int a = 0; a < 3; ++a)
{
if (isHit[a])
{
shapes[a]->Draw(Color::Red, 255);
}
else
{
shapes[a]->Draw(Color::White, 255);
}
}
if (Input::key.Return.on) break;//Enterで終了
}
System::End();
return true;
}

## Member Function Documentation

static bool SDX::IShape::RectRect | ( | double | x1,
|  | double | y1,
|  | double | x2,
|  | double | y2,
|  | double | x3,
|  | double | y3,
|  | double | x4,
|  | double | y4
| ) |  |
| static protected

矩形の交差判定.

static bool SDX::IShape::LineLine | ( | double | x1,
|  | double | y1,
|  | double | x2,
|  | double | y2,
|  | double | x3,
|  | double | y3,
|  | double | x4,
|  | double | y4
| ) |  |
| static protected

線分の交差判定.

static int SDX::IShape::PointPoint | ( | double | x1,
|  | double | y1,
|  | double | x2,
|  | double | y2
| ) |  |
| static protected

二点間の距離を計算.

virtual bool SDX::IShape::Hit | ( | const IShape * | IShape | ) | const
| pure virtual

衝突判定.

Implemented in SDX::Circle, SDX::Rect, SDX::Line, SDX::Point, and SDX::Complex.

virtual void SDX::IShape::SetPos | ( | double | X座標,
|  | double | Y座標
| ) |  |
| pure virtual

指定座標に移動.

Implemented in SDX::Circle, SDX::Rect, SDX::Line, SDX::Point, and SDX::Complex.

virtual IShape* SDX::IShape::Clone | ( | double | x,
|  | double | y
| ) |  | const
| pure virtual

同じ形の図形を作る.

Implemented in SDX::Circle, SDX::Rect, SDX::Line, SDX::Point, and SDX::Complex.

void SDX::IShape::SetZoom | ( | double | X拡大率,
|  | double | Y拡大率
| ) |  |

拡大率を設定.

void SDX::IShape::MultiZoom | ( | double | 倍率 | ) |

拡大率を掛け算する.

virtual void SDX::IShape::MultiZoom | ( | double | X倍率,
|  | double | Y倍率
| ) |  |
| pure virtual

縦横別で拡大率を掛け算する.

Implemented in SDX::Circle, SDX::Rect, SDX::Line, SDX::Point, and SDX::Complex.

virtual void SDX::IShape::Move | ( | double | X移動量,
|  | double | Y移動量
| ) |  |
| pure virtual

相対座標で移動.

Implemented in SDX::Circle, SDX::Rect, SDX::Line, SDX::Point, and SDX::Complex.

void SDX::IShape::MoveA | ( | double | 距離,
|  | double | 方向
| ) |  |

極座標で移動.

virtual void SDX::IShape::Draw | ( | Color | 描画色,
|  | int | 透過率,
|  | Camera * | 座標変換Camera = `nullptr`
| ) |  | const
| pure virtual

描画する.

Implemented in SDX::Circle, SDX::Rect, SDX::Line, SDX::Point, and SDX::Complex.

virtual void SDX::IShape::Rotate | ( | double | 回転する角度 | ) |
| pure virtual

回転する.

Implemented in SDX::Circle, SDX::Rect, SDX::Line, SDX::Point, and SDX::Complex.

virtual void SDX::IShape::SetAngle | ( | double | 指定角度 | ) |
| pure virtual

角度を指定する.

Implemented in SDX::Circle, SDX::Rect, SDX::Line, SDX::Point, and SDX::Complex.

double SDX::IShape::GetDirect | ( | IShape * | 比較対象 | ) |

対象との角度を取得.

double SDX::IShape::GetDistance | ( | IShape * | 比較対象 | ) |

対象との相対座標を取得.

virtual double SDX::IShape::GetX | ( |  | ) | const
| pure virtual

X座標を取得.

Implemented in SDX::Circle, SDX::Rect, SDX::Line, SDX::Point, and SDX::Complex.

virtual double SDX::IShape::GetY | ( |  | ) | const
| pure virtual

Y座標を取得.

Implemented in SDX::Circle, SDX::Rect, SDX::Line, SDX::Point, and SDX::Complex.

virtual double SDX::IShape::GetW | ( |  | ) | const
| pure virtual

幅を取得.

Implemented in SDX::Circle, SDX::Rect, SDX::Line, SDX::Point, and SDX::Complex.

virtual double SDX::IShape::GetH | ( |  | ) | const
| pure virtual

高さを取得.

Implemented in SDX::Circle, SDX::Rect, SDX::Line, SDX::Point, and SDX::Complex.