-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectiles.cpp
More file actions
56 lines (44 loc) · 1.33 KB
/
Copy pathProjectiles.cpp
File metadata and controls
56 lines (44 loc) · 1.33 KB
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
#include "Projectiles.hpp"
Projectile::Projectile(const std::string& texturePath, float _movementSpeed, float scale , int _damage ,int _snowTime){
initTexture(texturePath);
initSprite(scale);
movementSpeed = _movementSpeed;
hit = false;
damage = _damage;
snowTime = _snowTime;
}
void Projectile::initTexture(const std::string& texturePath){
this->texture.loadFromFile(texturePath);
}
void Projectile::initSprite(float scale){
this->sprite.setTexture(this->texture);
this->sprite.scale(scale, scale);
this->sprite.setOrigin(sprite.getLocalBounds().width / 2, sprite.getLocalBounds().height / 2);
}
void Projectile::move(const float dirX , const float dirY){
this->sprite.move(this->movementSpeed * dirX ,this->movementSpeed * dirY);
}
void Projectile::render(sf::RenderTarget& target){
target.draw(this->sprite);
}
void Projectile::setPosition(float x, float y){
this->sprite.setPosition(x, y);
}
bool Projectile::isOffScreen(int screenWidth){
return sprite.getPosition().x > screenWidth || sprite.getPosition().x < 0;
}
sf::Sprite Projectile::getSprite(){
return this->sprite;
}
bool Projectile::isHit(){
return hit;
}
void Projectile::getHit(){
this->hit = true;
}
int Projectile::getDamage(){
return this->damage;
}
int Projectile::getSnowTime(){
return this->snowTime;
}