ST_engine  0.3-ALPHA
level.hpp
1 /* This file is part of the "ST" project.
2  * You may use, distribute or modify this code under the terms
3  * of the GNU General Public License version 2.
4  * See LICENCE.txt in the root directory of the project.
5  *
6  * Author: Maxim Atanasov
7  * E-mail: maxim.atanasov@protonmail.com
8  */
9 
10 #ifndef LVL_DEF
11 #define LVL_DEF
12 
13 #include <key_definitions.hpp>
14 #include <game_manager/level/entity.hpp>
15 #include <game_manager/level/text.hpp>
16 #include <game_manager/level/light.hpp>
17 #include <message_bus.hpp>
18 #include <game_manager/level/camera.hpp>
19 
20 class level_tests;
21 
22 #define PARALLAX_BG_LAYERS 4
23 
24 namespace ST {
26 
29  class level {
30  friend class ::level_tests;
31 
32  private:
33 
34  std::string name;
35  message_bus *gMessage_bus;
36 
37  static key key_index(const std::string &arg);
38 
39  public:
40 
41  //public data
42  /*
43  * Contains the mappings from keys to actions.
44  * Contains all entities, lights and text objects.
45  * Contains the background overlay and the camera.
46  */
47  ska::bytell_hash_map<uint16_t, std::vector<ST::key>> actions_buttons{};
48  std::vector<ST::entity> entities{};
49  std::vector<ST::light> lights{};
50  std::vector<ST::text> text_objects{};
51  uint16_t background[PARALLAX_BG_LAYERS] = {65535, 65535, 65535, 65535};
52  uint8_t parallax_speed[PARALLAX_BG_LAYERS] = {0, 0, 0, 0};
53  SDL_Color background_color{0, 0, 0, 0};
54  uint16_t overlay = 65535;
55  uint8_t overlay_sprite_num = 1;
56  uint32_t physics_objects_count = 0;
57 
58  // ST::camera camera = {0, 0, -1, 1920, 0, 1080};
59  ST::camera camera = {0, 0, -1, 1920, 0, 1080};
60 
61  level(const std::string &, message_bus *);
62 
63  int8_t load();
64 
65  void reload();
66 
67  void unload();
68 
69  [[nodiscard]] std::string get_name() const;
70 
71  ~level();
72 
73  int8_t load_input_conf();
74  };
75 }
76 
77 #endif
This object contains all the data for a level and provides functions for loading and unloading a leve...
Definition: level.hpp:29
std::string get_name() const
Definition: level.cpp:76
int8_t load_input_conf()
Definition: level.cpp:132
void unload()
Definition: level.cpp:102
level(const std::string &, message_bus *)
Definition: level.cpp:20
int8_t load()
Definition: level.cpp:30
~level()
Definition: level.cpp:84
void reload()
Definition: level.cpp:50
Tests fixture for the level object.
Definition: level_tests.cpp:16
The central messaging system of the engine. All subsystem make extensive use of it.
Definition: message_bus.hpp:29
The camera object - represents the viewport for the game.
Definition: camera.hpp:16