-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.cpp
More file actions
108 lines (87 loc) · 1.22 KB
/
player.cpp
File metadata and controls
108 lines (87 loc) · 1.22 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
Player::Player(std::string filename)
{
SDL_Surface *oldface;
oldface = IMG_Load(filename.c_str());
sprite = SDL_DisplayFormatAlpha(oldface);
SDL_FreeSurface(oldface);
coords.x=500;
coords.y=200;
coords.w=100;
coords.h=100;
frames.x=0;
frames.y=0;
frames.w=100;
frames.h=100;
velx = 0;
vely = 0;
SDL_Rect speech_loc;
}
Player::~Player()
{
SDL_FreeSurface(sprite);
}
int Player::coordX()
{
return coords.x;
}
int Player::coordY()
{
return coords.y;
}
void Player::coordX(int X)
{
coords.x += X;
}
void Player::coordY(int Y)
{
coords.y += Y;
}
void Player::box_size(int boxSize)
{
coords.w = boxSize;
coords.h = boxSize;
frames.w = boxSize;
frames.h = boxSize;
}
void Player::frameX(int frameX)
{
frames.x = frameX;
}
void Player::frameY(int frameY)
{
frames.y = frameY;
}
int Player::xvel(int newxvel)
{
velx = newxvel;
}
int Player::yvel(int newyvel)
{
vely = newyvel;
}
int Player::xvel()
{
return velx;
}
int Player::yvel()
{
return vely;
}
SDL_Rect Player::location()
{
return coords;
}
SDL_Rect Player::speech_bubble()
{
speech_loc.x = coords.x + 65;
speech_loc.y = coords.y - 25;
return speech_loc;
}
SDL_Rect Player::frame()
{
return frames;
}
SDL_Surface Player::image()
{
return *sprite;
}