-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAnimatedTield.cpp
More file actions
39 lines (32 loc) · 1.41 KB
/
AnimatedTield.cpp
File metadata and controls
39 lines (32 loc) · 1.41 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
#include "AnimatedTield.h"
extern float mainTime;
void AnimatedTield::animation()
{
currentFrameX += speedAnimation * mainTime + rand() / 3'000'000.0;
if (currentFrameX > movementTexture.maxFrameX)
currentFrameX -= movementTexture.maxFrameX;
movementTexture.sprite->setTextureRect(sf::IntRect((valueSizeXY.sizeX) * int(currentFrameX), valueSizeXY.sizeY * int(currentFrameY), valueSizeXY.sizeX, valueSizeXY.sizeY));//(sizeX) * int(currentFrameY) + sizeX
}
AnimatedTield::AnimatedTield(const UtilitiesGame::TextureData movementTexture, const UtilitiesGame::SizeXY& valueSizeXY, int currentFrameY/*Íå õî÷ó ïðîñèòü Ïàøêà ïåðåäåëûâàòü, òê îí íåïðàâèëüíî ñòðóêòóðèçèðîâàë ñòåíêè*/, double speedAnimation)
{
this->valueSizeXY.sizeX = valueSizeXY.sizeX;
this->valueSizeXY.sizeY = valueSizeXY.sizeY;
this->movementTexture.image = new sf::Image;
this->movementTexture.texture = new sf::Texture;
this->movementTexture.sprite = new sf::Sprite;
*this->movementTexture.image = *movementTexture.image;
this->movementTexture.maxFrameX = movementTexture.maxFrameX;
this->movementTexture.maxFrameY = movementTexture.maxFrameY;// íå èìååò ñìûñëà
*this->movementTexture.sprite = *movementTexture.sprite;
*this->movementTexture.texture = *movementTexture.texture;
this->currentFrameY = currentFrameY;// ýõ
this->speedAnimation = speedAnimation;
}
AnimatedTield::~AnimatedTield()
{
}
int AnimatedTield::update()
{
animation();
return 0;
}