-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtatemono.cpp
More file actions
173 lines (138 loc) · 4.21 KB
/
tatemono.cpp
File metadata and controls
173 lines (138 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//=============================================================================
//
// エネミー処理 [enemy.cpp]
// 作成者 : GP11A132 11 蔡文権
// 作成日 : 2023 / 12 / 06
//=============================================================================
#include "main.h"
#include "renderer.h"
#include "model.h"
#include "debugproc.h"
#include "tatemono.h"
#include "collision.h"
#include "input.h"
//*****************************************************************************
// マクロ定義
//*****************************************************************************
#define VALUE_MOVE (2.5f) // 移動量
#define VALUE_ROTATE (XM_PI * 0.02f) // 回転量
static char* g_ObjectName[MAX_TATE] = {
"data/MODEL/TokyoTowerPart1.obj",
"data/MODEL/TokyoTowerPart2.obj",
"data/MODEL/TokyoTowerPart3.obj",
"data/MODEL/TokyoTowerPart4.obj",
};
//*****************************************************************************
// プロトタイプ宣言
//*****************************************************************************
//*****************************************************************************
// グローバル変数
//*****************************************************************************
static TATE g_Tate[MAX_TATE]; // エネミー
static int g_Level;
//=============================================================================
// 初期化処理
//=============================================================================
HRESULT InitTate(void)
{
g_Level = 0;
for (int i = 0; i < MAX_TATE; i++)
{
LoadModel(g_ObjectName[i], &g_Tate[i].model);
g_Tate[i].load = TRUE;
g_Tate[i].pos = XMFLOAT3(0.0f, i*TATE_SIZE+10.0f, 0.0f);
g_Tate[i].rot = XMFLOAT3(0.0f, 0.0f, 0.0f);
g_Tate[i].scl = XMFLOAT3(1.0f, 1.0f, 1.0f);
g_Tate[i].spd = 1.0f; // 移動スピードクリア
g_Tate[i].size = 10.0f; // 当たり判定の大きさ
g_Tate[i].count = 0;
// モデルのディフューズを保存しておく。色変え対応の為。
GetModelDiffuse(&g_Tate[i].model, &g_Tate[i].diffuse[0]);
g_Tate[i].use = TRUE;
}
return S_OK;
}
//=============================================================================
// 終了処理
//=============================================================================
void UninitTate(void)
{
for (int i = 0; i < MAX_TATE; i++)
{
if (g_Tate[i].load)
{
UnloadModel(&g_Tate[i].model);
g_Tate[i].load = FALSE;
}
}
}
//=============================================================================
// 更新処理
//=============================================================================
void UpdateTate(void)
{
// 現段階をカウントする
int count = 0;
for (int i = 0; i < MAX_TATE; i++)
{
if (g_Tate[i].use)
{
count++;
}
}
for (int i = 0; i < MAX_TATE; i++)
{
if (g_Tate[i].use)
{
if (g_Tate[i].pos.y > (i * TATE_SIZE + 10.0f))
{
g_Tate[i].pos.y += VALUE_MOVE;
}
}
}
g_Level = count;
#ifdef _DEBUG
#endif
}
//=============================================================================
// 描画処理
//=============================================================================
void DrawTate(void)
{
XMMATRIX mtxScl, mtxRot, mtxTranslate, mtxWorld;
// カリング無効
SetCullingMode(CULL_MODE_NONE);
for (int i = 0; i < MAX_TATE; i++)
{
if (g_Tate[i].use == FALSE) continue;
// ワールドマトリックスの初期化
mtxWorld = XMMatrixIdentity();
// スケールを反映
mtxScl = XMMatrixScaling(g_Tate[i].scl.x, g_Tate[i].scl.y, g_Tate[i].scl.z);
mtxWorld = XMMatrixMultiply(mtxWorld, mtxScl);
// 回転を反映
mtxRot = XMMatrixRotationRollPitchYaw(g_Tate[i].rot.x, g_Tate[i].rot.y + XM_PI, g_Tate[i].rot.z);
mtxWorld = XMMatrixMultiply(mtxWorld, mtxRot);
// 移動を反映
mtxTranslate = XMMatrixTranslation(g_Tate[i].pos.x, g_Tate[i].pos.y*i*0.7f, g_Tate[i].pos.z);
mtxWorld = XMMatrixMultiply(mtxWorld, mtxTranslate);
// ワールドマトリックスの設定
SetWorldMatrix(&mtxWorld);
XMStoreFloat4x4(&g_Tate[i].mtxWorld, mtxWorld);
// モデル描画
DrawModel(&g_Tate[i].model);
}
// カリング設定を戻す
SetCullingMode(CULL_MODE_BACK);
}
//=============================================================================
// エネミーの取得
//=============================================================================
TATE *GetTate()
{
return &g_Tate[0];
}
int GetLevel()
{
return g_Level;
}