diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-25 18:03:24 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-25 18:03:24 +0200 |
commit | b3a54e9b149ae2df289d6719b02972ff3694ee21 (patch) | |
tree | a18067d15523028d5a24f2dd809a028ef65cc1ee /Museum.cpp | |
parent | b31d7a677481b4a09168c43d203bfd6d7badf577 (diff) |
fix mementos implementation
Diffstat (limited to 'Museum.cpp')
-rw-r--r-- | Museum.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -16,22 +16,23 @@ Museum::~Museum() { } void Museum::update() { + unsigned long long next_snapshot = this->snapshot_ticks; + if (!this->history.empty()) next_snapshot += this->history.top().tick; + if (this->tick >= next_snapshot || this->history.empty()) { + this->history.push(this->save_snapshot()); + } + this->people.update(); this->canvas.update(); this->collision.update(); this->tick++; - - unsigned long long next_snapshot = this->snapshot_ticks; - if (!this->history.empty()) next_snapshot += this->history.top().tick; - if (next_snapshot > this->tick) return; - this->history.push(this->save_snapshot()); - printf("saved snapshot at tick %llu\n", this->tick); } void Museum::skip_forward() { this->jump++; } void Museum::skip_backward() { + this->paused = true; this->jump--; } @@ -41,7 +42,6 @@ void Museum::work() { if (this->jump > 0) { // forward jump for (; this->jump != 0; this->jump--) { - printf("jumping forward %u ticks\n", this->snapshot_ticks); for (size_t i = 0; i < this->snapshot_ticks; i++) this->update(); } @@ -49,9 +49,8 @@ void Museum::work() { // backward jump for (; this->jump != 0; this->jump++) { if (this->history.empty()) continue; - printf("restoring snapshot from tick %llu\n", this->history.top().tick); this->restore_snapshot(this->history.top()); - this->history.pop(); + if (this->tick > 0) this->history.pop(); } } |