-
Notifications
You must be signed in to change notification settings - Fork 1
/
Coin.cpp
51 lines (45 loc) · 1.15 KB
/
Coin.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
#include"Coin.h"
Flower::Flower(GameDataRef data) : _data(data)
{
_borderHeight = _data->pictures.GetTexture("Border").getSize().y;
_flowerHeight = _data->pictures.GetTexture("Flower").getSize().y;
_flowerYCoordinate = 0;
}
void Flower::CreateFlower()
{
sf::Sprite sprite(_data->pictures.GetTexture("Flower"));
sprite.setPosition(_data->window.getSize().x, _flowerYCoordinate);
flowerSprites.push_back(sprite);
}
void Flower::MoveFlower(float dt)
{
for (int i = 0; i < flowerSprites.size(); i++)
{
sf::Vector2f position = flowerSprites.at(i).getPosition();
float motion = BRICK_MOVEMENT_SPEED * dt;
flowerSprites.at(i).move(-motion, 0);
}
}
void Flower::DrawFlower()
{
for (int i = 0; i < flowerSprites.size(); i++)
{
_data->window.draw(flowerSprites.at(i));
}
}
int Flower::RandomiseYFlowerCoordinate()
{
_flowerYCoordinate = (rand() % (_data->window.getSize().y - _borderHeight - _flowerHeight) + _borderHeight-10);
return _flowerYCoordinate;
}
bool Flower::DoIntersect(int y1, int y2)
{
if ((y1 + 47 < y2) || (y1 - 47 > y2))
return true;
else
return false;
}
std::vector<sf::Sprite>& Flower::getSprites()
{
return flowerSprites;
}