Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 375


Ignore:
Timestamp:
Dec 3, 2007, 10:02:06 PM (17 years ago)
Author:
landauf
Message:

added a "Tickable"-interface
added a "Timer"-class

Location:
code/branches/objecthierarchy/src
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/CMakeLists.txt

    r258 r375  
    33# create a few variables to simplify life
    44SET(SRC_FILES orxonox/orxonox.cc loader/LevelLoader.cc xml/xmlParser.cc orxonox/core/IdentifierList.cc orxonox/core/Identifier.cc orxonox/core/MetaObjectList.cc orxonox/core/Factory.cc orxonox/core/OrxonoxClass.cc orxonox/objects/BaseObject.cc orxonox/objects/test1.cc orxonox/objects/test2.cc orxonox/objects/test3.cc)
    5 SET(INC_FILES loader/LevelLoader.h xml/xmlParser.h orxonox/core/IdentifierIncludes.h orxonox/core/Identifier.h orxonox/core/Factory.h orxonox/core/ClassFactory.h orxonox/core/IdentifierList.h orxonox/core/ObjectList.h orxonox/core/MetaObjectList.h orxonox/core/Iterator.h orxonox/core/OrxonoxClass.h orxonox/objects/BaseObject.h orxonox/objects/Test.h orxonox/objects/test1.h orxonox/objects/test2.h orxonox/objects/test3.h)
     5SET(INC_FILES loader/LevelLoader.h xml/xmlParser.h orxonox/core/IdentifierIncludes.h orxonox/core/Identifier.h orxonox/core/Factory.h orxonox/core/ClassFactory.h orxonox/core/IdentifierList.h orxonox/core/ObjectList.h orxonox/core/MetaObjectList.h orxonox/core/Iterator.h orxonox/core/OrxonoxClass.h orxonox/objects/BaseObject.h orxonox/objects/Test.h orxonox/objects/test1.h orxonox/objects/test2.h orxonox/objects/test3.h orxonox/objects/Tickable.h orxonox/objects/Timer.h)
    66
    77#Creates an executable
  • code/branches/objecthierarchy/src/orxonox/objects/test1.cc

    r258 r375  
    1818    Test1::~Test1()
    1919    {
     20    }
     21
     22    void Test1::tick(float dt)
     23    {
     24        std::cout << "Test1: " << this << "\n";
    2025    }
    2126
  • code/branches/objecthierarchy/src/orxonox/objects/test1.h

    r258 r375  
    33
    44#include "BaseObject.h"
     5#include "Tickable.h"
    56#include "test3.h"
    67
    78namespace orxonox
    89{
    9     class Test1 : public BaseObject
     10    class Test1 : public BaseObject, public Tickable
    1011    {
    1112        public:
    1213            Test1();
    1314            virtual ~Test1();
     15
     16            virtual void tick(float dt);
    1417
    1518            bool usefullClass1isA(Identifier* identifier);
  • code/branches/objecthierarchy/src/orxonox/objects/test2.cc

    r258 r375  
    1414        this->usefullClass2_ = Class(Test2);
    1515        this->usefullClass3_ = Class(Test3);
     16
     17        timer1.setTimer(1, true, this, &Test2::timerFunction1);
     18        timer2.setTimer(5, true, this, &Test2::timerFunction2);
     19        timer3.setTimer(10, false, this, &Test2::timerFunction3);
    1620    }
    1721
    1822    Test2::~Test2()
    1923    {
     24    }
     25
     26    void Test2::timerFunction1()
     27    {
     28        std::cout << "Test2: 1 Sekunde\n";
     29    }
     30
     31    void Test2::timerFunction2()
     32    {
     33        std::cout << "Test2: 5 Sekunden\n";
     34    }
     35
     36    void Test2::timerFunction3()
     37    {
     38        std::cout << "Test2: 10 Sekunden sind um!\n";
    2039    }
    2140
  • code/branches/objecthierarchy/src/orxonox/objects/test2.h

    r258 r375  
    33
    44#include "BaseObject.h"
     5#include "Timer.h"
    56
    67namespace orxonox
     
    2122            void setUsefullClassOfTypeTest3(Identifier* identifier);
    2223
     24            void timerFunction1();
     25            void timerFunction2();
     26            void timerFunction3();
     27
    2328        private:
    2429            Identifier* usefullClass1_;
     
    2631            SubclassIdentifier<Test3> usefullClass3_;
    2732
     33            Timer<Test2> timer1;
     34            Timer<Test2> timer2;
     35            Timer<Test2> timer3;
    2836    };
    2937}
  • code/branches/objecthierarchy/src/orxonox/orxonox.cc

    r366 r375  
    3939#include <iostream>
    4040
    41 #include "../xml/xmlParser.h"
    42 #include "../loader/LevelLoader.h"
     41//#include "../xml/xmlParser.h"
     42//#include "../loader/LevelLoader.h"
    4343
    4444#include "core/IdentifierIncludes.h"
     45#include "objects/Tickable.h"
     46#include "objects/Timer.h"
     47
    4548#include "objects/BaseObject.h"
    4649#include "objects/Test.h"
     
    4851#include "objects/test2.h"
    4952#include "objects/test3.h"
    50 
    5153
    5254// some tests to see if enet works without includsion
     
    106108      void go()
    107109      {
    108 /*
    109110        createRoot();
    110111        defineResources();
     
    117118        setupCEGUI();
    118119        createFrameListener();
    119         startRenderLoop();
    120 */
     120
    121121
    122122        #define testandcout(code) \
     
    148148        test4 = new A3();
    149149*/
    150 
     150/*
    151151        std::cout << "Test 5\n";
    152152        A1* test5_01 = new A1();
     
    218218        std::cout << "ID of BaseObject: " << Class(BaseObject)->getNetworkID() << "\n";
    219219        std::cout << "ID of Test1: " << Class(Test1)->getNetworkID() << "\n";
    220 
     220*/
    221221/*
    222222        std::cout << "\n";
     
    474474        delete test9_06;
    475475*/
    476 
     476/*
    477477        std::cout << "Test 10\n";
    478478        Identifier* test10_01 = Class(A1B2);
     
    605605
    606606        std::cout << "13\n";
    607 
     607*/
     608        std::cout << "Test 11\n";
     609/*
     610        std::cout << "1\n";
     611        count = 0; for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) { count++; }
     612        std::cout << "AnzahlTickable: " << count << "\n";
     613
     614        Test1* test11_1;
     615        for (int i = 0; i < 3; i++)
     616            test11_1 = new Test1;
     617
     618        count = 0; for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) { count++; }
     619        std::cout << "AnzahlTickable: " << count << "\n";
     620
     621        for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
     622            it->tick(0);
     623
     624        std::cout << "2\n";
     625*/
     626
     627        Test2* test11_2 = new Test2;
     628        std::cout << "3\n";
     629
     630        startRenderLoop();
    608631      }
    609632
     
    687710      {
    688711
    689         string levelFile = "sp_level_moonstation.oxw";
    690         loader::LevelLoader* loader = new loader::LevelLoader(levelFile);
     712//        string levelFile = "sp_level_moonstation.oxw";
     713//        loader::LevelLoader* loader = new loader::LevelLoader(levelFile);
    691714      }
    692715
     
    735758      void createFrameListener()
    736759      {
     760        TickFrameListener* TickFL = new TickFrameListener();
     761        mRoot->addFrameListener(TickFL);
     762
     763        TimerFrameListener* TimerFL = new TimerFrameListener();
     764        mRoot->addFrameListener(TimerFL);
     765
    737766        mListener = new OrxExitListener(mKeyboard);
    738767        mRoot->addFrameListener(mListener);
Note: See TracChangeset for help on using the changeset viewer.