]> Dogcows Code - chaz/yoink/blobdiff - src/YoinkApp.cc
new timer class
[chaz/yoink] / src / YoinkApp.cc
index 597a74ff79d24b11a7bf54d7dc91e5dfc6758ed1..a9b8f1328068029f42442cfa16630234db76f3a3 100644 (file)
 #include <iostream>
 #include <string>
 
-#include <boost/bind.hpp>
-
 #include <Moof/Exception.hh>
 #include <Moof/Log.hh>
 #include <Moof/Math.hh>
 #include <Moof/OpenGL.hh>
 #include <Moof/Settings.hh>
+#include <Moof/Thread.hh>
 #include <Moof/Timer.hh>
 #include <Moof/Video.hh>
 
@@ -100,9 +99,31 @@ static std::string iconFile()
 }
 
 
+void YoinkApp::myFunc(Mf::Timer& timer, Mf::Scalar t)
+{
+       std::cout << "timer: " << t << std::endl;
+       
+       //timer.invalidate();
+}
+
+int YoinkApp::myThread()
+{
+       Mf::Scalar timer = Mf::Timer::getTicks();
+
+       for (;;)
+       {
+               std::cout << "thread awake: " << Mf::Timer::getTicks() << std::endl;
+
+               timer += 3.0;
+               Mf::Timer::sleep(timer, true);
+       }
+       return 0;
+}
+
+
 YoinkApp::YoinkApp(int argc, char* argv[]) :
        Mf::Engine(argc, argv, configFiles(), PACKAGE_STRING, iconFile()),
-       music("BeatTheCube"),
+       music("NightFusionIntro"),
        punchSound("RobotPunch")
 {
        Mf::dispatcher::addHandler("video.context_recreated",
@@ -124,6 +145,11 @@ YoinkApp::YoinkApp(int argc, char* argv[]) :
 
        octree = Mf::loadScene("Test");
        heroine->treeNode = octree->insert(heroine);
+
+       //myTimer.init(boost::bind(&YoinkApp::myFunc, this, _1, _2),
+                       //0.0, Mf::Timer::REPEAT);
+       //Mf::Thread thread = Mf::detachFunction(boost::bind(&YoinkApp::myThread, this));
+       //std::cout << "thread " << thread << " detached." << std::endl;
 }
 
 YoinkApp::~YoinkApp()
@@ -174,9 +200,8 @@ void YoinkApp::contextRecreated(const Mf::Notification* note)
 
 void YoinkApp::update(Mf::Scalar t, Mf::Scalar dt)
 {
-       dt *= 0.7;
+       //dt *= 0.7;
 
-       music.update(t, dt);
        fadeIn.update(dt);
        camera.update(t, dt);
        heroine->update(t, dt);
@@ -186,7 +211,8 @@ void YoinkApp::update(Mf::Scalar t, Mf::Scalar dt)
        octree->print(heroine->treeNode);
        
        //camera.lookAt(heroine->getSphere().point);
-       camera.setPosition(Mf::Vector3(-heroine->current.position[0], -heroine->current.position[1], -256));
+       camera.setPosition(Mf::Vector3(-heroine->current.position[0],
+                               -heroine->current.position[1], -256));
 
        interp.update(dt);
        hud.setBar1Progress(interp.getState(dt));
@@ -294,7 +320,8 @@ void YoinkApp::handleEvent(const Mf::Event& event)
                case SDL_VIDEORESIZE:
                        glViewport(0, 0, event.resize.w, event.resize.h);
                        hud.resize(event.resize.w, event.resize.h);
-                       camera.setProjection(cml::rad(60.0), double(event.resize.w / event.resize.h), 32.0, 2500.0);
+                       camera.setProjection(cml::rad(60.0),
+                               double(event.resize.w) / double(event.resize.h), 32.0, 2500.0);
                        camera.uploadProjectionToGL();
                        break;
        }
This page took 0.01798 seconds and 4 git commands to generate.