summary refs log tree commit diff stats
path: root/src/schedule.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2019-02-20 16:44:09 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2019-02-20 16:44:09 -0500
commitd9c201cbf2fbfe315137e141d886a9bbfa6794ba (patch)
tree2dfaf8db9e43e456386796d797884ea18d63befe /src/schedule.h
parent8996810b1356c2224d4f34423fd4211de20da238 (diff)
downloaddispatcher-d9c201cbf2fbfe315137e141d886a9bbfa6794ba.tar.gz
dispatcher-d9c201cbf2fbfe315137e141d886a9bbfa6794ba.tar.bz2
dispatcher-d9c201cbf2fbfe315137e141d886a9bbfa6794ba.zip
Started implementing schedule
Scheduled entities move downward every beat, although they have a speed that is twice the bpm, so essentially they move every other beat?

Broke the simulation loop such that different parts run independently -- made it horizontal rather than vertical.

Encapsulated the grid cache so that more than one position field could be cached. This is used to make sure that an entity can't move into a space that something else is already moving into.

Fixed issue where an entity could move perpendicularly into the space an entity was moving out of.
Diffstat (limited to 'src/schedule.h')
-rw-r--r--src/schedule.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/schedule.h b/src/schedule.h new file mode 100644 index 0000000..5d77761 --- /dev/null +++ b/src/schedule.h
@@ -0,0 +1,44 @@
1#ifndef SCHEDULE_H_EF7B9D12
2#define SCHEDULE_H_EF7B9D12
3
4class Schedule {
5public:
6
7 explicit Schedule(
8 size_t bpm) :
9 bpm_(bpm),
10 tick_(60.0 / static_cast<double>(bpm_))
11 {
12 }
13
14 size_t getBPM() const
15 {
16 return bpm_;
17 }
18
19 void accumulate(double dt)
20 {
21 accum_ += dt;
22 }
23
24 bool step()
25 {
26 if (accum_ > tick_)
27 {
28 accum_ -= tick_;
29
30 return true;
31 } else {
32 return false;
33 }
34 }
35
36private:
37
38 size_t bpm_;
39 double tick_;
40 double accum_ = 0.0;
41
42};
43
44#endif /* end of include guard: SCHEDULE_H_EF7B9D12 */