SDXFrameWork 0.12 SDXFrameWork

- Main Page
- Related Pages
- Classes

All Classes Namespaces Functions Variables Enumerations Enumerator Pages
IModel.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 #include <Framework/Sprite.h>
6 #include <Framework/Shape.h>
7
8 namespace SDX
9 {
12 class IModel : public IPosition
13 {
14 private:
15 double angle = 0;
16 double shadowSize = 1;
17 protected:
18 bool isRemove = false;
19 public:
20 IShape &iShape;
21 ISprite &iSprite;
22
24 IModel(IShape &図形, ISprite &描画方法) :
25 iShape(図形),
26 iSprite(描画方法)
27 {}
28
29 virtual ~IModel() = default;
30
32 bool GetRemoveFlag() const
33 {
34 return isRemove;
35 }
36
38 virtual void Update(){}
39
41 void SetShadowSize(double 影の表示倍率)
42 {
43 shadowSize = 影の表示倍率;
44 }
45
47 virtual void Draw() const
48 {
49 iSprite.Draw( iShape );
50
51 //当たり判定を表示するならコメントアウト解除
52 //iShape.Draw({255,0,0,128} );
53 }
54
56 void DrawShadow(double X座標ずれ, double Y座標ずれ)
57 {
58 if (shadowSize <= 0) return;
59
60 X座標ずれ *= shadowSize;
61 Y座標ずれ *= shadowSize;
62
63 double zoomX = iSprite.zoomX;
64 double zoomY = iSprite.zoomY;
65 iSprite.zoomX *= shadowSize;
66 iSprite.zoomY *= shadowSize;
67
68 iSprite.gap.Move(X座標ずれ,Y座標ずれ);
69 iSprite.Draw( iShape);
70 iSprite.gap.Move(-X座標ずれ, -Y座標ずれ);
71
72 iSprite.zoomX = zoomX;
73 iSprite.zoomY = zoomY;
74 }
75
77 void SetPos(double X座標, double Y座標) override
78 {
79 iShape.SetPos(X座標, Y座標);
80 }
81
83 void MultiZoom(double X倍率, double Y倍率) override
84 {
85 zoomX *= X倍率;
86 zoomY *= Y倍率;
87
88 iShape.MultiZoom(X倍率, Y倍率);
89 iSprite.MultiZoom(X倍率, Y倍率);
90 }
91
93 void Move(double X移動量, double Y移動量) override
94 {
95 iShape.Move(X移動量, Y移動量);
96 }
97
99 void Rotate(double 回転角度) override
100 {
101 angle += 回転角度;
102 iSprite.Rotate(回転角度);
103 iShape.Rotate(回転角度);
104 }
105
107 double GetAngle() const override
108 {
109 return angle;
110 }
111
113 double GetX() const override
114 {
115 return iShape.GetX();
116 }
117
119 double GetY() const override
120 {
121 return iShape.GetY();
122 }
123
125 double GetW() const override
126 {
127 return iShape.GetW();
128 }
129
131 double GetH() const override
132 {
133 return iShape.GetH();
134 }
135
137 void SetColor(const Color &描画色)
138 {
139 iSprite.color = 描画色;
140 }
141
143 double GetZoomX() const
144 {
145 return zoomX;
146 }
147
149 double GetZoomY() const
150 {
151 return zoomY;
152 }
153
155 bool Hit(const IModel *判定を行うModel) const
156 {
157 return iShape.Hit(&判定を行うModel->iShape);
158 }
159
161 bool Hit(const IShape *判定を行うShape) const
162 {
163 return iShape.Hit(判定を行うShape);
164 }
165 };
166 }
SDX::IModel::iShape
IShape & iShape
対応Shape
Definition: IModel.h:20
SDX::IModel::iSprite
ISprite & iSprite
対応Sprite
Definition: IModel.h:21
SDX::IModel::isRemove
bool isRemove
消滅フラグ
Definition: IModel.h:18
SDX::IPosition::GetW
virtual double GetW() const =0
幅を取得.
SDX::IModel::SetPos
void SetPos(double X座標, double Y座標) override
指定座標に移動.
Definition: IModel.h:77
SDX::IModel::GetH
double GetH() const override
Y座標を取得.
Definition: IModel.h:131
SDX::IPosition::GetH
virtual double GetH() const =0
高さを取得.
SDX::IModel::Draw
virtual void Draw() const
描画する.
Definition: IModel.h:47
SDX::IModel::DrawShadow
void DrawShadow(double X座標ずれ, double Y座標ずれ)
影を描画する.
Definition: IModel.h:56
SDX::ISprite::Rotate
void Rotate(double 回転する角度)
回転させる.
Definition: ISprite.h:84
SDX::IModel::GetAngle
double GetAngle() const override
角度を取得する.
Definition: IModel.h:107
SDX::ISprite::Draw
virtual void Draw(const IShape &図形)=0
ISpriteを描画する.
SDX::IShape
衝突判定可能な図形の抽象クラス.
Definition: IShape.h:21
SDX::IModel::GetZoomX
double GetZoomX() const
横方向の拡大率を取得.
Definition: IModel.h:143
SDX::IModel::SetColor
void SetColor(const Color &描画色)
色をまとめて変更する、透明度も含む.
Definition: IModel.h:137
SDX::IShape::Hit
virtual bool Hit(const IShape *iShape) const =0
衝突判定.
SDX::IModel::GetRemoveFlag
bool GetRemoveFlag() const
消滅フラグの取得.
Definition: IModel.h:32
SDX::IPosition::MultiZoom
virtual void MultiZoom(double X倍率, double Y倍率)=0
縦横別で拡大率を掛け算する.
SDX::ISprite::zoomY
double zoomY
描画倍率
Definition: ISprite.h:22
SDX::IModel::Rotate
void Rotate(double 回転角度) override
回転させる.
Definition: IModel.h:99
SDX::ISprite::color
Color color
描画色
Definition: ISprite.h:27
SDX::ISprite
2Dモデルに貼り付けるスプライトを表す抽象クラス.
Definition: ISprite.h:17
SDX::IPosition::Rotate
virtual void Rotate(double 回転する角度)=0
回転する.
SDX::IModel::SetShadowSize
void SetShadowSize(double 影の表示倍率)
影の大きさを設定.
Definition: IModel.h:41
SDX::IPosition::GetY
virtual double GetY() const =0
Y座標を取得.
SDX::Color
色を表すクラス.
Definition: Color.h:11
SDX::IPosition::Move
virtual void Move(double X移動量, double Y移動量)=0
相対座標で移動.
SDX::IModel::MultiZoom
void MultiZoom(double X倍率, double Y倍率) override
縦横別で拡大率を掛ける.
Definition: IModel.h:83
SDX::IModel::Hit
bool Hit(const IModel *判定を行うModel) const
Modelとの衝突判定.
Definition: IModel.h:155
SDX::IModel::Update
virtual void Update()
更新処理を行う.
Definition: IModel.h:38
SDX::IModel::GetW
double GetW() const override
X座標を取得.
Definition: IModel.h:125
SDX::IModel::IModel
IModel(IShape &図形, ISprite &描画方法)
コンストラクタ.
Definition: IModel.h:24
SDX::ISprite::gap
Point gap
Shape中心とSpriteとの位置差
Definition: ISprite.h:28
SDX::IModel::Hit
bool Hit(const IShape *判定を行うShape) const
Shapeとの衝突判定.
Definition: IModel.h:161
SDX::IPosition::zoomX
double zoomX
図形の拡大率
Definition: IPosition.h:14
SDX::IModel::Move
void Move(double X移動量, double Y移動量) override
相対座標で移動.
Definition: IModel.h:93
SDX::IModel::GetX
double GetX() const override
X座標を取得.
Definition: IModel.h:113
SDX::IPosition::SetPos
virtual void SetPos(double X座標, double Y座標)=0
指定座標に移動.
SDX::IPosition
位置と方向を持つクラスのインターフェース.
Definition: IPosition.h:11
SDX::IModel
ShapeとSpriteをまとめて、2Dモデルを表すクラス.
Definition: IModel.h:12
SDX::Point::Move
void Move(double X移動量, double Y移動量) override
相対座標で移動.
Definition: Point.h:57
SDX::ISprite::MultiZoom
void MultiZoom(double 倍率)
拡大率を掛け算する.
Definition: ISprite.h:44
SDX::IPosition::GetX
virtual double GetX() const =0
X座標を取得.
SDX::IModel::GetY
double GetY() const override
Y座標を取得.
Definition: IModel.h:119
SDX::ISprite::zoomX
double zoomX
描画倍率
Definition: ISprite.h:21
SDX::IPosition::zoomY
double zoomY
図形の拡大率
Definition: IPosition.h:15
SDX::IModel::GetZoomY
double GetZoomY() const
縦方向の拡大率を取得.
Definition: IModel.h:149