src/game/game_loop.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *  Wormux is a convivial mass murder game.
00003  *  Copyright (C) 2001-2004 Lawrence Azzoug.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00018  ******************************************************************************
00019  * Game loop : drawing and data handling
00020  *****************************************************************************/
00021 
00022 #ifndef GAME_LOOP_H
00023 #define GAME_LOOP_H
00024 
00025 #include "../graphic/fps.h"
00026 #include "../include/base.h"
00027 #include "../character/character.h"
00028 #include "../network/chat.h"
00029 
00030 class GameLoop
00031 {
00032 private:
00033   int state;
00034   uint pause_seconde;
00035   uint duration;
00036 
00037 public:
00038   static const int PLAYING = 0;
00039   static const int HAS_PLAYED = 1;
00040   static const int END_TURN = 2;
00041 
00042   FramePerSecond fps;
00043   Chat chatsession;
00044 
00045   static GameLoop * singleton;
00046   GameLoop();
00047 
00048 public:
00049   static GameLoop * GetInstance();
00050 
00051   void Init();
00052 
00053   bool character_already_chosen;
00054   bool interaction_enabled;
00055 
00056   // Draw to screen
00057   void Draw();
00058 
00059   // Main loop
00060   void Run();
00061 
00062   // Refresh all objects (position, state ...)
00063   void RefreshObject();
00064   void RefreshInput();
00065   void RefreshClock();
00066   void PingClient();
00067 
00068   // Read/Set State
00069   int ReadState() const { return state; }
00070   void SetState(int new_state, bool begin_game=false);
00071 
00072   // Signal death of a player
00073   void SignalCharacterDeath (Character *character);
00074 
00075   // Signal character damage
00076   void SignalCharacterDamage(Character *character);
00077 
00078 private:
00079 
00080   void InitGameData_NetServer();
00081   void InitGameData_NetClient();
00082   void InitData_Local();
00083   void InitData();
00084 
00085   void CallDraw();
00086 
00087   PhysicalObj* GetMovingObject();
00088   bool IsAnythingMoving();
00089   void ApplyDiseaseDamage();
00090   void ApplyDeathMode();
00091 };
00092 #endif

Generated on Mon Jan 1 13:10:56 2007 for Wormux by  doxygen 1.4.7