-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBullet.cpp
82 lines (71 loc) · 1.3 KB
/
Bullet.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
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
#include "DXUT.h"
#include "Bullet.h"
void Bullet_Manager::Make_Bullet(Map* map)
{
for (int i = 0; i < 100; i++)
{
Bullet* b = new Bullet(map);
// map->AddChild(b, 3);
_bullets.push_back(b);
}
}
void Bullet_Manager::Shot_Bullet(vector2 startpos, vector2 shotpower, t_shot_type shot_tpye, t_obj_type obj_type)
{
for (auto it : _bullets)
{
if (!it->_visible)
{
it->shotpos = startpos;
it->_position = startpos;
it->v = shotpower;
it->_visible = true;
it->mytype = obj_type;
return;
}
}
}
void Bullet_Manager::Delete_Bullet()
{
for (auto it : _bullets)
delete it;
_bullets.clear();
}
Bullet::Bullet(Map* map)
{
Create(L"Weapon.png");
_map = map;
_visible = false;
}
Bullet::~Bullet()
{
}
void Bullet::Update()
{
if (!_visible)
return;
shotpos += v * Time::deltaTime * 100;
v += Time::deltaTime * g;
//cout << _map->_position.x * -1<< endl;
//_position += v * Time::deltaTime * 100;
_position = shotpos;
_rotation = atan2(v.y, v.x);
//if(_position.x < 0)
//{
// _visible = false;
// return;
//}
if (_map->_mapData[shotpos.x][shotpos.y].a > 0)
{
_visible = false;
}
}
void Bullet::CollideBullet(Obj* obj)
{
RECT TEMP;
if (!IntersectRect(&TEMP, &GetRect(), &obj->GetRect()))
return;
if (obj->_mytpye == mytype)
return;
obj->isHit();
_visible = false;
}