-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.cpp
More file actions
98 lines (61 loc) · 940 Bytes
/
player.cpp
File metadata and controls
98 lines (61 loc) · 940 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
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 "player.h"
#include <sstream>
#include <string>
#include <cstdlib>
using namespace std;
Player::Player(){
length = 150;
position = 0;
score = 0;
}
int Player::getRed(){
return red;
}
int Player::getGreen(){
return green;
}
int Player::getBlue(){
return blue;
}
void Player::setColor(int r, int g, int b){
red = r;
green = g;
blue = b;
}
int Player::getLives(){
return lives;
}
double Player::getPosition(){
return position;
}
void Player::setLives(int l){
lives = l;
}
void Player::die(){
if (lives > 0){
lives --;
}
else{
setPos(0);
setLength(600);
}
}
void Player::move(int a,double s){
position = position + a * s;
}
void Player::setLength(int l){
length = l;
}
void Player::setPos(int p){
position = p;
}
int Player::getLength(){
return length;
}
string Player::getLivesAsString(){
std::string s;
stringstream out;
out << lives;
s = out.str();
return s;
}