1 #include "src\eng_core.h"
\r
3 #include "src\eng_snd.h"
\r
4 #include "src\eng_gfx.h"
\r
5 #include "src\eng_comm.h"
\r
6 #include "src\eng_ai.h"
\r
10 //#include "src\lib\dos_gfx.h"
\r
11 //#include "src\lib\opl2.h"
\r
12 //#include "src\lib\dos_comm.h"
\r
18 // Hardware Initiation
\r
21 //default constructor
\r
22 this->fp = new std::list<void(Core::*)()>;
\r
23 this->msg = ENGINE_RUN;
\r
24 this->timer.start_timer();
\r
25 this->frames_per_second = 60;
\r
27 this->fp->push_back(&Core::sound);
\r
28 this->fp->push_back(&Core::graphics);
\r
29 this->fp->push_back(&Core::comm);
\r
30 this->fp->push_back(&Core::ai);
\r
32 //this->fp.push_back(&core::sound);
\r
33 //this->fp.push_back(&core::graphics);
\r
34 //this->fp.push_back(&core::comm);
\r
35 //this->fp.push_back(&engine::core::ai);
\r
38 this->bing = 4; // test global variable
\r
45 for (std::list<void(Core::*)()>::iterator i = fp->begin(); i != fp->end(); i++)
\r
46 //for (std::list<void(core::*)()>::iterator i = this->fp.begin(); i != this->fp.end(); i++)
\r
58 void Core::graphics()
\r
60 //int num_frames = 60;
\r
61 //double fps = 1.0 / num_frames;
\r
62 //double now = this->timer.elapsed_timer();
\r
63 //std::cout << "fps: " << fps << " now: " << now << std::endl;
\r
64 //if (this->timer.elapsed_timer() >= fps)
\r
68 //this->timer.start_timer();
\r
73 //int num_frames = 60;
\r
74 //double fps = 1.0 / num_frames;
\r
75 //double now = this->timer.elapsed_timer();
\r
76 //std::cout << "fps: " << fps << " now: " << now << std::endl;
\r
77 //if (this->timer.elapsed_timer() >= fps)
\r
80 this->msg = do_communication();
\r
81 //this->timer.start_timer();
\r
87 do_artificial_intelligence();
\r
90 engine_message Core::_msg()
\r
98 while (ENGINE_EXIT != this->msg)
\r
100 //next line for purely testing purposes
\r
101 //---- i++;if(i==600){char a;std::cin >> a;this->keeq[a] = true;i=0;}
\r
109 bool xz = 0; // error switch...
\r
110 std::cout << "VIDEO INITIATION" << std::endl;
\r
113 std::cout << "Checking for Adlib sound card...." << std::endl;
\r
114 if(!AdlibExists()){
\r
115 std::cout << "not found." << std::endl;
\r
118 std::cout << "found." << std::endl;
\r
119 std::cout << "OPL2 INITIATION" << std::endl;
\r
121 std::cout << "\nPress ESC to quit the game engine core test." << std::endl;
\r
122 std::cout << "1 - 9 for graphical tests!" << std::endl;
\r
123 std::cout << "space bar for control and sprite test!" << std::endl;
\r
124 std::cout << "z key for noise!" << std::endl;
\r
125 std::cout << "Press press any key to continue!" << std::endl;
\r
127 std::cout << "INPUT INITIATION" << std::endl;
\r
129 std::cout << "INITIATION" << std::endl;
\r
133 void Core::release()
\r
135 //release contexts and set engine to exit
\r
140 this->msg = ENGINE_EXIT;
\r
143 void Core::input(){
\r
144 //retrieve input device information
\r
145 //dummy 'w' and 'p' down, t up
\r
146 //---- bool dummy_input_available = true;
\r
147 //---- if(dummy_input_available)
\r
149 //---- std::cout << "key down" << std::endl;
\r
150 //---- this->keeq['w'] = true;
\r
151 //---- this->keeq['p'] = true;
\r
152 //---- this->keeq['t'] = false;
\r
153 //notify engine that input occured
\r
154 this->msg = ENGINE_INPUT;
\r
158 //---- std::cout << "key up" << std::endl;
\r
159 //---- this->msg = ENGINE_RUN;
\r
165 if (this->timer.elapsed_timer() >= (1.0 / this->frames_per_second))
\r
167 //int a;std::cin >> a;
\r
168 this->fp->push_back(&Core::graphics);
\r
169 this->timer.start_timer();
\r
170 //==== std::cout << "GRAPHICS GRAPHICS GRAPHICS GRAPHICS GRAPHICS" << std::endl;
\r
174 this->fp->remove(&Core::graphics);
\r
176 if (ENGINE_INPUT == this->msg)
\r
178 this->fp->push_back(&Core::comm);
\r
182 this->fp->remove(&Core::comm);
\r
184 if (ENGINE_QUIT == this->msg)
\r
186 this->fp->push_back(&Core::release);
\r