-
Notifications
You must be signed in to change notification settings - Fork 0
/
Weapon.h
71 lines (58 loc) · 1.83 KB
/
Weapon.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
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
//#pragma once
#ifndef WEAPON_H
#define WEAPON_H
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
class Weapon{
public:
struct Bullet {
//default bullet constructor
Bullet();
//constructor
Bullet(sf::Sprite weaponSprite, sf::RenderWindow * window, sf::Texture & bulletTextureB);
//mouse position when bullet is created
sf::Vector2i mousePos;
//start position based on weapon position
sf::Vector2f startPos;
sf::Sprite bulletSprite;
};
//default constructor
Weapon();
//constructor
Weapon(sf::Texture bulletTexture, sf::Texture & weaponTextureR, sf::Texture & weaponTextureL, sf::SoundBuffer harpoonBuffer, sf::RenderWindow * theWindow);
//copy constructor
Weapon(Weapon const & myWeapon);
//destructor
~Weapon();
//operator=
Weapon const & operator=(Weapon const & other);
//set position of weapon (including rotation towards mouse)
void setPos(sf::Sprite charSprite);
//get weapon side based on rotation (false is right and true is left)
bool getSide(); //used for animation in Character.h
//set weapon sprite based on rotation
void setSide();
//draw weapon
void draw();
//draw and move bullets
void drawB();
std::vector<Bullet*> getBullets(); //used for collision detection in Map.h
private:
void copy(Weapon const & myWeapon); //helper for copy constructor and operator=
void clear(); //helper for destructor and operator=
sf::Sprite wepSprite;
sf::Sprite wepSpriteR;
sf::Sprite wepSpriteL;
sf::Sound sound;
sf::SoundBuffer hBuffer;
sf::RenderWindow * window;
//--BULLET--
//creates bullet using bulletTextureW
void createBullet(sf::RenderWindow * window);
//moves bullet towards mouse
void moveBullet(Bullet * & theBullet);
std::vector<Bullet*> bullets; //holds all existing bullets
sf::Texture bulletTextureW; //used for creating bullet
sf::Clock clock; //used for bullet shooting
};
#endif