-
Notifications
You must be signed in to change notification settings - Fork 2
/
EnemyBulletFire.cpp
79 lines (63 loc) · 1.91 KB
/
EnemyBulletFire.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
//=====================================
//
//エネミーバレットファイア処理[EnemyBulletFire.cpp]
//Author:GP12A332 21 立花雄太
//
//=====================================
#include "EnemyBulletFire.h"
#include "Framework\Easing.h"
/**************************************
マクロ定義
***************************************/
#define ENEMYBULLETFIRE_LIFE_MIN (10)
#define ENEMYBULLETFIRE_LIFE_MAX (30)
#define ENEMYBULLETFIRE_SPEED_MAX (20.0f)
#define ENEMYBULLETFIRE_SPEED_MIN (15.0f)
/**************************************
EnemyBulletFire初期化処理
***************************************/
void EnemyBulletFire::Init()
{
cntFrame = 0;
active = true;
lifeFrame = RandomRange(ENEMYBULLETFIRE_LIFE_MIN, ENEMYBULLETFIRE_LIFE_MAX);
moveDir.x = RandomRangef(-1.0f, 1.0f);
moveDir.y = RandomRangef(-1.0f, 1.0f);
moveDir.z = 1.0f;
D3DXVec3Normalize(&moveDir, &moveDir);
speed = RandomRangef(ENEMYBULLETFIRE_SPEED_MIN, ENEMYBULLETFIRE_SPEED_MAX);
}
/**************************************
EnemyBulletFire更新処理
***************************************/
void EnemyBulletFire::Update()
{
static const float EndSpeed = 0.0f;
static const float InitScale = 1.0f;
static const float EndScale = 0.0f;
cntFrame++;
float t = (float)cntFrame / lifeFrame;
float currentSpeed = Easing::EaseValue(t, speed, EndSpeed, EaseType::OutCubic);
transform.pos += moveDir * currentSpeed;
transform.scale = D3DXVECTOR3(1.0f, 1.0f, 1.0f) * Easing::EaseValue(t, InitScale, EndScale, EaseType::InExpo);
if (cntFrame == lifeFrame)
active = false;
}
/**************************************
EnemyBulletFireEmitter初期化処理
***************************************/
void EnemyBulletFireEmitter::Init()
{
cntFrame = 0;
active = true;
duration = 5;
}
/**************************************
EnemyBulletFireEmitter更新処理
***************************************/
void EnemyBulletFireEmitter::Update()
{
cntFrame++;
if (cntFrame == duration)
active = false;
}