Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

LogicTest.cpp

Go to the documentation of this file.
00001 
00002 /* standalone testprogram for the logic system */
00003 /* many of the functionality that needs an environment (embedding) is disabled */
00004 
00005 #include "SCA_KeyboardSensor.h"
00006 #include "SCA_KeyboardManager.h"
00007 #include "GlutSystem.h"
00008 #include "SCA_LogicManager.h"
00009 #include "SCA_ANDController.h"
00010 #include "DebugActuator.h"
00011 #include "SCA_AlwaysSensor.h"
00012 #include "SCA_AlwaysEventManager.h"
00013 
00014 #include "GlutKeyboardDevice.h"
00015 
00016 
00017 
00018 class ExampleSystem: public SCA_IMainLoop
00019 {
00020         SCA_LogicManager*       m_logicmgr;
00021 
00022 public:
00023         ExampleSystem() : m_logicmgr(NULL) {};
00024         virtual ~ExampleSystem() {};
00025         void    SetLogicMgr(SCA_LogicManager* mgr) {            m_logicmgr=mgr; };
00026         virtual int MainLoopCallback()

00027         {
00028                 double curtime=0, deltatime=0;
00029                 if (m_logicmgr)
00030                 {
00031                         m_logicmgr->BeginFrame(curtime,deltatime);
00032                         m_logicmgr->UpdateFrame(curtime,deltatime);
00033                         m_logicmgr->EndFrame();
00034                 }
00035                 return 0;
00036         };
00037 };
00038 
00039 int main()

00040 {
00041         
00042         KX_GlutInputDevice* inputdev = new GlutKeyboardDevice();
00043         SCA_ISystem* system = NewGlutSystem();
00044         system->SetKeyboardDevice(inputdev);
00045 
00046 
00047         SCA_LogicManager* logicmgr = new SCA_LogicManager();
00048         SCA_KeyboardManager* kbdeventmgr = new SCA_KeyboardManager(logicmgr,inputdev);
00049         SCA_AlwaysEventManager* alwayseventmgr = new SCA_AlwaysEventManager(logicmgr);
00050 
00051         // register the eventmanagers to the logicmanager
00052         logicmgr->RegisterEventManager(kbdeventmgr);
00053         logicmgr->RegisterEventManager(alwayseventmgr);
00054 
00055         // setup a KeyboardSensor, an AlwaysSensor, an ANDController and a DebugActuator
00056         
00057         SCA_ISensor* keysensor = new SCA_KeyboardSensor(kbdeventmgr,
00058                 SCA_IInputDevice::KX_EKEY,0,0,false,NULL);
00059         keysensor->RegisterToManager();
00060         //SCA_ISensor* alwayssensor = new SCA_AlwaysSensor(alwayseventmgr,NULL);
00061         //alwayssensor->RegisterToManager();
00062         SCA_IController* andctrl = new SCA_ANDController(NULL);
00063         SCA_IActuator* actua = new DebugActuator(NULL);
00064 
00065         // link the controller to both sensors and the actuator
00066         //logicmgr->RegisterToSensor(andctrl,alwayssensor);
00067         logicmgr->RegisterToSensor(andctrl,keysensor);
00068         logicmgr->RegisterToActuator(andctrl,actua);
00069 
00070         ExampleSystem* mylooper = new ExampleSystem();
00071         mylooper->SetLogicMgr(logicmgr);
00072 
00073         system->SetMainLoop(mylooper);
00074         system->StartMainLoop();
00075                 
00076         return 0;
00077 }

Generated at Thu Feb 1 13:03:07 2001 for Ketsji Game Engine by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000