SDXFrameWork  0.09
SDXFrameWork
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Object.h
1 #pragma once//©SDXFramework http://sourceforge.jp/projects/dxframework/
2 #include <SDXFramework.h>
3 #include <Framework/ModelMove.h>
4 #include <Utility/Module.h>
5 
6 namespace SDX
7 {
9 enum class Belong
10 {
11  Ally,
12  EnemyF,
13  EnemyG,
14  Item,
15  Block,
16  Etc,
17 };
18 
21 class IObject : public IModel
22 {
23 friend class Layer;
24 
25 protected:
26  int timer = 0;
27  bool isRemove = false;
28  bool isOutCheck = true;
29  double power;
30  int attribute;
31  int lifeTime = -1;
33 
35  virtual bool RemoveCheck(Rect* 存在可能範囲)
36  {
37  if(
38  timer == this->lifeTime ||
39  (isOutCheck && !shape->Hit( 存在可能範囲 ) )
40  )
41  {
42  this->isRemove = true;
43  }
44 
45  if (isRemove) Remove();
46 
47  return this->isRemove;
48  }
49 
51  virtual void Attack(Object *攻撃対象 )
52  {
53  攻撃対象->Damaged( power );
54  }
55 
56  void SetTimer(int フレーム数)
57  {
58  timer = フレーム数;
59  }
60 
61 public:
63  IObject( IShape &図形 , ISprite &描画方法 , double 攻撃力 = 0 , Belong 所属 = Belong::Etc):
64  IModel(図形, 描画方法),
65  ModelMove(this),
66  power(攻撃力),
67  belong(所属)
68  {}
69 
71  int GetTimer()
72  {
73  return timer;
74  }
75 
76  virtual ~Object(){}
77 
79  virtual void Update()
80  {
81  this->timer++;
82  AnimeUpdate();
83  this->Act();
84  }
85 
88  {
89  return isRemove;
90  }
91 
92  void SetRemoveFlag(bool 消滅フラグ)
93  {
94  isRemove = 消滅フラグ;
95  }
96 
99  {
100  return belong;
101  }
102 
104  virtual void Act(){}
105 
107  virtual void Remove(){}
108 
110  virtual void React(){}
111 
113  virtual void Damaged(double 被ダメージ){}
114 
115 };
116 
118 template <class TShape,class TSprite>
119 class Object : public IObject
120 {
121  public:
122  TShape shape;
123  TSprite sprite;
124 
125  Object(const TShape &図形と位置, const TSprite &描画方法):
126  shape(図形と位置),
127  sprite(描画方法)
128  {}
129 
130 };
131 
132 }
矩形を表す図形クラス.
Definition: Shape.h:536
virtual void Damaged(double 被ダメージ)
攻撃された時の処理.
Definition: Object.h:113
Model派生のサンプルクラス.
Definition: Object.h:119
int timer
発生してから経過したフレーム数
Definition: Object.h:26
int GetTimer()
発生後経過時間を返す.
Definition: Object.h:71
void AnimeUpdate()
アニメーションを更新する.
Definition: Model.h:92
地上の敵
Belong GetBelong()
所属を取得.
Definition: Object.h:98
virtual void Update()
状態の更新.
Definition: Object.h:79
位置情報を持つ図形の抽象クラス.
Definition: IShape .h:18
virtual void Attack(Object *攻撃対象)
衝突した相手に攻撃する.
Definition: Object.h:51
空中の敵
bool GetRemoveFlag()
消滅フラグの取得.
Definition: Object.h:87
アイテム
int lifeTime
生存期間
Definition: Object.h:31
2Dモデルに貼り付けるスプライトを表す抽象クラス.
Definition: ISprite.h:14
Belong
所属するレイヤーの識別子.
Definition: Object.h:9
int attribute
攻撃属性
Definition: Object.h:30
virtual void React()
ダメージを受けた時の処理.
Definition: Object.h:110
virtual void Remove()
消滅時の処理.
Definition: Object.h:107
virtual void Act()
Update時の行動処理.
Definition: Object.h:104
ShapeとSpriteをまとめて、2Dモデルを表すクラス.
Definition: Model.h:12
bool isOutCheck
範囲外処理を行うかフラグ
Definition: Object.h:28
IObject(IShape &図形, ISprite &描画方法, double 攻撃力=0, Belong 所属=Belong::Etc)
説明.
Definition: Object.h:63
Belong belong
所属するレイヤー
Definition: Object.h:32
double power
攻撃力
Definition: Object.h:29
ModelにSTG用の機能を追加したサンプルクラス.
Definition: Object.h:21
virtual bool RemoveCheck(Rect *存在可能範囲)
消滅判定を行う.
Definition: Object.h:35
bool isRemove
消滅フラグ
Definition: Object.h:27