ST_engine  0.3-ALPHA
physics_manager.hpp
1 #include <utility>
2 
3 /* This file is part of the "ST" project.
4  * You may use, distribute or modify this code under the terms
5  * of the GNU General Public License version 2.
6  * See LICENCE.txt in the root directory of the project.
7  *
8  * Author: Maxim Atanasov
9  * E-mail: maxim.atanasov@protonmail.com
10  */
11 
12 #ifndef PHYSICS_DEF
13 #define PHYSICS_DEF
14 
15 #include <game_manager/level/entity.hpp>
16 #include <message_bus.hpp>
17 #include <task_manager.hpp>
18 #include "game_manager/level/level.hpp"
19 
22 private:
23  message_bus &gMessage_bus;
24  subscriber msg_sub{};
25  int32_t level_floor = 0;
26  bool physics_paused = false;
27  std::vector<ST::entity *> entities_ref{};
28  int8_t gravity = 0;
29  int8_t friction = 0;
30 
31  static int check_collision(uint64_t, std::vector<ST::entity *> *entities);
32 
33  static uint8_t entity_set_x(int32_t x, uint64_t, std::vector<ST::entity *> *entities);
34 
35  static uint8_t entity_set_y(int32_t y, uint64_t, std::vector<ST::entity *> *entities);
36 
37  static void process_horizontal(std::vector<ST::entity *> *entities, int8_t friction);
38 
39  static void process_vertical(std::vector<ST::entity *> *entities, int8_t gravity, int32_t level_floor);
40 
41  void handle_messages();
42 
43 public:
44  explicit physics_manager(message_bus &gMessageBus);
45 
46  void update(ST::level &level);
47 
48  ~physics_manager();
49 
50 };
51 
52 #endif //PHYSICS_DEF
This object contains all the data for a level and provides functions for loading and unloading a leve...
Definition: level.hpp:29
The central messaging system of the engine. All subsystem make extensive use of it.
Definition: message_bus.hpp:29
This class handles all physics related actions in the engine.
void update(ST::level &level)
physics_manager(message_bus &gMessageBus)
This class handles a small queue for messages.
Definition: subscriber.hpp:20