X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Feng_core.cpp;h=8e1248d844342efadf94d57051d13b1a6349158a;hb=1383e43fba409a7f879a4a4d406bed30ebe0b0a1;hp=8f790fac2bf23742a423a8a6e424d4c7154eb3f3;hpb=2153ae506cd9faaea1e62cfdde4deb4fc97a384e;p=16.git diff --git a/src/eng_core.cpp b/src/eng_core.cpp index 8f790fac..8e1248d8 100644 --- a/src/eng_core.cpp +++ b/src/eng_core.cpp @@ -1,5 +1,5 @@ #include "src\eng_core.h" -#include + #include "src\eng_snd.h" #include "src\eng_gfx.h" #include "src\eng_comm.h" @@ -19,35 +19,35 @@ namespace engine{ this->init(); //default constructor - this->fp = new std::list; this->msg = ENGINE_RUN; this->timer.start_timer(); this->frames_per_second = 60; - this->fp->push_back(&Core::sound); - this->fp->push_back(&Core::graphics); - this->fp->push_back(&Core::comm); - this->fp->push_back(&Core::ai); - - //this->fp.push_back(&core::sound); - //this->fp.push_back(&core::graphics); - //this->fp.push_back(&core::comm); - //this->fp.push_back(&engine::core::ai); - // Global Variables this->bing = 4; // test global variable this->x = 0; // X this->y = 0; // Y + + // Start setttings of flags. I hope I got the same + // logic as it was before, with the STL list. + this->graphics_flag = true; + this->comm_flag = true; + this->release_flag = false; } void Core::update() { - for (std::list::iterator i = fp->begin(); i != fp->end(); i++) - //for (std::list::iterator i = this->fp.begin(); i != this->fp.end(); i++) - { - (this->*(*i))(); - } - + // call update functions, instead of traversing a function pointer + // list. Remove this comment! + + sound(); + if ( graphics_flag ) + graphics(); + if ( comm_flag ) + comm(); + ai(); + if ( release_flag ) + release(); } void Core::sound() @@ -122,8 +122,8 @@ namespace engine{ std::cout << "1 - 9 for graphical tests!" << std::endl; std::cout << "space bar for control and sprite test!" << std::endl; std::cout << "z key for noise!" << std::endl; - std::cout << "Press press any key to continue!" << std::endl; - getch(); + //std::cout << "Press press any key to continue!" << std::endl; + //getch(); std::cout << "INPUT INITIATION" << std::endl; setkb(1); std::cout << "INITIATION" << std::endl; @@ -165,32 +165,31 @@ namespace engine{ if (this->timer.elapsed_timer() >= (1.0 / this->frames_per_second)) { //int a;std::cin >> a; - this->fp->push_back(&Core::graphics); + graphics_flag = true; this->timer.start_timer(); //==== std::cout << "GRAPHICS GRAPHICS GRAPHICS GRAPHICS GRAPHICS" << std::endl; } else { - this->fp->remove(&Core::graphics); + graphics_flag = false; } if (ENGINE_INPUT == this->msg) { - this->fp->push_back(&Core::comm); + comm_flag = true; } else { - this->fp->remove(&Core::comm); + comm_flag = false; } if (ENGINE_QUIT == this->msg) { - this->fp->push_back(&Core::release); + release_flag = true; } } Core::~Core() { //deconstructor - delete(this->fp); } }