-
Notifications
You must be signed in to change notification settings - Fork 0
/
Weapon.cpp
53 lines (42 loc) · 871 Bytes
/
Weapon.cpp
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
#include "Weapon.h"
Weapon::Weapon()
{
}
Weapon::~Weapon()
{
}
bool Weapon::Initialize()
{
weaponMesh.Initialize("models/acr.x");
for (int i = 0; i < 10; i++) {
Bullet *temp = new Bullet();
bulletList.push_back(temp);
}
for (int i = 0; i < bulletList.size(); i++)
bulletList[i]->Initialize();
return true;
}
bool Weapon::Render(float deltaTime)
{
// set position and render
Device->GetTransform(D3DTS_WORLD, &T);
D3DXMatrixTranslation(&O, 2, -2, 4);
W = O*T;
Device->SetTransform(D3DTS_WORLD, &W);
weaponMesh.Render();
// render active bullets
for (int i = 0; i < bulletList.size(); i++) {
if (bulletList[i]->active)
bulletList[i]->Render(deltaTime);
}
return true;
}
D3DXMATRIX Weapon::CreateBullet()
{
for (int i = 0; i < bulletList.size(); i++) {
if (!bulletList[i]->active) {
bulletList[i]->Spawn(&W);
return W;
}
}
}