-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grave.cpp
49 lines (44 loc) · 1.18 KB
/
Grave.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
#include "Grave.h"
Grave::Grave(sf::Vector2f pPosition,
sf::Vector2f pVelocity,
sf::Vector2i pSize,
sf::Texture *pTexture,
float pReleaseTimeMin,
float pReleaseTimeMax,
float pAngle,
float pAngularVelocity) :
//call superclass constructor
Enemy(pPosition, pVelocity, pSize, pTexture, pAngle, pAngularVelocity),
mClock(),
mReleaseTimeMin(pReleaseTimeMin),
mReleaseTimeMax(pReleaseTimeMax)
{
std::random_device rd;
std::mt19937 eng(rd());
std::uniform_real_distribution<> dis(mReleaseTimeMin, mReleaseTimeMax);
mReleaseTime = floor(dis(eng));
//this is how u random
std::uniform_real_distribution<> dis2(0.12, 0.17);
//-----------------------------------------------
mAnimations.insert(mAnimations.begin(), Animation(8,dis2(eng), true));
AnimatedSprite::startAnimation();
mSprite.scale(0.7,0.7);
mSize.x *= 0.7;
mSize.y *= 0.7;
}
Grave::~Grave(void)
{
}
bool Grave::checkIfTime()
{
if(mClock.getElapsedTime().asSeconds() > mReleaseTime)
{
std::random_device rd;
std::mt19937 eng(rd());
std::uniform_real_distribution<> dis(mReleaseTimeMin, mReleaseTimeMax);
mReleaseTime = floor(dis(eng));
mClock.restart();
return true;
}
return false;
}