SDXFrameWork 0.10 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>`

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...
virtual void | SetPos (double X座標, double Y座標)=0
| 指定座標に移動. More...
virtual void | SetPos (double X座標, double Y座標)=0
| 指定座標に移動. More...
virtual void | MultiZoom (double X倍率, double Y倍率)=0
| 縦横別で拡大率を掛け算する. More...
void | MultiZoom (double 倍率)
| 拡大率を掛け算する. More...
virtual void | MultiZoom (double X倍率, double Y倍率)=0
| 縦横別で拡大率を掛け算する. More...
void | MultiZoom (double 倍率)
| 拡大率を掛け算する. More...
void | SetZoom (double X拡大率, double Y拡大率)
| 拡大率を設定. More...
virtual void | SetZoom (double X拡大率, double Y拡大率)
| 拡大率を設定. More...
virtual void | Move (double X移動量, double Y移動量)=0
| 相対座標で移動. More...
virtual void | Move (double X移動量, double Y移動量)=0
| 相対座標で移動. More...
void | MoveA (double 距離, double 方向)
| 極座標で移動. More...
void | MoveA (double 距離, double 方向)
| 極座標で移動. More...
void | MoveF (double 距離)
| 前方に移動. More...
virtual void | Rotate (double 回転する角度)=0
| 回転する. More...
virtual void | Rotate (double 回転する角度)=0
| 回転する. More...
virtual double | GetAngle () const
| 角度を取得する. More...
virtual double | GetAngle () const
| 角度を取得する. More...
void | SetAngle (double 指定角度)
| 角度を指定する. More...
virtual void | SetAngle (double 指定角度)
| 角度を指定する. More...
double | GetDirect (IPosition *比較対象) const
| 対象との角度を取得. More...
double | GetDirect (IPosition *比較対象) const
| 対象との角度を取得. More...
double | GetDistance (IPosition *比較対象) const
| 対象との相対座標を取得. More...
double | GetDistance (IPosition *比較対象) const
| 対象との相対座標を取得. More...
virtual double | GetX () const =0
| X座標を取得. More...
virtual double | GetX () const =0
| X座標を取得. More...
virtual double | GetY () const =0
| Y座標を取得. More...
virtual double | GetY () const =0
| Y座標を取得. More...
virtual double | GetW () const =0
| 幅を取得. More...
virtual double | GetW () const =0
| 幅を取得. More...
virtual double | GetH () const =0
| 高さを取得. More...
virtual double | GetH () const =0
| 高さを取得. More...
double | CompareAngle (double 角度)
| 角度の差を計算する

## 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 = 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
| ) |  |
| 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 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.

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

指定座標に移動.

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

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

指定座標に移動.

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

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

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

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

void SDX::IPosition::MultiZoom | ( | double | 倍率 | ) |
| inherited

拡大率を掛け算する.

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

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

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

void SDX::IPosition::MultiZoom | ( | double | 倍率 | ) |
| inherited

拡大率を掛け算する.

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

拡大率を設定.

virtual void SDX::IPosition::SetZoom | ( | double | X拡大率,
|  | double | Y拡大率
| ) |  |
| virtual inherited

拡大率を設定.

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

相対座標で移動.

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

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

相対座標で移動.

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

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

極座標で移動.

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

極座標で移動.

void SDX::IPosition::MoveF | ( | double | 距離 | ) |
| inherited

前方に移動.

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

回転する.

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

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

回転する.

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

virtual double SDX::IPosition::GetAngle | ( |  | ) | const
| virtual inherited

角度を取得する.

Reimplemented in SDX::Line, and SDX::IModel.

virtual double SDX::IPosition::GetAngle | ( |  | ) | const
| virtual inherited

角度を取得する.

Reimplemented in SDX::Line, and SDX::IModel.

void SDX::IPosition::SetAngle | ( | double | 指定角度 | ) |
| inherited

角度を指定する.

virtual void SDX::IPosition::SetAngle | ( | double | 指定角度 | ) |
| virtual inherited

角度を指定する.

double SDX::IPosition::GetDirect | ( | IPosition * | 比較対象 | ) | const
| inherited

対象との角度を取得.

double SDX::IPosition::GetDirect | ( | IPosition * | 比較対象 | ) | const
| inherited

対象との角度を取得.

double SDX::IPosition::GetDistance | ( | IPosition * | 比較対象 | ) | const
| inherited

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

double SDX::IPosition::GetDistance | ( | IPosition * | 比較対象 | ) | const
| inherited

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

virtual double SDX::IPosition::GetX | ( |  | ) | const
| pure virtual inherited

X座標を取得.

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

virtual double SDX::IPosition::GetX | ( |  | ) | const
| pure virtual inherited

X座標を取得.

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

virtual double SDX::IPosition::GetY | ( |  | ) | const
| pure virtual inherited

Y座標を取得.

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

virtual double SDX::IPosition::GetY | ( |  | ) | const
| pure virtual inherited

Y座標を取得.

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

virtual double SDX::IPosition::GetW | ( |  | ) | const
| pure virtual inherited

幅を取得.

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

virtual double SDX::IPosition::GetW | ( |  | ) | const
| pure virtual inherited

幅を取得.

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

virtual double SDX::IPosition::GetH | ( |  | ) | const
| pure virtual inherited

高さを取得.

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

virtual double SDX::IPosition::GetH | ( |  | ) | const
| pure virtual inherited

高さを取得.

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