-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFireBullet.cpp
70 lines (53 loc) · 1.48 KB
/
FireBullet.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
#include "FireBullet.h"
CFireBullet::CFireBullet(float x, float y, int nx, int owner) {
this->x = x;
this->y = y;
this->nx = nx;
this->owner = owner;
this->isDisable = true;
}
void CFireBullet::PrepareForShooting() {
vy = VELOCITY_Y_FIRE_BULLET;
}
void CFireBullet::UpdatePos(Vector2 pos, int nx) {
this->x = pos.x;
this->y = pos.y + INITIAL_DELTA_Y_FIRE_BULLET;
this->nx = nx;
}
void CFireBullet::CollidedLeftRight(LPGAMEOBJECT obj) {
if(owner == 0)
this->isDisable = true;
CGameObject::CollidedLeftRight(obj);
}
void CFireBullet::OnHadCollided(LPGAMEOBJECT obj) {
obj->BeingCollided(this);
}
void CFireBullet::CollidedTop(LPGAMEOBJECT obj) {
CGameObject::CollidedTop(obj);
if(owner == 0) vy = -VELOCITY_Y_FIRE_BULLET_BOUNCE;
}
void CFireBullet::Update(DWORD dt, vector<LPGAMEOBJECT>* coObjects) {
if (isDisable) return;
if (owner == 0) {
vx = VELOCITY_X_FIRE_BULLET * nx * dt;
ApplyGravity();
}
if (owner == 1) {
vx = 0.07f * venusBulletDirection.x;
vy = 0.05f * venusBulletDirection.y;
}
CGameObject::Update(dt, coObjects);
UpdateWithCollision(coObjects);
}
void CFireBullet::GetBoundingBox(float& left, float& top, float& right, float& bottom)
{
left = x - FIRE_BULLET_WIDTH / 2;
top = y - FIRE_BULLET_HEIGHT / 2;
right = x + FIRE_BULLET_WIDTH / 2;
bottom = y + FIRE_BULLET_HEIGHT /2;
}
void CFireBullet::Render(Vector2 finalPos) {
CAnimations::GetInstance()->Get(ANI_FIRE_BULLET)
->Render(finalPos, Vector2(nx,ny), 255);
//RenderBoundingBox(finalPos);
}