[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Usata-commits] Changes to usata2/src/usata.cpp
From: |
David Lau |
Subject: |
[Usata-commits] Changes to usata2/src/usata.cpp |
Date: |
Sun, 02 Jan 2005 02:19:42 -0500 |
Index: usata2/src/usata.cpp
diff -u usata2/src/usata.cpp:1.12 usata2/src/usata.cpp:1.13
--- usata2/src/usata.cpp:1.12 Fri Dec 31 07:27:46 2004
+++ usata2/src/usata.cpp Sun Jan 2 06:34:43 2005
@@ -10,7 +10,7 @@
// included in the software distribution, or visit
// http://www.fsf.org/licenses/gpl.html.
//
-// $Id: usata.cpp,v 1.12 2004/12/31 07:27:46 skunix Exp $
+// $Id: usata.cpp,v 1.13 2005/01/02 06:34:43 skunix Exp $
#include "usata.hpp"
#include "config.hpp"
@@ -20,7 +20,7 @@
#include "log.hpp"
#include "texture.hpp"
#include "scene-manager.hpp"
-#include <stdexcept>
+#include "exception_types.hpp"
#include <boost/format.hpp>
#include <boost/filesystem/operations.hpp>
#include <memory>
@@ -28,6 +28,41 @@
namespace usata
{
+class Clocker
+{
+ unsigned cnt;
+ unsigned int next;
+ public:
+ bool try_next();
+ void xsync();
+};
+
+bool
+Clocker::try_next()
+{
+ if (system::time::get_ticks()>= next)
+ {
+ next +=16;
+ ++cnt;
+ if (cnt >= 3)
+ {
+ cnt=0;
+ ++next;
+ }
+ return true;
+ }
+
+ return false;
+}
+
+void
+Clocker::xsync()
+{
+ next=system::time::get_ticks();
+ cnt=0;
+}
+
+
namespace
{
@@ -68,7 +103,7 @@
: texture_manager(new TextureManager),
scene(new SceneManager)
{
-
+
}
Usata::~Usata()
@@ -106,6 +141,28 @@
}
int
+Usata::loop()
+{
+ Clocker clock;
+ clock.xsync();
+ quit = false;
+
+ unsigned int cnt=0;
+
+ while (!quit)
+ {
+ while (clock.try_next())
+ ++cnt;
+
+ if (cnt > 60)
+ quit=true;
+
+ }
+
+ return 0;
+}
+
+int
Usata::run()
{
log::BufferedStream logstream;
@@ -119,7 +176,9 @@
//texture_manager->get("atex");
- return 0;
+ return loop();
}
+
+
} // namespace usata
- [Usata-commits] Changes to usata2/src/usata.cpp, David Lau, 2005/01/02
- [Usata-commits] Changes to usata2/src/usata.cpp,
David Lau <=
- [Usata-commits] Changes to usata2/src/usata.cpp, David Lau, 2005/01/03
- [Usata-commits] Changes to usata2/src/usata.cpp, David Lau, 2005/01/09
- [Usata-commits] Changes to usata2/src/usata.cpp, David Lau, 2005/01/10
- [Usata-commits] Changes to usata2/src/usata.cpp, David Lau, 2005/01/15
- [Usata-commits] Changes to usata2/src/usata.cpp, David Lau, 2005/01/17
- [Usata-commits] Changes to usata2/src/usata.cpp, David Lau, 2005/01/19
- [Usata-commits] Changes to usata2/src/usata.cpp, David Lau, 2005/01/20
- [Usata-commits] Changes to usata2/src/usata.cpp, David Lau, 2005/01/21
- [Usata-commits] Changes to usata2/src/usata.cpp, David Lau, 2005/01/25