-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObject.cpp
More file actions
188 lines (151 loc) · 2.64 KB
/
Object.cpp
File metadata and controls
188 lines (151 loc) · 2.64 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#include"Object.h"
Object::Object()
{
pos = &position;
createdTex = false;
actSet = false;
changed = true;
length = 0;
moveCount = 0;
moveCountList = 0;
type = EMPTY;
visible = true;
disappearCount = 0;
disappearInterval = 0;
}
Object::~Object()
{
}
float Object::currentPosX()const
{
return pos->x;
}
float Object::currentPosY()const
{
return pos->y;
}
float Object::getBottom()
{
return 0.0f;
}
void Object::setPos(float px, float py)
{
pos->x = px;
pos->y = py;
changed = true;
}
void Object::setMoveList(float px, float py)
{
if (!actSetList)
{
moveList.emplace_back(Position{ px,py });
}
else
{
cout << "MoveListが終わってからセットする2024 1 5 5:41" << endl;
}
}
void Object::clearMoveList()
{
moveList.clear();
moveList.shrink_to_fit();
}
void Object::actMoveList()
{
actSetList = true;
reverse(moveList.begin(), moveList.end());
}
void Object::setMove(float px, float py)
{
actSet = true;
int lx = static_cast<int>(px - pos->x);
int ly = static_cast<int>(py - pos->y);
length = sqrt(lx * lx + ly * ly);
moveCount = length;
onceMoveX = lx / length;
onceMoveY = ly / length;
}
void Object::setMove(Position p)
{
actSet = true;
int lx = static_cast<int>(p.x - pos->x);
int ly = static_cast<int>(p.y - pos->y);
length = sqrt(lx * lx + ly * ly);
moveCount = length;
onceMoveX = lx / length;
onceMoveY = ly / length;
}
void Object::setMove(float px, float py, int time)
{
actSet = true;
int lx = static_cast<int>(px - pos->x);
int ly = static_cast<int>(py - pos->y);
moveCount = time;
onceMoveX = lx / static_cast<float>(time);
onceMoveY = ly / static_cast<float>(time);
}
bool Object::actMove()
{
if(actSet && moveCount > 0)
{
setPos(pos->x + onceMoveX, pos->y + onceMoveY);
moveCount--;
return false;
}
else
{
actSet = false;
moveCount = 0;
return true;
}
}
void Object::setDisappear(float time, int count)
{
disappearTime = clock();
disappearInterval = time;
disappearCount = count;
}
void Object::disappear()
{
if (disappearCount > 0)
{
if ((clock() - disappearTime) / CLOCKS_PER_SEC >= disappearInterval)
{
disappearTime = clock();
if (visible)
{
visible = false;
}
else
{
visible = true;
disappearCount--;
if (disappearInterval <= 0)
{
disappearInterval = 0.0f;
}
}
}
}
}
void Object::Update()
{
if (disappearInterval)
{
disappear();
}
}
void Object::drawObjects(SDL_Renderer* gRenderer)
{
}
void Object::drawObjectsScroll(SDL_Renderer* gRenderer, Position* scrollPos,Position* offset)
{
}
bool Object::hitCheck()
{
return false;
}
bool Object::hitCheckScroll(Position* scrollPos, Position* scrollOffSet)
{
return false;
}