-
Notifications
You must be signed in to change notification settings - Fork 0
/
Organism.cpp
executable file
·58 lines (47 loc) · 1.08 KB
/
Organism.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
//
// Created by vtimofeev on 28/06/16.
//
#include "Organism.h"
textDisplay Organism::takeDamage(textDisplay &msg, int damage, sf::Vector2f rectPosition){
hp -= damage;
// Text display
msg.text.setString(std::to_string(-damage));
msg.text.setPosition(rectPosition);
msg.text.setColor(sf::Color::White);
if (hp <= 0) {
destroy = true;
}
return msg;
}
int Organism::getHp() const
{
return hp;
}
void Organism::setMovementSpeed(float speed)
{
movementSpeed = speed;
}
void Organism::setHp(int value)
{
hp = value;
}
int Organism::getAttackDamage() const {
return attackDamage;
}
void Organism::setAttackDamage(int value) {
attackDamage = value;
}
float Organism::getMovementSpeed() const
{
return movementSpeed;
}
void Organism::changeWalkingSprite() {
if (changeSpriteCounter++ == 0) {
walkingCounter++;
}
if (changeSpriteCounter == changeSpritePerFrames) {
changeSpriteCounter = 0;
}
if (walkingCounter == 2)
walkingCounter = 0;
}