-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDragon.cpp
More file actions
56 lines (53 loc) · 1.56 KB
/
Copy pathDragon.cpp
File metadata and controls
56 lines (53 loc) · 1.56 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
//
// Created by lapo on 09/06/22.
//
#include "Dragon.h"
Dragon::~Dragon() {
delete this->fireptr;
}
Dragon::Dragon(int N) {
Level=N*2;
Hp=8*Level*3/2;
Strenght=6*Level;
StaminaBar=6*Level;
Stamina=6*Level;
StaminaLeft=StaminaBar;
auto texture=new sf::Texture;
texture->loadFromFile("./sprite/character/drago.png");
this->setTexture(*texture);
this->setTextureRect(sf::IntRect(0, 0, 64, 64));
this->setPosition(Posx,Posy);
this->setScale(3.125,3.125);
auto fireptr1=new Fireball(1400,400);
this->fireptr=fireptr1;
fireptr->setPosx(1400);
fireptr->setPosy(400);
}
void Dragon::AttackAnimation() {
if(this->isAttackEnded()==false) {
this->InAttack=true;
auto time1 = new sf::Time;
*time1 = sf::seconds(0.10);
auto clock1 = new sf::Clock;
if (this->getFaseAttack() == 0)
fireptr->move(-50,5.55);
clock1->restart();
while (clock1->getElapsedTime() < *time1) {
}
this->setCountAttack(this->getCountAttack() + 1);
fireptr->setTextureRect(sf::IntRect((this->getCountAttack()%8) * 32, 0, 32, 32));
if (this->getCountAttack() == 20) {
this->setAttackEnded(true);
fireptr->setPosition(fireptr->getPosx(),fireptr->getPosy());
this->setCountAttack(0);
this->InAttack=false;
}
delete time1;
delete clock1;
}
}
void Dragon::Draw(sf::RenderWindow &finestra)const {
finestra.draw(*this);
if(this->InAttack)
finestra.draw(*(this->fireptr));
}