SDXFrameWork 0.12 SDXFrameWork

- Main Page
- Related Pages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

衝突判定可能な図形の抽象クラス. More...

`#include <IShape.h>`

Inherits SDX::IPosition.

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

## Public Member Functions
virtual IShape * | Clone (double x, double y) const =0
| 同じ形の図形を作る. More...
virtual bool | Hit (const IShape *iShape) const =0
| 衝突判定. More...
virtual bool | Hit (const Complex *complex) const =0
| 衝突判定. More...
virtual bool | Hit (const Point *point) const =0
| 衝突判定. More...
virtual bool | Hit (const Line *line) const =0
| 衝突判定. More...
virtual bool | Hit (const Rect *rect) const =0
| 衝突判定. More...
virtual bool | Hit (const Circle *circle) const =0
| 衝突判定. More...
virtual void | Draw (const Color &描画色) const =0
| 描画する. More...
Public Member Functions inherited from SDX::IPosition
virtual void | SetPos (double X座標, double Y座標)=0
| 指定座標に移動. More...
virtual void | MultiZoom (double X倍率, double Y倍率)=0
| 縦横別で拡大率を掛け算する. More...
void | SetZoom (double X拡大率, double Y拡大率)
| 拡大率を設定. More...
void | MultiZoom (double 倍率)
| 拡大率を掛け算する. More...
virtual void | Move (double X移動量, double Y移動量)=0
| 相対座標で移動. More...
void | MoveA (double 距離, double 方向)
| 極座標で移動. More...
void | MoveF (double 距離)
| 前方に移動. More...
virtual void | Rotate (double 回転する角度)=0
| 回転する. More...
virtual double | GetAngle () const
| 角度を取得する. More...
void | SetAngle (double 指定角度)
| 角度を指定する. More...
double | GetDirect (IPosition *比較対象) const
| 対象との角度を取得. More...
double | GetDistance (IPosition *比較対象) const
| 対象との相対座標を取得. 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...
virtual void | SetPos (double X座標, double Y座標)=0
| 指定座標に移動. More...
virtual void | MultiZoom (double X倍率, double Y倍率)=0
| 縦横別で拡大率を掛け算する. More...
virtual void | SetZoom (double X拡大率, double Y拡大率)
| 拡大率を設定. More...
void | MultiZoom (double 倍率)
| 拡大率を掛け算する. More...
virtual void | Move (double X移動量, double Y移動量)=0
| 相対座標で移動. More...
void | MoveA (double 距離, double 方向)
| 極座標で移動. More...
virtual void | Rotate (double 回転する角度)=0
| 回転する. More...
virtual double | GetAngle () const
| 角度を取得する. More...
virtual void | SetAngle (double 指定角度)
| 角度を指定する. More...
double | GetDirect (IPosition *比較対象) const
| 対象との角度を取得. More...
double | GetDistance (IPosition *比較対象) const
| 対象との相対座標を取得. More...
double | CompareAngle (double 角度)
| 角度の差を計算する
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...

## Additional Inherited Members
Protected Attributes inherited from SDX::IPosition
double | zoomX = 1
| 図形の拡大率
double | zoomY = 1
| 図形の拡大率

## Detailed Description

衝突判定可能な図形の抽象クラス.

//Copyright © 2014 SDXFramework
//[License]GNU Affero General Public License, version 3
//[Contact]http://sourceforge.jp/projects/dxframework/
//図形の当たり判定をする
#include <SDXFramework.h>
bool SampleShape()
{
using namespace SDX;
System::Initialise("sample", 640, 480);
//図形を宣言する
Circle circle(10, 10, 100);
Rect rect(60, 60, 100, 100);
Line line(200, 100, PAI / 4, 600, 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);
//ダブルディスパッチによる当たり判定
for (int a = 0; a < 3; ++a)
{
int hit = 0;
for (int b = 0; b < 3; ++b)
{
if (a == b){ continue; }
hit += shapes[a]->Hit(shapes[b]);
}
if ( hit == 0)
{
shapes[a]->Draw(Color::White);
}
else if (hit == 1)
{
shapes[a]->Draw(Color::Red);
}
else
{
shapes[a]->Draw(Color::Blue);
}
}
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
| ) |  |
| inline static protected

矩形の交差判定.

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

線分の交差判定.

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

二点間の距離を計算.

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

同じ形の図形を作る.

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

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

衝突判定.

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

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

衝突判定.

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

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

衝突判定.

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

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

衝突判定.

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

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

衝突判定.

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

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

衝突判定.

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

virtual void SDX::IShape::Draw | ( | const Color & | 描画色 | ) | const
| pure virtual

描画する.

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