| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- //
- // game_dispatch.hpp
- // gameutils
- //
- // Created by Sam Jaffe on 9/2/16.
- //
- #pragma once
- #include <chrono>
- #include <memory>
- #include <unordered_map>
- #include "time.hpp"
- #include "engine_fwd.hpp"
- #include "events.hpp"
- #include "math/math_fwd.hpp"
- #include "math/vector.hpp"
- namespace engine {
- class game_dispatch {
- public:
- game_dispatch( );
-
- void process_key_event( raw_key_t key, bool press );
- void process_mouse_event( math::vec2 click, bool press );
-
- [[noreturn]] void gameloop( );
- void quit( );
- private:
- void single_frame( tick t ) { }
- tick get_tick( );
- tick next_frame( );
- void cleanup_resources( ) { } // TODO ???
- private:
- math::vec2 screen_size;
- duration minimum_frame_duration;
- using scene_t = std::unique_ptr<scene>;
- std::unordered_map<scene_id_t, scene_t> scenes;
-
- bool running = true;
- timestamp current_timestamp;
- struct current_scene_info {
- current_scene_info( );
- current_scene_info( scene * );
-
- scene * ptr; // weak
-
- std::string current_scene_id; // metadata
- math::vec2 local_size; // metadata
- bool is_mouse_event;
- bool is_keyboard_event;
- } curr_scene;
- };
- }
|