-
Notifications
You must be signed in to change notification settings - Fork 0
/
Proyectil.cpp
119 lines (88 loc) · 2.27 KB
/
Proyectil.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
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
/*
* File: Proyectil.cpp
* Author: Dani
*
* Created on 7 de abril de 2015, 16:46
*/
#include "Proyectil.h"
Proyectil::Proyectil(sf::Sprite* spriteProyectil, sf::Texture* t, sf::Vector2<float> s, sf::Vector2<float> m, int d, int v, int r) {
spriteProyectil->setPosition(s);
sprite= new sf::Sprite(*spriteProyectil);
tex=t;
sprite->setTexture(*t);
danyo=d;
velocidad=v;
setMov(m);
rango=r;
contador=0;
posActual = s;
posAnterior = s;
}
Proyectil::Proyectil(const Proyectil& orig) {
}
Proyectil::~Proyectil() {
}
/********************************METODOS GET Y SET*******************************************************/
sf::Sprite* Proyectil::getSprite(){
return sprite;
}
void Proyectil::setSprite(sf::Sprite s){
sprite= new sf::Sprite(s);
}
int Proyectil::getContador(){
return contador;
}
void Proyectil::setContador(int i){
contador=i;
}
int Proyectil::getRango(){
return rango;
}
void Proyectil::setRango(int r){
rango=r;
}
sf::Vector2<float> Proyectil::getMov(){
return mov;
}
void Proyectil::setMov(sf::Vector2<float> v){
mov=sf::Vector2<float>(v);
}
int Proyectil::getVelocidad(){
return velocidad;
}
void Proyectil::setVelocidad(int i){
velocidad=i;
}
int Proyectil::getDanyo(){
return danyo;
}
void Proyectil::setDanyo(int i){
danyo=i;
}
sf::Vector2<float> Proyectil::getPosAnterior(){
return posAnterior;
}
void Proyectil::setPosAnterior(sf::Vector2<float> v){
posAnterior= v;
}
sf::Vector2<float> Proyectil::getPosActual(){
return posActual;
}
void Proyectil::setPosActual(sf::Vector2<float> v){
posActual = v;
}
/********************************METODOS CUSTOM*******************************************************/
//Actualiza la posicion de la Proyectil en funcion del vector mov de la propia Proyectil, que almacena el incremento en x e y que debe realizar la Proyectil en cada iteracion
bool Proyectil::updatePosition(){
bool devuelve = false;
if(contador<rango){
sprite->move(2*velocidad*mov.x, 2*velocidad*mov.y);
contador++;
}else{
devuelve=true;
}
return devuelve;
}
void Proyectil::setPositionSprite(sf::Vector2<float> v){
sprite->setPosition(v.x, v.y);
}