R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
InputEvent.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** InputEvent.hpp
6*/
7
8#ifndef INPUTEVENT_HPP
9#define INPUTEVENT_HPP
10
11#include <cstdint>
12#include "Events/IEvent.hpp"
13
20enum class InputAction {
21 MOVE_UP,
22 MOVE_DOWN,
23 MOVE_LEFT,
25 SHOOT,
26 PAUSE,
27 QUIT
28};
29
36enum class InputState {
37 PRESSED,
38 RELEASED,
39 HELD
40};
41
58class InputEvent : public IEvent {
59 public:
67 InputEvent(InputAction action, InputState state, uint32_t frameNumber = 0)
68 : _action(action), _state(state), _frameNumber(frameNumber) {}
69
74 InputAction getAction() const { return _action; }
75
80 InputState getState() const { return _state; }
81
86 [[nodiscard]] uint32_t getFrameNumber() const { return _frameNumber; }
87
88 private:
91 uint32_t _frameNumber;
92};
93
94#endif
InputAction
Available player input actions.
@ SHOOT
Fire weapon.
@ PAUSE
Pause/unpause the game.
@ MOVE_RIGHT
Move player ship to the right.
@ QUIT
Request to quit the game.
@ MOVE_DOWN
Move player ship downward.
@ MOVE_LEFT
Move player ship to the left.
@ MOVE_UP
Move player ship upward.
InputState
State of an input action.
@ RELEASED
Input just released this frame.
@ PRESSED
Input just pressed this frame.
@ HELD
Input held down (continuous)
Base interface for all event types.
Definition IEvent.hpp:26
Event representing a player input action.
InputState getState() const
Get the input state.
uint32_t _frameNumber
Frame number for network synchronization.
InputAction _action
The action performed.
InputAction getAction() const
Get the input action.
uint32_t getFrameNumber() const
Get the frame number.
InputEvent(InputAction action, InputState state, uint32_t frameNumber=0)
Construct an input event.
InputState _state
The state of the input.