From 57fe8f3c4124819b95164547333a33f4c45eac8d Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 10 Mar 2019 12:07:40 -0400 Subject: Editor now allows tile placement You can scroll through the three layers (map, track, object) with Z/X. You can swap between focusing on the map and the tileset with TAB. You can place tiles with enter or space. Pretty rudimentary, but it's a start. --- src/input_lag.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/input_lag.h (limited to 'src/input_lag.h') diff --git a/src/input_lag.h b/src/input_lag.h new file mode 100644 index 0000000..40bc4a1 --- /dev/null +++ b/src/input_lag.h @@ -0,0 +1,66 @@ +#ifndef INPUT_LAG_H_DF16F381 +#define INPUT_LAG_H_DF16F381 + +/** + * Helper class that handles key repeat. + */ +class InputLag { +public: + + bool isActive() const + { + return active_; + } + + void reset() + { + accum_ = 0.0; + active_ = false; + repeat_ = false; + } + + void accumulate(double dt) + { + accum_ += dt; + } + + bool step() + { + if (!active_) + { + active_ = true; + + return true; + } else if (!repeat_) + { + if (accum_ > delay_) + { + accum_ -= delay_; + repeat_ = true; + + return true; + } + } else { + if (accum_ > tick_) + { + accum_ -= tick_; + + return true; + } + } + + return false; + } + +private: + + double tick_ = 1.0 / 15.0; + double delay_ = tick_ * 3.0; + + double accum_ = 0.0; + bool active_ = false; + bool repeat_ = false; + +}; + +#endif /* end of include guard: INPUT_LAG_H_DF16F381 */ -- cgit 1.4.1