Some notes about co-op mode
authormathnerd314 <mathnerd314@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Sun, 7 Mar 2010 23:43:26 +0000 (23:43 +0000)
committermathnerd314 <mathnerd314@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Sun, 7 Mar 2010 23:43:26 +0000 (23:43 +0000)
git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6574 837edb03-e0f3-0310-88ca-d4d4e8b29345

src/object/camera.cpp
src/object/player.cpp
src/supertux/sector.cpp

index 1a91ca9..93fb818 100644 (file)
@@ -305,7 +305,8 @@ Camera::update_scroll_normal(float elapsed_time)
 {
   const CameraConfig& config = *(this->config);
   Player* player = sector->player;
-  const Vector& player_pos = Vector(player->get_bbox().get_middle().x,
+  // TODO: co-op mode needs a good camera
+  Vector player_pos(player->get_bbox().get_middle().x,
                                     player->get_bbox().get_bottom());
   static Vector last_player_pos = player_pos;
   Vector player_delta = player_pos - last_player_pos;
index e673d86..86318a5 100644 (file)
@@ -154,6 +154,9 @@ Player::Player(PlayerStatus* _player_status, const std::string& name) :
   this->name = name;
   controller = g_main_controller;
   scripting_controller.reset(new CodeController());
+  // if/when we have complete penny gfx, we can
+  // load those instead of Tux's sprite in the
+  // constructor
   sprite = sprite_manager->create("images/creatures/tux/tux.sprite");
   airarrow = Surface::create("images/engine/hud/airarrow.png");
   idle_timer.start(IDLE_TIME[0]/1000.0f);
@@ -1202,6 +1205,11 @@ Player::collision(GameObject& other, const CollisionHit& hit)
     return FORCE_MOVE;
   }
 
+  Player* player = dynamic_cast<Player*> (&other);
+  if(player) {
+    return ABORT_MOVE;
+  }
+
   if(hit.left || hit.right) {
     try_grab(); //grab objects right now, in update it will be too late
   }
@@ -1290,6 +1298,7 @@ Player::kill(bool completely)
     dying_timer.start(3.0);
     set_group(COLGROUP_DISABLED);
 
+    // TODO: need nice way to handle players dying in co-op mode
     Sector::current()->effect->fade_out(3.0);
     sound_manager->stop_music(3.0);
   }
index 273c1d4..cffda6b 100644 (file)
@@ -575,19 +575,28 @@ Sector::activate(const Vector& player_pos)
   }
   try_expose_me();
 
-  // spawn smalltux below spawnpoint
-  if (!player->is_big()) {
-    player->move(player_pos + Vector(0,32));
-  } else {
-    player->move(player_pos);
-  }
 
-  // spawning tux in the ground would kill him
-  if(!is_free_of_tiles(player->get_bbox())) {
-    log_warning << "Tried spawning Tux in solid matter. Compensating." << std::endl;
-    Vector npos = player->get_bbox().p1;
-    npos.y-=32;
-    player->move(npos);
+  // two-player hack: move other players to main player's position
+  // Maybe specify 2 spawnpoints in the level?
+  for(GameObjects::iterator i = gameobjects.begin();
+      i != gameobjects.end(); ++i) {
+    Player* p = dynamic_cast<Player*>(*i);
+    if (!p) continue;
+
+    // spawn smalltux below spawnpoint
+    if (!p->is_big()) {
+      p->move(player_pos + Vector(0,32));
+    } else {
+      p->move(player_pos);
+    }
+
+    // spawning tux in the ground would kill him
+    if(!is_free_of_tiles(p->get_bbox())) {
+      log_warning << "Tried spawning Tux in solid matter. Compensating." << std::endl;
+      Vector npos = p->get_bbox().p1;
+      npos.y-=32;
+      p->move(npos);
+    }
   }
 
   camera->reset(player->get_pos());