e2d::core::Implementation Class Reference

List of all members.


Detailed Description

Any game you create with Easy2D must be contained inside a class, and such class must be a child of Implementation. It provides abstract methods which will be called from inside Easy2D.

The order in which Easy2D calls the methods is the following:

  1. OnInit();
  2. OnRun(); (and keep calling OnRun() until it returns false)
  3. OnQuit();

All other methods are response to events, and are called immediately when a correspondent event happens.

Attention:
It is important to do not call ANY Easy2D or SDL method in the constructor and/or destructor of your class, because SDL_Init() will be called right before the OnInit() method, and SDL_Quit() right after the OnQuit() method.
Note:
Events are processed in parallel with the OnRun() method, what means you can't expect any event handling routine to be called before OnInit() finishes and afer OnQuit() begins execution.

For any event to be processed, you must first initialize the events subsystem. In SDL, this is made in conjunction with the video initialization, what means you won't be able to capture any event before a successful call to Video::Init.


Public Member Functions

virtual void OnInit (Utilities *Utils)=0
 Game initializations.
virtual void OnKeyDown (Utilities *Utils, int key)
 Captures a key press.
virtual void OnKeyUp (Utilities *Utils, int key)
 Captures a key release.
virtual void OnMouseButtonDown (Utilities *Utils, int button)
 Captures a mouse button press.
virtual void OnMouseButtonUp (Utilities *Utils, int button)
 Captures a mouse button release.
virtual void OnMouseMotion (Utilities *Utils)
 Captures a mouse move.
virtual void OnQuit (Utilities *Utils)=0
 Game cleanup.
virtual bool OnRun (Utilities *Utils)=0
 Game loop.

Member Function Documentation

virtual void e2d::core::Implementation::OnInit ( Utilities Utils  )  [pure virtual]

You may want to process all initializations here, such as Video::Init or AudioManager::Init, as well as allocating all of your own objects.

Parameters:
Utils see Utilities

void e2d::core::Implementation::OnKeyDown ( Utilities Utils,
int  key 
) [virtual]

Whenever a key is pressed on the keyboard, this method is called.

Parameters:
Utils see Utilities
key the key being pressed: see SDL documentation for key constants
See also:
Keyboard

void e2d::core::Implementation::OnKeyUp ( Utilities Utils,
int  key 
) [virtual]

Whenever a key is released on the keyboard, this method is called.

Parameters:
Utils see Utilities
key the key being released: see SDL documentation for key constants
See also:
Keyboard

void e2d::core::Implementation::OnMouseButtonDown ( Utilities Utils,
int  button 
) [virtual]

Whenever any button is pressed on the mouse, this method is called.

Note:
The mouse wheel is treated like a button, and it triggers both the OnMouseButtonUp() and OnMouseButtonDown() events at the sime time when activated.
Parameters:
Utils see Utilities
button the mouse button being pressed: see Mouse for button constants.

void e2d::core::Implementation::OnMouseButtonUp ( Utilities Utils,
int  button 
) [virtual]

Whenever any button is released on the mouse, this method is called.

Note:
The mouse wheel is treated like a button, and it triggers both the OnMouseButtonUp() and OnMouseButtonDown() events at the sime time when activated.
Parameters:
Utils see Utilities
button the mouse button being pressed: see Mouse for button constants.

void e2d::core::Implementation::OnMouseMotion ( Utilities Utils  )  [virtual]

Whenever the mouse is moved inside the game window, this method is called.

Parameters:
Utils see Utilities

virtual void e2d::core::Implementation::OnQuit ( Utilities Utils  )  [pure virtual]

You may want to process all cleanups here (such as Video::Quit) as well as deallocating all of your own objects.

Parameters:
Utils see Utilities

virtual bool e2d::core::Implementation::OnRun ( Utilities Utils  )  [pure virtual]

Every game goes on inside a loop, and so Easy2D provides you a loop. This method runs inside a while(true) loop, and this loop is halted only when this method returns false. So, if you want the loop to keep running (i.e., this method being called), always return true.

Parameters:
Utils see Utilities


Generated on Tue Dec 8 10:32:44 2009 for Easy2D by  doxygen 1.5.6