-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGhost.cpp
97 lines (84 loc) · 2 KB
/
Ghost.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
90
91
92
93
94
95
96
97
#include "Ghost.h"
#include "Common.h"
//#define DEBUG
Ghost::Ghost(int arrayNum)
{
img = LoadGraph("resources/images/enemy_images/devilKing/Weapon/ghost.png");
hp = 1;
respawnTime = SetRespawnTimeGhost(arrayNum);
location = SetRespawnPostionGhost(arrayNum);
radius = 5;
damage = 1;
}
Ghost::~Ghost()
{
DeleteGraph(img);
}
void Ghost::Update(Player* player)
{
//プレイヤーの移動量をdiffにセット
SetPlayerAmountOfTravel_X(player->Player_MoveX());
SetPlayerAmountOfTravel_Y(player->Player_MoveY());
//プレイヤーの座標をdiffLocationにセット
SetPlayer_Location(player->GetLocation());
//画像左右
imgAngle = CheckImgAngle();
vector.x = Normalization_X(PlayerLoad_X(location.x), PlayerLoad_Y(location.y)) * 1.0f;
vector.y = Normalization_Y(PlayerLoad_X(location.x), PlayerLoad_Y(location.y)) * 1.0f;
location.x += vector.x - diff.x;
location.y += vector.y - diff.y;
}
void Ghost::Draw() const
{
if (imgAngle == IMG_L) {//左向き表示
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 155);
DrawRotaGraph((int)location.x, (int)location.y, 1.5, 0, img, TRUE, 1);
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 255);
}
else if (imgAngle == IMG_R) {//右向き表示
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 155);
DrawRotaGraph((int)location.x, (int)location.y, 1.5, 0, img, TRUE, 0);
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 255);
}
#ifdef DEBUG
DrawCircle((int)location.x, (int)location.y, radius, C_RED, FALSE, 2);
#endif // DEBUG
}
int Ghost::SetRespawnTimeGhost(int arrayNum)
{
float r;
if (arrayNum >= 100) {
r = SECOND_FRAME(10);
}
else {
r = SECOND_FRAME(0);
}
return r;
}
Location Ghost::SetRespawnPostionGhost(int arrayNum)
{
Location r;
int section = GetRand(3);
switch (section)
{
case 0://上
r.y = 10;
r.x = SetGetRand(10, 1270);
break;
case 1://下
r.y = 710;
r.x = SetGetRand(10, 1270);
break;
case 2://右
r.x = 1270;
r.y = SetGetRand(10, 710);
break;
case 3://左
r.x = 10;
r.y = SetGetRand(10, 710);
break;
default:
break;
}
return r;
}