chore: add comments to swarm.hpp
This commit is contained in:
10
src/main.cpp
10
src/main.cpp
@@ -65,12 +65,21 @@ main(int argc, char **argv) {
|
||||
scr.draw();
|
||||
};
|
||||
|
||||
// We draw to the screen at a rate of `kFPS', but step()ing the swarm at
|
||||
// this rate would be far too fast to be interesting to look at. On the
|
||||
// other hand, step()ing once a second is too slow.
|
||||
//
|
||||
// So, we step() every quarter second. To line up the move() so that a unit
|
||||
// move() happens preceding each step(), we also need to move as fast as
|
||||
// we've shortened our step() interval.
|
||||
for(int i = 0; i < iter_count * kFPS/4;) {
|
||||
if(!pause) {
|
||||
scr.clear();
|
||||
|
||||
update_and_draw();
|
||||
|
||||
// Since we step() 4x a second, we need to move() 4x as fast as moving by dt
|
||||
// each frame.
|
||||
swarm.move(kDT * 4);
|
||||
if(i % (kFPS/4) == (kFPS/4)-1)
|
||||
swarm.step();
|
||||
@@ -152,6 +161,7 @@ main(int argc, char **argv) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Wait for kDT (time between two frames)
|
||||
usleep(1000 * 1000 / kFPS);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user