Kaynağa Gözat

Split level::update into sensible sectors.

Sam Jaffe 6 yıl önce
ebeveyn
işleme
8191079436
2 değiştirilmiş dosya ile 12 ekleme ve 2 silme
  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,