sadafumi / hackathon

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DirectX Library

1.同名のソース・ヘッダーファイルを作成
例:Player.cpp, Player.h

2.ソースファイルにはヘッダーファイルをインクルードして、ヘッダーファイルのはLib/core.cppをインクルードする。
例:Player.cpp -> #include "Player.h", Player.h -> #include "Lib/core.cpp"

3.ヘッダー内にObjectクラスを継承したクラスを作って、InitとUpdate関数をオーバーロードする。
例:
class Player : public Object
{
public:
void Init(void);
void Update(void);
private:
float speed;
}

4.ソースファイルのほうにInitとUpdate関数の中身を書く。
例:
void Player::Init(void)
{
this->SetTexture(TEXTURE_PLAYER);
}

void Player::Update(void)
{
if (Input::uKeys['W'])
this->Move(Vector3(0.0f, -0.5f, 0.0f));
if (Input::uKeys['S'])
this->Move(Vector3(0.0f, 0.5f, 0.0f));
if (Input::uKeys['A'])
this->UpdateAngle(-1.0f);
if (Input::uKeys['D'])
this->UpdateAngle(1.0f);
}

5.3で作ったクラス型のグローバル変数を宣言する。
Player g_player;

About


Languages

Language:C++ 100.0%