]> 4ch.mooo.com Git - 16.git/blobdiff - src/eng_core.cpp
modified: src/eng_core.cpp
[16.git] / src / eng_core.cpp
index 67c50978ff8b24156f4c29cc5849854f01287e16..2bfb4ca153c7cb0e4a053d8a3c2c331b8475fb6b 100644 (file)
@@ -1,5 +1,5 @@
 #include "src\eng_core.h"\r
-#include <list>\r
+\r
 #include "src\eng_snd.h"\r
 #include "src\eng_gfx.h"\r
 #include "src\eng_comm.h"\r
@@ -7,9 +7,9 @@
 \r
 #include <iostream>\r
 \r
-#include "src\lib\dos_gfx.h"\r
-#include "src\lib\opl2.h"\r
-#include "src\lib\dos_comm.h"\r
+//#include "src\lib\dos_gfx.h"\r
+//#include "src\lib\opl2.h"\r
+//#include "src\lib\dos_comm.h"\r
 \r
 namespace engine{\r
 \r
@@ -19,36 +19,35 @@ namespace engine{
                this->init();\r
                \r
                //default constructor\r
-               this->fp = new std::list<void(Core::*)()>;\r
                this->msg = ENGINE_RUN;\r
                this->timer.start_timer();\r
-               this->frames_per_second = 60;
-\r
-               this->fp->push_back(&Core::sound);\r
-               this->fp->push_back(&Core::graphics);\r
-               this->fp->push_back(&Core::comm);\r
-               this->fp->push_back(&Core::ai);\r
-\r
-               //this->fp.push_back(&core::sound);\r
-               //this->fp.push_back(&core::graphics);\r
-               //this->fp.push_back(&core::comm);\r
-               //this->fp.push_back(&engine::core::ai);
-
-               // Global Variables
-               this->qing = 4; // test global variable\r
-               this->x = 0; // X
+               this->frames_per_second = 60;\r
+\r
+               // Global Variables\r
+               this->bing = 4; // test global variable\r
+               this->x = 0; // X\r
                this->y = 0; // Y\r
+               \r
+               // Start setttings of flags.  I hope I got the same\r
+               // logic as it was before, with the STL list.\r
+               this->graphics_flag = true;\r
+               this->comm_flag = true;\r
+               this->release_flag = false;\r
        }\r
 \r
        void Core::update()\r
        {\r
-               for (std::list<void(Core::*)()>::iterator i = fp->begin(); i != fp->end(); i++)\r
-               //for (std::list<void(core::*)()>::iterator i = this->fp.begin(); i != this->fp.end(); i++)\r
-               {\r
-                       \r
-                       (this->*(*i))();\r
-               }\r
-\r
+         // call update functions, instead of traversing a function pointer\r
+         // list.  Remove this comment!\r
+\r
+         sound();\r
+         if ( graphics_flag )\r
+                 graphics();\r
+         if ( comm_flag )\r
+                 comm();\r
+         ai();\r
+         if ( release_flag )\r
+                 release();\r
        }\r
 \r
        void Core::sound()\r
@@ -78,7 +77,7 @@ namespace engine{
                //if (this->timer.elapsed_timer() >= fps)\r
                //{\r
                //wrap comm lib\r
-               this->msg = do_communication(scankey());\r
+               this->msg = do_communication();\r
                //this->timer.start_timer();\r
                //}\r
        }\r
@@ -102,8 +101,7 @@ namespace engine{
 //----                 i++;if(i==600){char a;std::cin >> a;this->keeq[a] = true;i=0;}\r
                        this->sync();\r
                        this->input();\r
-                       this->update();
-//tt                   std::cout << this->qing << std::endl;
+                       this->update();\r
                }\r
        }\r
 \r
@@ -147,7 +145,6 @@ namespace engine{
                //dummy 'w' and 'p' down, t up\r
 //----         bool dummy_input_available = true;\r
 //----         if(dummy_input_available)\r
-               //if (scankey() <= 128)\r
 //----         {\r
 //----                 std::cout << "key down" << std::endl;\r
 //----                 this->keeq['w'] = true;\r
@@ -168,32 +165,31 @@ namespace engine{
                if (this->timer.elapsed_timer() >= (1.0 / this->frames_per_second))\r
                {\r
                        //int a;std::cin >> a;\r
-                       this->fp->push_back(&Core::graphics);\r
+                       graphics_flag = true;\r
                        this->timer.start_timer();\r
 //====                 std::cout << "GRAPHICS GRAPHICS GRAPHICS GRAPHICS GRAPHICS" << std::endl;\r
                }\r
                else\r
                {\r
-                       this->fp->remove(&Core::graphics);\r
+                       graphics_flag = false;\r
                }\r
                if (ENGINE_INPUT == this->msg)\r
                {\r
-                       this->fp->push_back(&Core::comm);\r
+                       comm_flag = true;\r
                }\r
                else\r
                {\r
-                       this->fp->remove(&Core::comm);\r
+                       comm_flag = false;\r
                }\r
                if (ENGINE_QUIT == this->msg)\r
                {\r
-                       this->fp->push_back(&Core::release);\r
+                       release_flag = true;\r
                }\r
        }\r
 \r
        Core::~Core()\r
        {\r
                //deconstructor\r
-               delete(this->fp);\r
        }\r
 \r
 }\r