-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathItem.cpp
More file actions
39 lines (37 loc) · 961 Bytes
/
Item.cpp
File metadata and controls
39 lines (37 loc) · 961 Bytes
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 "Item.h"
extern double speedAnimation;
extern float mainTime;
Item::Item(sf::String ImageFile, int maxFrameX, int maxFrameY, double speed) : Object(ImageFile, maxFrameX, maxFrameY, speed)
{
items.push_back(this);
}
Item::~Item()
{
for (int j = 0; j < Item::items.size(); ++j)
{
if (this == Item::items[j])
{
Item::items.erase(Item::items.begin() + j);
break;
}
}
}
int Item::actionCollisionObjects(Object* obj)
{
int temp = action(obj);
this->~Item();
return temp;
}
bool Item::animation(int direction)
{
currentFrameX += speedAnimation * mainTime;
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
return false;
}
int Item::update(sf::Event)
{
animation(0);
return 0;
}