R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
InputBuffer.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** Created by samuelBleau on 26/11/2025.
4** File description:
5** InputBuffer.hpp
6*/
7
8#ifndef INPUTBUFFER_HPP
9#define INPUTBUFFER_HPP
10
11#include <cstdint>
12#include <deque>
13#include <optional>
14#include <vector>
16
37 public:
47
51 InputBuffer() = default;
52
56 ~InputBuffer() = default;
57
70 void addInput(uint32_t frameNumber, InputAction action, InputState state);
71
84 std::vector<StoredInput> getInputsSince(uint32_t startFrame) const;
85
97 void clearUntil(uint32_t frameNumber);
98
106 std::optional<StoredInput> getLastInput() const;
107
114 void clear();
115
123 size_t size() const;
124
125 private:
126 std::deque<StoredInput> _inputs;
127 uint32_t _oldestFrame = 0;
128};
129
130#endif
InputAction
Available player input actions.
InputState
State of an input action.
Buffer for storing player input history.
void clear()
Clear the buffer completely.
uint32_t _oldestFrame
std::deque< StoredInput > _inputs
~InputBuffer()=default
Default destructor.
void addInput(uint32_t frameNumber, InputAction action, InputState state)
Add an input to the buffer.
void clearUntil(uint32_t frameNumber)
Clear inputs up to a given frame.
std::optional< StoredInput > getLastInput() const
Get the last stored input.
std::vector< StoredInput > getInputsSince(uint32_t startFrame) const
Get all inputs since a given frame.
InputBuffer()=default
Default constructor.
size_t size() const
Get the number of stored inputs.
Structure representing a stored input with metadata.
uint32_t frameNumber
Frame number where input was captured.
InputAction action
Action performed (MOVE, SHOOT, etc.)
InputState state
Action state (PRESSED, RELEASED, HELD)