??? More...
#include <Engine.h>
Public Types | |
| enum | KeyEvent { KEY_DOWN_EX = 1, KEY_UP_EX, KEY_DOWN_EX = 1, KEY_UP_EX } |
| Keyboard event. More... | |
| enum | KeyEvent { KEY_DOWN_EX = 1, KEY_UP_EX, KEY_DOWN_EX = 1, KEY_UP_EX } |
| Keyboard event. More... | |
Public Member Functions | |
| Engine () | |
| ~Engine () | |
| void | SendEvent (EventListener::EventType evt) |
| send event to all listeners | |
| void | AddEventListener (EventListener *el) |
| add el to even listener's list | |
| void | RemoveEventListener (EventListener *el) |
| remove el from event listeners list | |
| void | PostOperation (const Operation &operation) |
| Engine () | |
| ~Engine () | |
| void | SendEvent (EventListener::EventType evt) |
| send event to all listeners | |
| void | AddEventListener (EventListener *el) |
| add el to even listener's list | |
| void | RemoveEventListener (EventListener *el) |
| remove el from event listeners list | |
| void | PostOperation (const Operation &operation) |
Initiaization routines | |
Initialization is broken into tree funcdtions for flexibility of interactive calling. First call must be InitConfig() then one can make several calls to LoadConfig() to load configuration from multiple files and finaly InitGui must be call before any drawing is made. | |
| bool | InitConfig () |
| Call InitConfig first! | |
| bool | LoadConfig (const char *configName) |
| You can call LoadConfig multiple times after InitConfig. | |
| bool | InitGui () |
| Call InitGui before any drawing has been made. | |
| bool | InitConfig () |
| Call InitConfig first! | |
| bool | LoadConfig (const char *configName) |
| You can call LoadConfig multiple times after InitConfig. | |
| bool | InitGui () |
| Call InitGui before any drawing has been made. | |
Engine control routines | |
| bool | Start () |
| Create window and display scene. | |
| bool | Stop () |
| Destroy window. | |
| bool | IsStopped () const |
| bool | Pause () |
| Pause animation. | |
| bool | Resume (bool updateStatus) |
| Resume animation. | |
| bool | LoadLevel (const char *fileName, int level=1) |
| Load level from file. | |
| bool | LoadLevel (int level) |
| Load specified level. | |
| bool | NewGame (int level=1) |
| Load level and reset lives. | |
| void | NextLevel () |
| Increment level. | |
| bool | UnLoad () |
| Unload Level. | |
| bool | Start () |
| Create window and display scene. | |
| bool | Stop () |
| Destroy window. | |
| bool | IsStopped () const |
| bool | Pause () |
| Pause animation. | |
| bool | Resume (bool updateStatus) |
| Resume animation. | |
| bool | LoadLevel (const char *fileName, int level=1) |
| Load level from file. | |
| bool | LoadLevel (int level) |
| Load specified level. | |
| bool | NewGame (int level=1) |
| Load level and reset lives. | |
| void | NextLevel () |
| Increment level. | |
| bool | UnLoad () |
| Unload Level. | |
Viewer Control Routines | |
| void | SetViewer (double x, double y, double z) |
| void | SetViewerLook (double x, double y, double z) |
| void | GetViewer (double *px, double *py, double *pz) const |
| void | GetViewerLook (double *px, double *py, double *pz) const |
| void | SetViewer (double x, double y, double z) |
| void | SetViewerLook (double x, double y, double z) |
| void | GetViewer (double *px, double *py, double *pz) const |
| void | GetViewerLook (double *px, double *py, double *pz) const |
Keyboard and Mouse processing | |
Mouse is not supported yet. | |
| void | KeyPress (int key, KeyEvent type, int x, int y) |
| void | MousePress (int button, int state, int x, int y) |
| void | MouseMove (int x, int y) |
| void | KeyPress (int key, KeyEvent type, int x, int y) |
| void | MousePress (int button, int state, int x, int y) |
| void | MouseMove (int x, int y) |
Getters and Setters | |
| MenuDisplay * | GetMenuDisplay () const |
| TextDisplay * | ActiveDisplay () const |
| TextDisplay * | StatusDisplay () const |
| TextDisplay * | AboutDisplay () const |
| Controller * | BongoMover () const |
| Controller * | GetMenuController () const |
| Controller * | GetViewController () const |
| int | CurrentLevel () const |
| void | SetActiveDisplay (TextDisplay *display) |
| void | SetActiveController (Controller *controller) |
| MenuDisplay * | GetMenuDisplay () const |
| TextDisplay * | ActiveDisplay () const |
| TextDisplay * | StatusDisplay () const |
| TextDisplay * | AboutDisplay () const |
| Controller * | BongoMover () const |
| Controller * | GetMenuController () const |
| Controller * | GetViewController () const |
| int | CurrentLevel () const |
| void | SetActiveDisplay (TextDisplay *display) |
| void | SetActiveController (Controller *controller) |
Private Member Functions | |
| void | UpdateLivesDisplay () |
| bool | Display () |
| void | TimeTick () |
| void | Reshape (int width, int height) |
| void | UpdateLivesDisplay () |
| bool | Display () |
| void | TimeTick () |
| void | Reshape (int width, int height) |
Setup Views | |
| void | TextView () |
| 2D view to display menus | |
| void | QuadView () |
| 3D views for Quads | |
| void | TextView () |
| 2D view to display menus | |
| void | QuadView () |
| 3D views for Quads | |
Private Attributes | |
| pthread_mutex_t | mOperationMutex |
| std::deque< Operation > | mOperations |
| CollisionMaster * | mpCollisionMaster |
| bool | mbDisplayUptodate |
| This flag can be set to invalidate display in GUI thread of execution. | |
| bool | mbStopped |
| This flag can be set to stop GUI thread. | |
| Box * | mpBox |
| XCongo | mXCongo |
| std::list< Quad * > | mQuads |
| std::list< EventListener * > | mEventListeners |
Display Variables | |
These variables are usefull to set the scene | |
| double | mBoxPos [3] |
| double | mBoxDim [3] |
| double | mViewPos [3] |
| double | mViewCenter [3] |
| double | mViewUp [3] |
| int | mWindowWidth |
| Initial Window Settings. | |
| int | mWindowHeight |
| int | mScreenWidth |
| Actual Screen Dimensions. | |
| int | mScreenHeight |
2D Display screens | |
| TextDisplay * | mpActiveDisplay |
| Pointer to central display. It can point to Menu, About or Status Display. | |
| TimeDisplay * | mpStatusDisplay |
| Status message is displayed in center of the screen. | |
| MenuDisplay * | mpMenuDisplay |
| when active displayed in center | |
| TextDisplay * | mpAboutDisplay |
| when active displayed in center | |
| TextDisplay * | mpFpsDisplay |
| displayed in down right corner | |
| int | mbFpsDisplay |
| whether fps display is enabled | |
| TextDisplay * | mpLevelDisplay |
| displayed in down left corner | |
| TextDisplay * | mpLivesDisplay |
| displayed bellow level display | |
Game specific settings | |
| double | mWindowColor [3] |
| general window background color | |
| double | mLevelBackground [3] |
| current level background color | |
| int | mLevels |
| total number of levels | |
| int | mCurrentLevel |
| int | mLives |
| number of lives left for Bongo | |
| int | mToKill |
| number of balls left in this level | |
| char * | mpLevelName |
General Configuraiton | |
| bool | mbDisplayProcessing |
| Wheter display calculation is in processing. If this is true engine will ignore post redisplay. | |
| int | mbAnimeEnabled |
| whether animation is currently running | |
| double | mGravitation [3] |
| Gravitaiton vector. | |
| int | mTimerDelay |
| deley between two timer ticks | |
| unsigned long | mLastUpdateTime |
| used to calculate FPS | |
| int | mbLocalViewer |
| Whether to use GL_LIGHT_MODEL_LOCAL_VIEWER or not. | |
Friends | |
| class | CollisionMaster |
| void | display (void) |
| void | timer_func (int data) |
| void | reshape (int, int) |
| void | idle_func (void) |
| void | display (void) |
| void | timer_func (int data) |
| void | reshape (int, int) |
| void | idle_func (void) |
Controlers | |
All events will be first forwaded to default controler and then active controller. | |
| Controller * | mpDefaultController |
| Controller * | mpActiveController |
| Controller * | mpBongoMover |
| Control Bongo. | |
| Controller * | mpViewController |
| Control Camera. | |
| Controller * | mpMenuController |
| Control Menus. | |
| ViewBongoFollower * | mpViewBongoFollower |
| View is following Bongo. | |
| class | BongoOrthoMover |
| class | BongoRealMover |
| class | ViewBongoFollower |
| enum Engine::KeyEvent |
Keyboard event.
There are two function callbacks in opengl for keyboard events, but only one in Engine. This enum will be used to overcome the difference.
Definition at line 85 of file Engine.h.
{
KEY_DOWN_EX = 1,
KEY_UP_EX
};
| enum Engine::KeyEvent |
Keyboard event.
There are two function callbacks in opengl for keyboard events, but only one in Engine. This enum will be used to overcome the difference.
Definition at line 85 of file Engine.h.
{
KEY_DOWN_EX = 1,
KEY_UP_EX
};
| Engine::Engine | ( | ) |
Definition at line 120 of file Engine.cpp.
References APP_TITLE.
{
pthread_mutex_init(&mOperationMutex, NULL);
//level settings
mpLevelName = 0;
mpViewBongoFollower = 0;
mpCollisionMaster = new CollisionMaster(this);
mbStopped = true;
mbDisplayProcessing = false;
mpBongoMover = 0;
mpBox = 0;
mpAboutDisplay = new StrokeDisplay(30, 3, 3, true, false);
mpAboutDisplay->Print(APP_TITLE "\n");
mpAboutDisplay->Print("Author: Stefan Tarana\n");
mpAboutDisplay->Print("Index: MR98165");
mpFpsDisplay = 0;
mpStatusDisplay = new TimeDisplay(20, 1, 4, true, 4);
mpMenuDisplay = new MenuDisplay(20, 4, 5);
mpMenuDisplay->Add("New Game", new NewGameAction(this) );
mpMenuDisplay->Add("View Prompt ", new ViewPromptAction(this) );
mpMenuDisplay->Add("About", new AboutAction(this) );
mpMenuDisplay->Add("Exit", new ExitAction(this) );
mpLevelDisplay = new StrokeDisplay(4, 1, 3, true, false);
mpLevelDisplay->Print("\nL:01");
mpLivesDisplay = new StrokeDisplay(4, 1, 3, true, false);
mpActiveDisplay = mpMenuDisplay;
mpDefaultController = new ShortcutController(this);
mpMenuController = new MenuController(mpMenuDisplay);
mpActiveController = mpMenuController;
}
| Engine::~Engine | ( | ) |
Definition at line 159 of file Engine.cpp.
{
UnLoad();
delete mpFpsDisplay;
delete mpViewBongoFollower;
delete mpCollisionMaster;
delete mpDefaultController;
delete mpMenuController;
delete mpStatusDisplay;
delete mpMenuDisplay;
}
| Engine::Engine | ( | ) |
| Engine::~Engine | ( | ) |
| TextDisplay * Engine::AboutDisplay | ( | ) | const |
Definition at line 479 of file Engine.cpp.
{
return mpAboutDisplay;
}
| TextDisplay* Engine::AboutDisplay | ( | ) | const |
| TextDisplay* Engine::ActiveDisplay | ( | ) | const |
| TextDisplay * Engine::ActiveDisplay | ( | ) | const |
Definition at line 469 of file Engine.cpp.
Referenced by ShortcutController::ProcessKey().
{
return mpActiveDisplay;
}
| void Engine::AddEventListener | ( | EventListener * | el | ) |
add el to even listener's list
| Controller* Engine::BongoMover | ( | ) | const |
| Controller * Engine::BongoMover | ( | ) | const |
Definition at line 494 of file Engine.cpp.
Referenced by ShortcutController::ProcessKey().
{
return mpBongoMover;
}
| int Engine::CurrentLevel | ( | ) | const |
| int Engine::CurrentLevel | ( | ) | const |
Definition at line 509 of file Engine.cpp.
Referenced by ShortcutController::ProcessKey().
{
return mCurrentLevel;
}
| bool Engine::Display | ( | ) | [private] |
Setup 2D View
Definition at line 321 of file Engine.cpp.
Referenced by display().
{
assert(!mbDisplayProcessing);
// Setup 3D View
QuadView();
// Display Quads - 3D objects relative to the Box position
glPushMatrix();
glTranslatef(mBoxPos[0], mBoxPos[1], mBoxPos[2]);
mbDisplayUptodate = true;
glPopMatrix();
list<Quad*>::reverse_iterator i;
for (i = mQuads.rbegin(); i != mQuads.rend(); i++)
(*i)->Display();
TextView();
// Dipslay 2d Menus
glPushMatrix();
if (mpStatusDisplay == mpActiveDisplay && !mpStatusDisplay->IsExpired()
|| mpMenuDisplay == mpActiveDisplay
|| mpAboutDisplay == mpActiveDisplay)
{
glTranslatef(20.0, 70.0, 0.0);
mpActiveDisplay->Display();
}
glPopMatrix();
// Display Level Info
glPushMatrix();
glTranslatef(10.0, 10.0, 0.0);
mpLevelDisplay->Display();
glPopMatrix();
// Display Lives Info
glPushMatrix();
glTranslatef(10.0, 5.0, 0.0);
mpLivesDisplay->Display();
glPopMatrix();
// Display FPS
if (mpFpsDisplay)
{
glPushMatrix();
glTranslatef(75.0, 10.0, 0.0);
mpFpsDisplay->Display();
glPopMatrix();
}
glDepthMask(GL_TRUE);
mbDisplayUptodate = true;
return true;
}
| bool Engine::Display | ( | ) | [private] |
| Controller* Engine::GetMenuController | ( | ) | const |
| Controller * Engine::GetMenuController | ( | ) | const |
Definition at line 499 of file Engine.cpp.
Referenced by ShortcutController::ProcessKey().
{
return mpMenuController;
}
| MenuDisplay* Engine::GetMenuDisplay | ( | ) | const |
| MenuDisplay * Engine::GetMenuDisplay | ( | ) | const |
Definition at line 464 of file Engine.cpp.
Referenced by ShortcutController::ProcessKey().
{
return mpMenuDisplay;
}
| Controller* Engine::GetViewController | ( | ) | const |
| Controller * Engine::GetViewController | ( | ) | const |
Definition at line 504 of file Engine.cpp.
{
return mpViewController;
}
| void Engine::GetViewer | ( | double * | px, |
| double * | py, | ||
| double * | pz | ||
| ) | const |
Definition at line 300 of file Engine.cpp.
Referenced by BongoRealMover::BongoRealMover(), l_engine_getviewer(), BongoOrthoMover::ProcessKey(), and ViewController::ProcessKey().
| void Engine::GetViewer | ( | double * | px, |
| double * | py, | ||
| double * | pz | ||
| ) | const |
| void Engine::GetViewerLook | ( | double * | px, |
| double * | py, | ||
| double * | pz | ||
| ) | const |
Definition at line 307 of file Engine.cpp.
{
*px = mViewCenter[0];
*py = mViewCenter[0];
*pz = mViewCenter[0];
}
| void Engine::GetViewerLook | ( | double * | px, |
| double * | py, | ||
| double * | pz | ||
| ) | const |
| bool Engine::InitConfig | ( | ) |
Call InitConfig first!
Definition at line 172 of file Engine.cpp.
References LOGE.
Referenced by run_initconfig().
| bool Engine::InitConfig | ( | ) |
Call InitConfig first!
| bool Engine::InitGui | ( | ) |
Call InitGui before any drawing has been made.
| bool Engine::InitGui | ( | ) |
Call InitGui before any drawing has been made.
Definition at line 668 of file Engine.cpp.
Referenced by run_initgui().
{
char *argv[] = { (char*) "QuadPang", 0 };
int argc = 1;
glutInit(&argc, argv);
return true;
}
| bool Engine::IsStopped | ( | ) | const |
| bool Engine::IsStopped | ( | ) | const |
| void Engine::KeyPress | ( | int | key, |
| KeyEvent | type, | ||
| int | x, | ||
| int | y | ||
| ) |
Definition at line 561 of file Engine.cpp.
Referenced by keyboard_func(), keyboard_spec(), keyboardup_func(), and keyboardup_spec().
{
if (!mpDefaultController->ProcessKey(key, type, x, y) )
{
if (mpActiveController)
mpActiveController->ProcessKey(key, type, x, y);
}
}
| void Engine::KeyPress | ( | int | key, |
| KeyEvent | type, | ||
| int | x, | ||
| int | y | ||
| ) |
| bool Engine::LoadConfig | ( | const char * | configName | ) |
You can call LoadConfig multiple times after InitConfig.
Definition at line 184 of file Engine.cpp.
References APP_NAME, and LOGE.
Referenced by run_loadconfig().
{
if (!mXCongo.Load(configName, APP_NAME) )
return false;
if (!mXCongo.IntValue("Settings.mLevels", &mLevels) )
{
LOGE("Failed to read number of levels");
return false;
}
if (!mXCongo.DoubleValue("View.mPos.mX", &mViewPos[0]) ||
!mXCongo.DoubleValue("View.mPos.mY", &mViewPos[1]) ||
!mXCongo.DoubleValue("View.mPos.mZ", &mViewPos[2]) ||
!mXCongo.DoubleValue("View.mCenter.mX", &mViewCenter[0]) ||
!mXCongo.DoubleValue("View.mCenter.mY", &mViewCenter[1]) ||
!mXCongo.DoubleValue("View.mCenter.mZ", &mViewCenter[2]) ||
!mXCongo.DoubleValue("View.mUp.mX", &mViewUp[0]) ||
!mXCongo.DoubleValue("View.mUp.mY", &mViewUp[1]) ||
!mXCongo.DoubleValue("View.mUp.mZ", &mViewUp[2]) ||
!mXCongo.IntValue("View.mLocalViewer", &mbLocalViewer) )
{
LOGE("reading View coordinages");
return false;
}
XRes resource(&mXCongo, "ViewPrompt");
mpViewController = new ViewController(this);
if (!mpViewController->Init(&resource, &mXCongo) )
{
LOGE("reading ViewCotroler");
return false;
}
if (!mXCongo.IntValue("Window.mSize.mWidth", &mWindowWidth) ||
!mXCongo.IntValue("Window.mSize.mWidth", &mWindowHeight) ||
!mXCongo.DoubleValue("Window.mColor.red", &mWindowColor[0]) ||
!mXCongo.DoubleValue("Window.mColor.green", &mWindowColor[1]) ||
!mXCongo.DoubleValue("Window.mColor.blue", &mWindowColor[2]) )
{
LOGE("reading Window coordinages");
return false;
}
if (!mXCongo.IntValue("Anime.mFramePerSecond", &mTimerDelay) ||
!mXCongo.IntValue("Anime.mEnabled", &mbAnimeEnabled) ||
!mXCongo.DoubleValue("Anime.mGravitation", &mGravitation[1]) ||
!mXCongo.IntValue("Anime.mFpsDisplay", &mbFpsDisplay))
{
LOGE("reading animation configuration");
return false;
}
if (mbFpsDisplay)
{
mpFpsDisplay = new StrokeDisplay(7, 1, 3, true, false);
mpFpsDisplay->Print("\nfps");
}
mTimerDelay = 1000 / mTimerDelay;
mGravitation[0] = 0.0;
mGravitation[2] = 0.0;
mGravitation[1] = -mGravitation[1];
mpStatusDisplay->Print("\nConfig loaded");
mpStatusDisplay->Reset();
return true;
}
| bool Engine::LoadConfig | ( | const char * | configName | ) |
You can call LoadConfig multiple times after InitConfig.
| bool Engine::LoadLevel | ( | const char * | fileName, |
| int | level = 1 |
||
| ) |
Load level from file.
Definition at line 803 of file Engine.cpp.
References APP_NAME, Quad::ClassName(), Factory::CreateQuad(), Factory::CreateQuadMover(), and LOGE.
Referenced by ShortcutController::ProcessKey(), and run_loadlevel().
{
if (!mXCongo.Load(level_file, APP_NAME))
{
LOGE("XCongo::Load(\"%s\")", level_file);
return false;
}
Pause();
UnLoad();
if (!mXCongo.StringValue("LevelSettings.mLevelName", &mpLevelName) )
{
LOGE("failed to read level name");
return false;
}
if (!mXCongo.DoubleValue("LevelSettings.mBackground.red", &mLevelBackground[0])
|| !mXCongo.DoubleValue("LevelSettings.mBackground.green", &mLevelBackground[1])
|| !mXCongo.DoubleValue("LevelSettings.mBackground.blue", &mLevelBackground[2]) )
{
LOGE("reading background color");
return false;
}
glClearColor(mLevelBackground[0], mLevelBackground[1], mLevelBackground[2], 0.0);
if (!mXCongo.DoubleValue("Box.mDim.mXWidth", &mBoxDim[0])
|| !mXCongo.DoubleValue("Box.mDim.mYWidth", &mBoxDim[1])
|| !mXCongo.DoubleValue("Box.mDim.mZWidth", &mBoxDim[2]) )
{
LOGE("reading Box dimenstions");
return false;
}
mBoxPos[0] = 0;
mBoxPos[1] = 0;
mBoxPos[2] = 0;
size_t n_quads;
if (!mXCongo.SizeOf("Quads", &n_quads) )
{
LOGE("XCongo::SizeOf(\"Quads\")");
return false;
}
Quad *quad;
Factory qufac;
mToKill = 0;
for (size_t id = 1; id <= n_quads; id ++)
{
XRes resource(&mXCongo, "Quads", (int)id);
if (!(quad = qufac.CreateQuad(&resource, &mXCongo) ) )
{
LOGE("QuadResourceFactory::Create()");
return false;
}
if (0 == strcmp(quad->ClassName(), "Bongo") )
{
((Bongo*)quad)->SetLives(mLives);
if (mpBongoMover)
{
LOGE("Bongo alread defined for this level");
return false;
}
else
{
XRes res2(&resource, "mQuadMover");
mpViewBongoFollower = new ViewBongoFollower(this, (Bongo*)quad);
mpBongoMover = qufac.CreateQuadMover(&res2, &mXCongo, this, quad);
}
}
if (0 == strcmp(quad->ClassName(), "Box") )
{
mpBox = (Box*)quad;
SetViewer(mViewPos[0], mViewPos[1], mViewPos[2]);
mQuads.push_front(quad);
}
else
{
mQuads.push_back(quad);
}
if (0 == strcmp(quad->ClassName(), "Ball") )
{
mToKill++;
}
}
// mpSampleDisplay->Print("A SPARE SERAPE APPEARS AS");
mCurrentLevel = level;
mpActiveDisplay = mpStatusDisplay;
mpActiveController = mpBongoMover;
Resume(false);
mpStatusDisplay->Clear();
mpStatusDisplay->Print("\n ");
mpStatusDisplay->Print(mpLevelName);
mpStatusDisplay->SetLongLife(false);
// this is lifetime object, we will reset it's timeout value
mpStatusDisplay->Reset();
mpLevelDisplay->Clear();
char buf[10];
sprintf(buf, "L:%.2d", mCurrentLevel);
mpLevelDisplay->Print(buf);
UpdateLivesDisplay();
return true;
}
| bool Engine::LoadLevel | ( | const char * | fileName, |
| int | level = 1 |
||
| ) |
Load level from file.
| bool Engine::LoadLevel | ( | int | level | ) |
Load specified level.
Definition at line 792 of file Engine.cpp.
References LEVEL_FORMAT.
{
bool ret_val = true;
char* level_file = new char[strlen(LEVEL_FORMAT) + 10];
sprintf(level_file, LEVEL_FORMAT, level);
ret_val = LoadLevel(level_file, level);
delete level_file;
return ret_val;
}
| bool Engine::LoadLevel | ( | int | level | ) |
Load specified level.
| void Engine::MouseMove | ( | int | x, |
| int | y | ||
| ) |
Definition at line 572 of file Engine.cpp.
Referenced by mouse_passive_motion_func().
{
if (!mpDefaultController->ProcessMouseMove(x, y) )
{
if (mpActiveController)
mpActiveController->ProcessMouseMove(x, y);
}
}
| void Engine::MouseMove | ( | int | x, |
| int | y | ||
| ) |
| void Engine::MousePress | ( | int | button, |
| int | state, | ||
| int | x, | ||
| int | y | ||
| ) |
Definition at line 581 of file Engine.cpp.
Referenced by mouse_press_func().
{
if (!mpDefaultController->ProcessMousePress(button, state, x, y) )
{
if (mpActiveController)
mpActiveController->ProcessMousePress(button, state, x, y);
}
}
| void Engine::MousePress | ( | int | button, |
| int | state, | ||
| int | x, | ||
| int | y | ||
| ) |
| bool Engine::NewGame | ( | int | level = 1 | ) |
Load level and reset lives.
Definition at line 785 of file Engine.cpp.
| bool Engine::NewGame | ( | int | level = 1 | ) |
Load level and reset lives.
| void Engine::NextLevel | ( | ) |
Increment level.
Definition at line 253 of file Engine.cpp.
Referenced by ShortcutController::ProcessKey(), and CollisionMaster::UpdateCollisions().
{
if (mCurrentLevel == mLevels)
{
mpStatusDisplay->Clear();
mpStatusDisplay->Print("Congratulations");
mpStatusDisplay->SetLongLife(true);
}
else
LoadLevel(mCurrentLevel+1);
}
| void Engine::NextLevel | ( | ) |
Increment level.
| bool Engine::Pause | ( | ) |
Pause animation.
| bool Engine::Pause | ( | ) |
Pause animation.
Definition at line 759 of file Engine.cpp.
Referenced by l_engine_pause(), and ShortcutController::ProcessKey().
{
if (!mbAnimeEnabled)
return false;
mpStatusDisplay->Print("\nPause");
mpStatusDisplay->Reset();
mpStatusDisplay->SetLongLife(true);
mbAnimeEnabled = false;
return true;
}
| void Engine::PostOperation | ( | const Operation & | operation | ) |
Definition at line 677 of file Engine.cpp.
Referenced by post_operation().
{
pthread_mutex_lock(&mOperationMutex);
mOperations.push_back(operation);
pthread_mutex_unlock(&mOperationMutex);
}
| void Engine::PostOperation | ( | const Operation & | operation | ) |
| void Engine::QuadView | ( | ) | [private] |
3D views for Quads
Definition at line 399 of file Engine.cpp.
{
glViewport (0, 0, (GLsizei) mScreenWidth, (GLsizei) mScreenHeight);
glEnable(GL_LIGHTING);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(45.0, (GLfloat) mScreenWidth/(GLfloat) mScreenHeight, 5.0, 45.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDepthMask(GL_TRUE);
glRotatef(15, -1.0, 0.0, 0.0);
gluLookAt(mViewPos[0], mViewPos[1], mViewPos[2],
mViewCenter[0], mViewCenter[1], mViewCenter[2],
mViewUp[0], mViewUp[1], mViewUp[2]);
GLfloat light_position[] = { -1.0, 1.0, 0.0, 0.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
}
| void Engine::QuadView | ( | ) | [private] |
3D views for Quads
| void Engine::RemoveEventListener | ( | EventListener * | el | ) |
remove el from event listeners list
| void Engine::Reshape | ( | int | width, |
| int | height | ||
| ) | [private] |
Definition at line 427 of file Engine.cpp.
Referenced by reshape().
{
mScreenWidth = w;
mScreenHeight = h;
}
| void Engine::Reshape | ( | int | width, |
| int | height | ||
| ) | [private] |
| bool Engine::Resume | ( | bool | updateStatus | ) |
Resume animation.
| updateStatus | if set it will update and show status screen as well |
Definition at line 771 of file Engine.cpp.
Referenced by l_engine_resume(), and ShortcutController::ProcessKey().
{
if (mbAnimeEnabled)
return true;
mbAnimeEnabled = true;
if (updateStatus)
{
mpStatusDisplay->Print("\nResume");
mpStatusDisplay->SetLongLife(false);
}
return true;
}
| bool Engine::Resume | ( | bool | updateStatus | ) |
Resume animation.
| updateStatus | if set it will update and show status screen as well |
| void Engine::SendEvent | ( | EventListener::EventType | evt | ) |
send event to all listeners
| void Engine::SetActiveController | ( | Controller * | controller | ) |
Definition at line 489 of file Engine.cpp.
Referenced by ShortcutController::ProcessKey().
{
mpActiveController = controller;
}
| void Engine::SetActiveController | ( | Controller * | controller | ) |
| void Engine::SetActiveDisplay | ( | TextDisplay * | display | ) |
Definition at line 484 of file Engine.cpp.
References display().
Referenced by ShortcutController::ProcessKey().
{
mpActiveDisplay = display;
}
| void Engine::SetActiveDisplay | ( | TextDisplay * | display | ) |
| void Engine::SetViewer | ( | double | x, |
| double | y, | ||
| double | z | ||
| ) |
| void Engine::SetViewer | ( | double | x, |
| double | y, | ||
| double | z | ||
| ) |
Definition at line 265 of file Engine.cpp.
References Box::WALL1, Box::WALL2, Box::WALL3, Box::WALL4, x, y, and z.
Referenced by l_engine_setviewer(), and ViewController::ProcessKey().
{
mViewPos[0] = x;
mViewPos[1] = y;
mViewPos[2] = z;
if (!mpBox)
return;
double m_k = mBoxDim[2] / mBoxDim[0];
double m_lz = mBoxDim[2];
double
t1 = m_k * x + z - m_lz,
t2 = -m_k * x + z;
if (t1 >=0 && t2 >= 0)
mpBox->HideWall(Box::WALL1);
else if (t1 >=0)
mpBox->HideWall(Box::WALL2);
else if (t2 >=0)
mpBox->HideWall(Box::WALL3);
else
mpBox->HideWall(Box::WALL4);
mbDisplayUptodate = false;
}
| void Engine::SetViewerLook | ( | double | x, |
| double | y, | ||
| double | z | ||
| ) |
| void Engine::SetViewerLook | ( | double | x, |
| double | y, | ||
| double | z | ||
| ) |
Definition at line 292 of file Engine.cpp.
{
mViewCenter[0] = x;
mViewCenter[1] = y;
mViewCenter[2] = z;
}
| bool Engine::Start | ( | ) |
Create window and display scene.
| bool Engine::Start | ( | ) |
Create window and display scene.
Definition at line 689 of file Engine.cpp.
References APP_TITLE, display(), idle_func(), keyboard_func(), keyboard_spec(), keyboardup_func(), keyboardup_spec(), reshape(), and timer_func().
Referenced by run_engine().
{
glutInitDisplayMode (GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (mWindowWidth, mWindowHeight);
glutInitWindowPosition (100, 100);
glutCreateWindow(APP_TITLE);
// Uncoment to see the fog
/*glEnable(GL_FOG);
{
GLfloat fogColor[4] = {0.5, 0.5, 0.5, 1.0};
glFogi (GL_FOG_MODE, GL_EXP2);
glFogfv (GL_FOG_COLOR, fogColor);
glFogf (GL_FOG_DENSITY, 0.05);
glHint (GL_FOG_HINT, GL_DONT_CARE);
glFogf (GL_FOG_START, 5.0);
glFogf (GL_FOG_END, 20.0);
}
*/
glClearColor(mWindowColor[0], mWindowColor[1], mWindowColor[2], 0.0);
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
GLfloat white_light[] = { 1.0, 1.0, 1.0, 1.0 };
glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);
GLfloat lmodel_ambient[] = { 0.6f, 0.6f, 0.6f, 1.0f };
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
if (mbLocalViewer)
{
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
}
glEnable(GL_DEPTH_TEST);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard_func);
glutKeyboardUpFunc(keyboardup_func);
// This feature is not ready yet. Use Keyboard only.
// glutMouseFunc(mouse_press_func);
// glutPassiveMotionFunc(mouse_passive_motion_func);
// glutMotionFunc(mouse_passive_motion_func);
glutSpecialFunc(keyboard_spec);
glutSpecialUpFunc(keyboardup_spec);
glutIgnoreKeyRepeat(GLUT_KEY_REPEAT_ON);
glutTimerFunc(mTimerDelay, timer_func, 0);
glutIdleFunc(idle_func);
mbStopped = false;
glutMainLoop();
return true;
}
| TextDisplay* Engine::StatusDisplay | ( | ) | const |
| TextDisplay * Engine::StatusDisplay | ( | ) | const |
Definition at line 474 of file Engine.cpp.
Referenced by ShortcutController::ProcessKey().
{
return mpStatusDisplay;
}
| bool Engine::Stop | ( | ) |
| bool Engine::Stop | ( | ) |
Destroy window.
| void Engine::TextView | ( | ) | [private] |
2D view to display menus
| void Engine::TextView | ( | ) | [private] |
2D view to display menus
Definition at line 378 of file Engine.cpp.
References MIN.
{
GLfloat dim = MIN(mScreenWidth, mScreenHeight);
GLfloat delta = mScreenWidth - mScreenHeight;
if (delta > 0)
glViewport(delta/2, 0.0, dim, dim);
else
glViewport(0.0, delta/2, dim, dim);
glDisable(GL_LIGHTING);
glDepthMask(GL_FALSE);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 100, 0.0, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
| void Engine::TimeTick | ( | ) | [private] |
Definition at line 595 of file Engine.cpp.
References EventListener::EV_TICK, LOGW, and timer_func().
Referenced by timer_func().
{
static int br = 0;
SendEvent(EventListener::EV_TICK);
glutTimerFunc(mTimerDelay, timer_func, 0);
if (!mbAnimeEnabled)
return;
if (mbDisplayProcessing)
LOGW("display processing");
mbDisplayProcessing = true;
mpCollisionMaster->UpdateCollisions();
// move viewer
if (mpViewBongoFollower)
mpViewBongoFollower->Move();
#if defined(CODE_LINUX) || defined(CODE_MAC)
static timeval tv;
gettimeofday(&tv, 0);
unsigned long new_time = tv.tv_sec * 1000000 + tv.tv_usec;
new_time *= 10;
#endif
#ifdef CODE_WINDOWS
// updating fps display
FILETIME currtime_file;
SYSTEMTIME currtime_sys;
GetSystemTime(&currtime_sys);
if (!SystemTimeToFileTime(&currtime_sys, &currtime_file) )
return;
unsigned long new_time = currtime_file.dwLowDateTime;
#endif
unsigned long time_dif = new_time - mLastUpdateTime;
int fps = -1;
if (time_dif)
fps = 10000000 / time_dif;
static unsigned long time_ruff = 0;
time_ruff += time_dif;
if (time_ruff > 5000000)
{
time_ruff = 0;
char buf[50];
sprintf(buf, "\n%d fps", fps);
if (mpFpsDisplay)
mpFpsDisplay->Print(buf);
}
mLastUpdateTime = new_time;
glutPostRedisplay();
mbDisplayProcessing = false;
}
| void Engine::TimeTick | ( | ) | [private] |
| bool Engine::UnLoad | ( | ) |
Unload Level.
| bool Engine::UnLoad | ( | ) |
Unload Level.
Definition at line 927 of file Engine.cpp.
Referenced by l_engine_unloadlevel().
{
list<Quad*>::iterator i;
for (i = mQuads.begin(); i != mQuads.end(); i++)
{
delete *i;
}
mQuads.clear();
delete mpBongoMover;
mpBongoMover = 0;
delete mpLevelName;
mpLevelName = 0;
return true;
}
| void Engine::UpdateLivesDisplay | ( | ) | [private] |
| void Engine::UpdateLivesDisplay | ( | ) | [private] |
Definition at line 918 of file Engine.cpp.
Referenced by CollisionMaster::Collision().
{
mpLivesDisplay->Clear();
char buf[10];
sprintf(buf, "^:%.2d", mLives);
mpLivesDisplay->Print(buf);
}
BongoOrthoMover [friend] |
BongoRealMover [friend] |
CollisionMaster [friend] |
| void display | ( | void | ) | [friend] |
Definition at line 314 of file Engine.cpp.
| void display | ( | void | ) | [friend] |
Definition at line 314 of file Engine.cpp.
| void idle_func | ( | void | ) | [friend] |
Definition at line 433 of file Engine.cpp.
{
// execute pending operations
pthread_mutex_lock(&gEngine.mOperationMutex);
while (gEngine.mOperations.size() > 0)
{
Operation oper = gEngine.mOperations.front();
gEngine.mOperations.pop_front();
oper.mfOperation(oper.mpArg);
}
pthread_mutex_unlock(&gEngine.mOperationMutex);
static int i = 0;
if (gEngine.mbStopped)
{
glutIdleFunc(NULL);
// mac will work in main thread
#ifdef CODE_MAC
exit(0);
#else
pthread_exit(0);
#endif
}
if (!gEngine.mbDisplayUptodate)
{
glutPostRedisplay();
}
}
| void idle_func | ( | void | ) | [friend] |
Definition at line 433 of file Engine.cpp.
{
// execute pending operations
pthread_mutex_lock(&gEngine.mOperationMutex);
while (gEngine.mOperations.size() > 0)
{
Operation oper = gEngine.mOperations.front();
gEngine.mOperations.pop_front();
oper.mfOperation(oper.mpArg);
}
pthread_mutex_unlock(&gEngine.mOperationMutex);
static int i = 0;
if (gEngine.mbStopped)
{
glutIdleFunc(NULL);
// mac will work in main thread
#ifdef CODE_MAC
exit(0);
#else
pthread_exit(0);
#endif
}
if (!gEngine.mbDisplayUptodate)
{
glutPostRedisplay();
}
}
| void reshape | ( | int | w, |
| int | h | ||
| ) | [friend] |
Definition at line 422 of file Engine.cpp.
| void reshape | ( | int | w, |
| int | h | ||
| ) | [friend] |
Definition at line 422 of file Engine.cpp.
| void timer_func | ( | int | data | ) | [friend] |
Definition at line 590 of file Engine.cpp.
| void timer_func | ( | int | data | ) | [friend] |
Definition at line 590 of file Engine.cpp.
ViewBongoFollower [friend] |
int Engine::mbAnimeEnabled [private] |
whether animation is currently running
Definition at line 376 of file Engine.h.
Referenced by BongoOrthoMover::ProcessKey().
bool Engine::mbDisplayProcessing [private] |
bool Engine::mbDisplayUptodate [private] |
This flag can be set to invalidate display in GUI thread of execution.
Definition at line 277 of file Engine.h.
Referenced by idle_func().
int Engine::mbFpsDisplay [private] |
int Engine::mbLocalViewer [private] |
double Engine::mBoxDim [private] |
Definition at line 296 of file Engine.h.
Referenced by BongoOrthoMover::BongoOrthoMover().
double Engine::mBoxPos [private] |
bool Engine::mbStopped [private] |
This flag can be set to stop GUI thread.
Definition at line 281 of file Engine.h.
Referenced by idle_func().
int Engine::mCurrentLevel [private] |
std::list< EventListener * > Engine::mEventListeners [private] |
double Engine::mGravitation [private] |
Gravitaiton vector.
Definition at line 378 of file Engine.h.
Referenced by CollisionMaster::UpdateCollisions().
unsigned long Engine::mLastUpdateTime [private] |
double Engine::mLevelBackground [private] |
int Engine::mLevels [private] |
int Engine::mLives [private] |
number of lives left for Bongo
Definition at line 358 of file Engine.h.
Referenced by CollisionMaster::Collision().
pthread_mutex_t Engine::mOperationMutex [private] |
Definition at line 215 of file Engine.h.
Referenced by idle_func().
std::deque< Operation > Engine::mOperations [private] |
Definition at line 216 of file Engine.h.
Referenced by idle_func().
TextDisplay * Engine::mpAboutDisplay [private] |
Controller * Engine::mpActiveController [private] |
TextDisplay * Engine::mpActiveDisplay [private] |
Controller * Engine::mpBongoMover [private] |
Box * Engine::mpBox [private] |
CollisionMaster * Engine::mpCollisionMaster [private] |
Controller * Engine::mpDefaultController [private] |
TextDisplay * Engine::mpFpsDisplay [private] |
TextDisplay * Engine::mpLevelDisplay [private] |
char * Engine::mpLevelName [private] |
TextDisplay * Engine::mpLivesDisplay [private] |
Controller * Engine::mpMenuController [private] |
MenuDisplay * Engine::mpMenuDisplay [private] |
TimeDisplay * Engine::mpStatusDisplay [private] |
Status message is displayed in center of the screen.
When displaying level name Lifetime behaviour is enabled. Otherwise it is disabled.
Definition at line 329 of file Engine.h.
Referenced by CollisionMaster::Collision().
ViewBongoFollower * Engine::mpViewBongoFollower [private] |
Controller * Engine::mpViewController [private] |
std::list< Quad * > Engine::mQuads [private] |
Definition at line 285 of file Engine.h.
Referenced by BongoOrthoMover::ProcessKey(), BongoRealMover::ProcessKey(), and CollisionMaster::UpdateCollisions().
int Engine::mScreenHeight [private] |
int Engine::mScreenWidth [private] |
int Engine::mTimerDelay [private] |
deley between two timer ticks
Definition at line 380 of file Engine.h.
Referenced by CollisionMaster::Collision().
int Engine::mToKill [private] |
number of balls left in this level
Definition at line 360 of file Engine.h.
Referenced by CollisionMaster::Collision(), and CollisionMaster::UpdateCollisions().
double Engine::mViewCenter [private] |
Definition at line 299 of file Engine.h.
Referenced by ViewBongoFollower::QuadEvent(), and ViewBongoFollower::ViewBongoFollower().
double Engine::mViewPos [private] |
Definition at line 298 of file Engine.h.
Referenced by ViewBongoFollower::Move().
double Engine::mViewUp [private] |
double Engine::mWindowColor [private] |
int Engine::mWindowHeight [private] |
int Engine::mWindowWidth [private] |
XCongo Engine::mXCongo [private] |
1.8.0