| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- //
- // game_dispatch.hpp
- // gameutils
- //
- // Created by Sam Jaffe on 9/2/16.
- //
- #pragma once
- #include <chrono>
- #include <memory>
- #include <unordered_map>
- #include "game/math/math_fwd.hpp"
- #include "vector/vector.hpp"
- #include "engine_fwd.hpp"
- #include "events.hpp"
- #include "game/graphics/graphics_fwd.h"
- #include "game/util/time.hpp"
- namespace engine {
- class game_dispatch {
- public:
- game_dispatch(std::shared_ptr<graphics::renderer> renderer);
- ~game_dispatch();
- void process_key_event(raw_key_t key, bool press);
- void process_mouse_event(math::vec2 click, bool press);
- bool is_running() const { return running; }
- void quit() { running = false; }
- public:
- void update();
- void render();
- private:
- env::clock::tick next_frame();
- private:
- std::shared_ptr<graphics::renderer> renderer;
- math::vec2 screen_size;
- env::clock::duration minimum_frame_duration;
- std::unique_ptr<fps_counter> counter;
- using scene_t = std::shared_ptr<scene>;
- std::unordered_map<scene_id_t, scene_t> scenes;
- bool running = true;
- env::clock::timestamp current_timestamp;
- struct current_scene_info {
- current_scene_info();
- current_scene_info(scene *);
- scene_t ptr;
- std::string current_scene_id; // metadata
- math::vec2 local_size; // metadata
- bool is_mouse_event;
- bool is_keyboard_event;
- } curr_scene;
- };
- }
|