summaryrefslogtreecommitdiff
path: root/timedLatch.cpp
blob: 0629ac8d9b6f27e102cc2f96febb0c1df508827a (plain)
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
#include "timedLatch.hpp"

namespace ur {

TimedLatch::TimedLatch(sf::Time duration)
{
  this->duration = duration;
  this->clock = sf::Clock();
};

void
TimedLatch::start()
{
  this->clock.restart();
  this->isStarted = true;
};

bool
TimedLatch::is_running()
{
  return this->isStarted && this->clock.getElapsedTime() < duration;
};

bool
TimedLatch::is_completed()
{

  return this->isStarted && this->clock.getElapsedTime() >= duration;
};

void
TimedLatch::reset()
{
  this->isStarted = false;
};

}