浏览代码

Split level::update into sensible sectors.

Sam Jaffe 6 年之前
父节点
当前提交
8191079436
共有 2 个文件被更改,包括 12 次插入2 次删除
  1. 3 1
      include/danmaku/level.hpp
  2. 9 1
      src/level.cxx

+ 3 - 1
include/danmaku/level.hpp

@@ -31,8 +31,10 @@ namespace danmaku {
     void set_player(player * p) { player_ = p; }
     void add_bullet(bullet b);
 
-  public:
+  private:
     void update_waves(float delta);
+    void update_object(float delta);
+    void check_collisions();
 
   private:
     player * player_;

+ 9 - 1
src/level.cxx

@@ -74,6 +74,11 @@ void level::add_bullet(bullet b) {
 
 void level::update(float delta) {
   update_waves(delta);
+  update_object(delta);
+  check_collisions();
+}
+
+void level::update_object(float delta) {
   player_->update(delta);
   for (auto & a : actors_) {
     a->update(delta);
@@ -81,7 +86,10 @@ void level::update(float delta) {
   for (auto & b : bullets_) {
     b->update(delta);
   }
-  check_collisions();
+}
+
+void level::check_collisions() {
+  engine::scene::check_collisions();
   // TODO: This is a bad hack until I can properly disassociate collision info
   for (auto & b : bullets_) {
     if (math::intersects(player_->render_info().points,