forked from YutaTachibana0310/SankouGoudou2019Summer
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccelEffectParticle.cpp
89 lines (74 loc) · 2.21 KB
/
AccelEffectParticle.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
83
84
85
86
87
88
89
//=====================================
//
//アクセルエフェクトパーティクル処理[AccelEffectParticle.cpp]
//Author:GP12A332 21 立花雄太
//
//=====================================
#include "AccelEffectParticle.h"
#include "Framework\Easing.h"
/**************************************
マクロ定義
***************************************/
#define ACCELEFFECT_LIFE_MIN (10)
#define ACCELEFFECT_LIFE_MAX (20)
#define ACCELEFFECT_SCALE (5.0f)
#define ACCELEFFECT_POS_OFFSET (5.0f)
#define ACCELEFFECT_SPEED (8.0f)
#define ACCELEFFECT_MOVE_Z (-2.0f)
/**************************************
AccelEffectParticle初期化処理
***************************************/
void AccelEffectParticle::Init()
{
cntFrame = 0;
active = true;
//移動方向決定
moveDir.x = RandomRangef(-1.0f, 1.0f);
moveDir.y = RandomRangef(-1.0f, 1.0f);
moveDir.z = -0.0f;
D3DXVec3Normalize(&moveDir, &moveDir);
//回転
float dir = moveDir.x > 0.0f ? 1.0f : -1.0f;
D3DXVECTOR3 vecUp = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
float dot = D3DXVec3Dot(&moveDir, &vecUp);
transform.Rotate(0.0f, 0.0f, D3DXToDegree(acosf(dot)) * dir);
//座標オフセット
transform.pos.x += moveDir.x * ACCELEFFECT_POS_OFFSET;
transform.pos.y += moveDir.y * ACCELEFFECT_POS_OFFSET;
//寿命決定
lifeFrame = RandomRange(ACCELEFFECT_LIFE_MIN, ACCELEFFECT_LIFE_MAX);
moveDir.z = ACCELEFFECT_MOVE_Z;
}
/**************************************
AccelEffectParticle更新処理
***************************************/
void AccelEffectParticle::Update()
{
cntFrame++;
float t = (float)cntFrame / lifeFrame;
//スピードイージング
float speed = Easing::EaseValue(t, ACCELEFFECT_SPEED, 0.3f, EaseType::OutCubic);
transform.pos += moveDir * speed;
//スケールイージング
transform.scale.x = Easing::EaseValue(t, 1.0f, 0.0f, EaseType::InCubic);
if (cntFrame == lifeFrame)
active = false;
}
/**************************************
AccelEffectParticleEmitter初期化処理
***************************************/
void AccelEffectParticleEmitter::Init()
{
cntFrame = 0;
duration = 5;
active = true;
}
/**************************************
AccelEffectParticleEmitter更新処理
**************************************/
void AccelEffectParticleEmitter::Update()
{
cntFrame++;
if (cntFrame == duration)
active = false;
}