-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.cpp
More file actions
40 lines (36 loc) · 892 Bytes
/
Player.cpp
File metadata and controls
40 lines (36 loc) · 892 Bytes
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
#include "Player.h"
void Player::SetPosition(float x, float y)
{
if ((x == current_x) && (y == current_y))
{
return;
}
if (previous_x.size() > 22)
{
previous_x.pop_back();
previous_y.pop_back();
}
previous_x.push_front(current_x);
previous_y.push_front(current_y);
current_x = x;
current_y = y;
}
/// <summary>
/// Draw the player object at its current location.
/// </summary>
void Player::Draw() const
{
CP_Settings_NoStroke();
auto alpha = 255;
auto draw_color = CP_Color_Create(color.r, color.g, color.b, alpha);
auto draw_size = size;
CP_Settings_Fill(draw_color);
CP_Graphics_DrawCircle(current_x, current_y, draw_size);
for (size_t i = 0; i < previous_x.size(); ++i)
{
alpha -= 10;
draw_color = CP_Color_Create(color.r, color.g, color.b, alpha);
CP_Settings_Fill(draw_color);
CP_Graphics_DrawCircle(previous_x[i], previous_y[i], draw_size - i);
}
}