-
Notifications
You must be signed in to change notification settings - Fork 0
/
Enemy.cpp
100 lines (81 loc) · 1.35 KB
/
Enemy.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
#include "Enemy.h"
Enemy::Enemy(sf::Texture pTexture, std::string pWord, sf::Vector2f pPosition, sf::Vector2f pVelocity):
mString(pWord),
mPosition(pPosition),
mVelocity(pVelocity)
{
mSprite.setTexture(pTexture);
}
Enemy::~Enemy(void)
{
}
void Enemy::update()
{
mPosition += mVelocity;
mAngle += mAngleVelocity;
mSprite.setRotation(mAngle);
mSprite.setPosition(mPosition);
}
bool Enemy::Hurt(char pChar)
{
if(pChar == mString[0])
{
mString.erase(mString.begin());
return true;
}
return false;
}
bool Enemy::isDead()
{
if( mString.empty()) return true;
return false;
}
//getters setters
std::string Enemy::getString()
{
return mString;
}
void Enemy::setString(std::string pString)
{
mString = pString;
}
sf::Vector2f Enemy::getPos()
{
return mPosition;
}
void Enemy::setPos(sf::Vector2f pPosition)
{
mPosition = pPosition;
}
sf::Vector2f Enemy::getVelocity()
{
return mVelocity;
}
void Enemy::setVelocity(sf::Vector2f pVelocity)
{
mVelocity = pVelocity;
}
sf::Sprite Enemy::getSprite()
{
return mSprite;
}
void Enemy::setTexture(sf::Texture pTexture)
{
mSprite.setTexture(pTexture);
}
void Enemy::setAngle(float pAngle)
{
mAngle = pAngle;
}
float Enemy::getAngle()
{
return mAngle;
}
void Enemy::setAngularVelocity(float pAngularVelocity)
{
mAngleVelocity = pAngularVelocity;
}
float Enemy::getAngularVelocity()
{
return mAngleVelocity;
}