From: mathnerd314 Date: Sun, 7 Mar 2010 23:43:26 +0000 (+0000) Subject: Some notes about co-op mode X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c6e51efddc6f6dabd72b70a7d84cf24ee677f082;p=supertux.git Some notes about co-op mode git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6574 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- diff --git a/src/object/camera.cpp b/src/object/camera.cpp index 1a91ca93c..93fb81829 100644 --- a/src/object/camera.cpp +++ b/src/object/camera.cpp @@ -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; diff --git a/src/object/player.cpp b/src/object/player.cpp index e673d8696..86318a521 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -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 (&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); } diff --git a/src/supertux/sector.cpp b/src/supertux/sector.cpp index 273c1d45d..cffda6b0e 100644 --- a/src/supertux/sector.cpp +++ b/src/supertux/sector.cpp @@ -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(*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());