-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPistola.h
35 lines (32 loc) · 1.26 KB
/
Pistola.h
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
#ifndef PISTOLA_H
#define PISTOLA_H
#include"Intf_Arma.h"
class Pistola : public Intf_Arma{
public:
Pistola(){
textura.loadFromFile("Assets/pistola.png");
spriteArma.setTexture(textura);
spriteArma.setScale(0.6f,0.6f);
intervalo=300;
}
void setPosicion(Vector2f pos)override{
spriteArma.setPosition(pos.x,pos.y-10);
}
void atacar(RenderWindow & w,vector<unique_ptr<Proyectil>> & disparos, FlyFactory * _fabrica,Vector2f jugador)override{
if(Mouse::isButtonPressed(Mouse::Left)){
setTiempoActual();
if(disponible()){
Vector2f mousePos = w.mapPixelToCoords(Mouse::getPosition(w));
Vector2f direction = mousePos - jugador;
float length = std::sqrt(direction.x * direction.x + direction.y * direction.y);
if (length > 0)
{
direction /= length;
disparos.push_back(make_unique<Proyectil>(_fabrica->getInstancia("bala"),100,jugador,direction,"aliadas_distancia"));
tiempoAnterior=tiempoActual;
}
}
}
}
};
#endif // PISTOLA_H