Niotso  git revision 558726a9f13d7c3423a683dd2f4323589b66c310
The New Implementation of The Sims Online
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Scene.hpp
Go to the documentation of this file.
1 /*
2  Niotso - The New Implementation of The Sims Online
3  Scene/Scene.hpp
4  Copyright (c) 2012 Niotso Project <http://niotso.org/>
5  Author(s): Fatbag <X-Fi6@phppoll.org>
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #define EXIT_SCENE() do { System::SceneFailed = true; delete this; return; } while(0)
22 #define SCENE_EXIT 0
23 #define SCENE_NEED_REDRAW 1
24 #define SCENE_NO_REDRAW -1
25 
26 class Scene {
27  const float TickPeriod;
29  virtual int Run(float TimeDelta) = 0;
30 
31  protected:
32  float TimeDelta;
33  Scene(float c) : TickPeriod(c), RealTimeDelta(0) {}
34 
35  public:
36  int RunFor(float TimeDelta) {
37  if(TickPeriod == 0){
38  return Run(TimeDelta);
39  }
40 
41  bool Redraw = false;
43  while(RealTimeDelta >= 0){
44  int result = Run(TickPeriod);
45  if(result == System::SHUTDOWN)
46  return System::SHUTDOWN;
47  if(result > 0) Redraw = true;
49  }
50  return (Redraw) ? 1 : -1;
51  }
52 
53  virtual void Render() = 0;
54  virtual ~Scene() {};
55 };
56 
57 /****
58 ** Scenes
59 */
60