소스 검색

Fix naming conventions.

Sam Jaffe 6 년 전
부모
커밋
034e5a3f6b
2개의 변경된 파일32개의 추가작업 그리고 32개의 파일을 삭제
  1. 6 6
      engine/include/game/engine/game_dispatch.hpp
  2. 26 26
      engine/src/game_dispatch.cpp

+ 6 - 6
engine/include/game/engine/game_dispatch.hpp

@@ -48,13 +48,13 @@ namespace engine {
     env::clock::tick next_frame();
 
   private:
-    math::vec2 screen_size;
-    std::shared_ptr<graphics::renderer> renderer, batch_renderer;
-    env::clock::duration minimum_frame_duration;
+    math::vec2 screen_size_;
+    std::shared_ptr<graphics::renderer> renderer_, batch_renderer_;
+    env::clock::duration minimum_frame_duration_;
     std::shared_ptr<text_engine> text_engine_;
-    std::unique_ptr<fps_counter> counter;
+    std::unique_ptr<fps_counter> counter_;
 
-    std::unordered_map<scene_id_t, scene_t> scenes;
+    std::unordered_map<scene_id_t, scene_t> scenes_;
 
     bool running = true;
     env::clock::timestamp current_timestamp;
@@ -68,6 +68,6 @@ namespace engine {
       math::vec2 local_size;        // metadata
       bool is_mouse_event;
       bool is_keyboard_event;
-    } curr_scene;
+    } current_scene_;
   };
 }

+ 26 - 26
engine/src/game_dispatch.cpp

@@ -27,22 +27,22 @@ namespace engine {
   }
 
   game_dispatch::game_dispatch(std::shared_ptr<graphics::renderer> renderer)
-      : screen_size(env::screen_size()), renderer(renderer),
-        batch_renderer(make_renderer(screen_size)),
-        minimum_frame_duration(env::fps::v60),
+      : screen_size_(env::screen_size()), renderer_(renderer),
+        batch_renderer_(make_renderer(screen_size_)),
+        minimum_frame_duration_(env::fps::v60),
         text_engine_(new text_engine("font", renderer->manager())),
-        counter(new fps_counter(text_engine_)), scenes(),
-        current_timestamp(env::clock::now()), curr_scene() {}
+        counter_(new fps_counter(text_engine_)), scenes_(),
+        current_timestamp(env::clock::now()), current_scene_() {}
 
   game_dispatch::~game_dispatch() {}
 
   void game_dispatch::register_scene(scene_t scn) {
-    scenes.emplace(scn->id, scn);
+    scenes_.emplace(scn->id, scn);
   }
 
   void game_dispatch::activate_scene(scene_id_t const & id) {
     // TODO: Cleanup
-    curr_scene = current_scene_info(scenes[id].get());
+    current_scene_ = current_scene_info(scenes_[id].get());
   }
 
   void game_dispatch::set_current_timestamp() {
@@ -55,33 +55,33 @@ namespace engine {
       : ptr(curr), current_scene_id(ptr->id), local_size(ptr->size()) {}
 
   graphics::manager const & game_dispatch::graphics_manager() const {
-    return *renderer->manager();
+    return *renderer_->manager();
   }
 
   void game_dispatch::process_key_event(raw_key_t key, bool press) {
-    if (!curr_scene.is_keyboard_event) return;
-    auto const & binding = curr_scene.ptr->keys();
+    if (!current_scene_.is_keyboard_event) return;
+    auto const & binding = current_scene_.ptr->keys();
     auto it = binding.find(key);
     if (it == binding.end()) return;
 
-    curr_scene.ptr->handle_key_event(
+    current_scene_.ptr->handle_key_event(
         {it->second, mask(event::KEY_MASK, press)});
   }
 
   void game_dispatch::process_mouse_event(math::vec2 mouse_pos, bool press) {
-    if (!curr_scene.is_mouse_event) return;
+    if (!current_scene_.is_mouse_event) return;
     math::vec2 local_scene_position =
-        mouse_pos * curr_scene.local_size / screen_size;
+        mouse_pos * current_scene_.local_size / screen_size_;
 
-    curr_scene.ptr->handle_mouse_event(
+    current_scene_.ptr->handle_mouse_event(
         {local_scene_position, mask(event::MOUSE_MASK, press)});
   }
 
   env::clock::tick game_dispatch::next_frame() {
     env::clock::tick t(current_timestamp);
 
-    while (t.since < minimum_frame_duration) {
-      std::this_thread::sleep_for(minimum_frame_duration - t.since);
+    while (t.since < minimum_frame_duration_) {
+      std::this_thread::sleep_for(minimum_frame_duration_ - t.since);
       t = env::clock::tick(current_timestamp);
     }
 
@@ -91,25 +91,25 @@ namespace engine {
 
   void game_dispatch::update() {
     env::clock::tick t = next_frame();
-    counter->set_frame_step(t.since);
-    curr_scene.ptr->update(std::chrono::duration<float>(t.since).count());
+    counter_->set_frame_step(t.since);
+    current_scene_.ptr->update(std::chrono::duration<float>(t.since).count());
   }
 
   void game_dispatch::render() {
-    batch_renderer->clear();
-    for (auto & obj : counter->glyphs()) {
-      batch_renderer->draw(obj);
+    batch_renderer_->clear();
+    for (auto & obj : counter_->glyphs()) {
+      batch_renderer_->draw(obj);
     }
-    batch_renderer->flush();
-    curr_scene.ptr->render();
-    renderer->flush();
+    batch_renderer_->flush();
+    current_scene_.ptr->render();
+    renderer_->flush();
   }
 
   std::shared_ptr<graphics::renderer>
   game_dispatch::make_renderer(math::vec2 const & bounds) const {
-    math::vec2 const factor = screen_size / bounds;
+    math::vec2 const factor = screen_size_ / bounds;
     float const scale = std::min(factor[0], factor[1]);
     return std::make_shared<graphics::batch_renderer>(
-        renderer.get(), math::matrix::scalar(make_vector(scale, scale, 1.f)));
+        renderer_.get(), math::matrix::scalar(make_vector(scale, scale, 1.f)));
   }
 }