-
Notifications
You must be signed in to change notification settings - Fork 7
/
Vehicle.cpp
58 lines (49 loc) · 2.04 KB
/
Vehicle.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
/******************************************************************************
* @file Vehicle.cpp
* @author Andrés Gavín Murillo, 716358
* @author Rubén Rodríguez Esteban, 737215
* @date Mayo 2020
* @coms Videojuegos - OutRun
******************************************************************************/
#include "Vehicle.hpp"
using namespace std;
using namespace sf;
Vehicle::Vehicle(const float maxSpeed, const float scale, const int maxCounterToChange, float speed, float posX,
float posY, float previousY, float minScreenX, float maxScreenX, const string &vehicle,
int numTextures,
int currentCodeImage, int counterCodeImage) : maxSpeed(maxSpeed), scale(scale),
maxCounterToChange(maxCounterToChange), speed(speed),
halfMaxSpeed(maxSpeed / 2.0f), posX(posX), posY(posY),
previousY(previousY), minScreenX(minScreenX),
maxScreenX(maxScreenX),
current_code_image(currentCodeImage),
counter_code_image(counterCodeImage) {
textures.reserve(static_cast<unsigned long>(numTextures));
for (int i = 1; i <= numTextures; i++) {
Texture t;
t.loadFromFile("resources/" + vehicle + "/c" + to_string(i) + ".png");
t.setSmooth(true);
t.setRepeated(false);
textures.push_back(t);
}
}
void Vehicle::setPosition(float pX, float pY) {
posX = pX;
posY = pY;
previousY = pY;
}
float Vehicle::getPosX() const {
return posX;
}
float Vehicle::getPosY() const {
return posY;
}
float Vehicle::getMinScreenX() const {
return minScreenX;
}
float Vehicle::getMaxScreenX() const {
return maxScreenX;
}
float Vehicle::getAcceleration() const {
return speed * speed;
}