/[enigma]/enigma/src/player.cc
ViewVC logotype

Diff of /enigma/src/player.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by dheck, Fri Jan 31 17:00:38 2003 UTC revision 1.8 by dheck, Sun Feb 2 18:32:17 2003 UTC
# Line 87  PlayerInfo::PlayerInfo () Line 87  PlayerInfo::PlayerInfo ()
87  namespace  namespace
88  {  {
89      PlayerList players;      PlayerList players;
90      int        icurrent_player               = 0;      unsigned   icurrent_player               = 0;
91      bool       current_player_inhibit_pickup = false;      bool       current_player_inhibit_pickup = false;
92      
93  }  }
94    
95  void  void
# Line 284  player::NewWorld() Line 284  player::NewWorld()
284  void  void
285  player::LevelFinished()  player::LevelFinished()
286  {  {
287      for (unsigned i=0; i<players.size(); ++i)      for (unsigned i=0; i<players.size(); ++i) {
     {  
288          for (unsigned j=0; j<players[i].actors.size(); ++j) {          for (unsigned j=0; j<players[i].actors.size(); ++j) {
289              Actor *a = players[i].actors[j];              Actor *a = players[i].actors[j];
290              SendMessage(a, "disappear");              SendMessage(a, "disappear");
 //             world::GrabActor(a);  
 //             display::ReplaceSprite(a->get_spriteid(), "ring-anim");  
291          }          }
292      }      }
293  }  }
# Line 376  resurrect_actor (unsigned pl, Actor *a) Line 373  resurrect_actor (unsigned pl, Actor *a)
373  ** Returns true if all actors are dead and they cannot be respawned  ** Returns true if all actors are dead and they cannot be respawned
374  ** (i.e., their owners don't have any extra lifes left).  ** (i.e., their owners don't have any extra lifes left).
375  */  */
376  bool  static bool
377  player::AllActorsDead()  AllPlayersDead()
378  {  {
379        bool all_players_dead=true;
380        unsigned old_player = icurrent_player;
381      for (unsigned i=0; i<players.size(); ++i) {      for (unsigned i=0; i<players.size(); ++i) {
382            bool actors_dead=true;
383          for (unsigned j=0; j<players[i].actors.size(); ++j) {          for (unsigned j=0; j<players[i].actors.size(); ++j) {
384              Actor *a = players[i].actors[j];              Actor *a = players[i].actors[j];
385              if (!a->is_dead() || resurrect_actor(i,a))              if (!a->is_dead() || resurrect_actor(i,a))
386                  return false;                  all_players_dead = actors_dead = false;
387            }
388            if (actors_dead && i==icurrent_player) {
389                // Switch to next player if this one is dead
390                unsigned nextplayer = (icurrent_player+1) % players.size();
391                SetCurrentPlayer (nextplayer);
392          }          }
393      }      }
394      return true;      if (all_players_dead)
395            SetCurrentPlayer(old_player);
396        return all_players_dead;
397  }  }
398    
399  void  void
# Line 402  player::Tick(double dtime) Line 409  player::Tick(double dtime)
409    
410      // Update the respawn list or restart the game when all actors are      // Update the respawn list or restart the game when all actors are
411      // dead and no extra lifes are left.      // dead and no extra lifes are left.
412      if (player::AllActorsDead()) {      if (AllPlayersDead()) {
413          enigma::RestartLevel();          enigma::RestartGame();
 //        change_state(PLAYERDEAD);  
414      }      }
415  }  }
416    

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26