-
Notifications
You must be signed in to change notification settings - Fork 0
/
Zako2.cpp
124 lines (100 loc) · 1.68 KB
/
Zako2.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
@brief Zako2.hppの実装
@author 吉村
*/
#include "Include\Zako2.hpp"
#include "Include\Game.hpp"
#include <cassert>
#include <random>
#include <DxLib.h>
std::random_device rnd; // 非決定的な乱数生成器
Zako2::Zako2()
: img(new Image)
, Movintime(180)
, Wait(60)
, attacktime(180)
{
img->Load("Images/Characters/zako1_1.png", "idle_1");
img->Load("Images/Characters/zako1_2.png", "idle_2");
img->Load("Images/Characters/zako1_3.png", "idle_3");
Initialize();
}
Zako2::~Zako2()
{
}
void Zako2::Initialize()
{
pos = Vector2D(160., 100.);
}
void Zako2::Update(const Player& player)
{
Move();
HitCheck();
}
void Zako2::Draw()
{
switch(attackPhase)
{
case 0:
img->Draw(pos.x, pos.y, "idle_1", true);
break;
case 1:
img->Draw(pos.x, pos.y, "idle_2", true);
break;
case 2:
const bool& IS_ATK = (movin_count % 4 < 2);
if (IS_ATK)
img->Draw(pos.x, pos.y, "idle_3", true);
else
img->Draw(pos.x, pos.y, "idle_1", true);
break;
}
}
void Zako2::Move()
{
if (movin_count < Movintime)
{
attackPhase = 0;
switch (movemuki)
{
case 0:
if (pos.x < BD_RIGHT)
pos.x++;
else
movin_count = Movintime;
break;
case 1:
if (pos.x > BD_LEFT)
pos.x--;
else
movin_count = Movintime;
break;
case 2:
if (pos.y < BD_TOP)
pos.y++;
else
movin_count = Movintime;
break;
case 3:
if (pos.y > BD_BOTTOM)
pos.y--;
else
movin_count = Movintime;
break;
}
}
else if(movin_count<Movintime+Wait)
attackPhase = 1;
else if (movin_count < Movintime + Wait + attacktime)
attackPhase = 2;
else
{
movin_count = 0;
movemuki = rnd()%4;
}
movin_count++;
}
bool Zako2::HitCheck()
{
return false;
}