void Ball::draw() const
{
- glDrawCircle(radius, position, color);
+ graphics::drawCircle(radius, position, color);
}
float Ball::getRadius() const
#include "GameStates/Paused.h"
#include "GameStates/CreatingPolygon.h"
+
/// ***** Private Variables *****
// The stack of active game states
/// ***** Public Methods *****
-void gameInit()
+
+void game::init()
{
running = new Running();
paused = new Paused();
#endif
}
-void gameClean()
+void game::clean()
{
effect::clean();
delete running;
}
-void gameInput()
+void game::input()
{
int last = active_States.size() -1;
for( int i = 0;
}
}
-void gameUpdate(float time_step)
+void game::update(float time_step)
{
int last = active_States.size() -1;
for( int i = 0;
}
}
-void gameDraw()
+void game::draw()
{
int last = active_States.size() -1;
for( int i = 0;
#ifndef GAME_H
#define GAME_H
+
/// ***** Header Methods *****
-void gameInit();
-void gameClean();
-void gameInput();
-void gameUpdate(float);
-void gameDraw();
+namespace game
+{
+ void init();
+ void clean();
+
+ void input();
+ void update(float);
+ void draw();
+}
#endif // GAME_H
#include "../mathw.h"
+
/// ***** Private Method Headers *****
-void drawCircle(int);
+void glDrawCircle(int);
void sdlInit();
void glInit();
/// ***** Initializers/Cleaners *****
-void graphicsInit()
+void graphics::init()
{
sdlInit();
glInit();
}
-void graphicsClean()
+void graphics::clean()
{
}
/// ***** Public Methods *****
-void glDrawCircle(float radius, const Vector2& vec, const float* color)
+void graphics::drawCircle(float radius, const Vector2& vec, const float* color)
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
if(color != NULL)
glColor3fv(color);
- drawCircle(32);
+ glDrawCircle(32);
}
/// ***** Private Methods *****
-void drawCircle(int pieces)
+void glDrawCircle(int pieces)
{
glBegin(GL_POLYGON);
for(int n = 0; n < pieces; n++)
#include "../Vector2.h"
+
/// ***** Header Methods *****
-void graphicsInit();
-void graphicsClean();
+namespace graphics
+{
+ void init();
+ void clean();
-void glDrawCircle(float radius, const Vector2&, const float* color = 0);
+ void drawCircle(float radius, const Vector2&, const float* color = 0);
+}
#endif // GRAPHICS_H
/// ***** Initializers/Cleaners *****
-void inputInit()
+void input::init()
{
for(int i=0; i< keySize; i++)
keyState[i] = isR;
}
-void inputClean()
+void input::clean()
{
}
/// ***** Public Methods *****
-void inputUpdate()
+void input::update()
{
SDL_Event event;
}
}
-bool isPressed(Uint8 key)
+bool input::isPressed(Uint8 key)
{
return keyState[key] == isP || keyState[key] == wasP;
}
-bool isReleased(Uint8 key)
+bool input::isReleased(Uint8 key)
{
return keyState[key] == isR || keyState[key] == wasR;
}
-bool wasPressed(Uint8 key)
+bool input::wasPressed(Uint8 key)
{
return keyState[key] == wasP;
}
-bool wasReleased(Uint8 key)
+bool input::wasReleased(Uint8 key)
{
return keyState[key] == wasR;
}
#include <SDL/SDL.h>
+
/// ***** Header Methods *****
-void inputInit();
-void inputClean();
+namespace input
+{
+ void init();
+ void clean();
-void inputUpdate();
+ void update();
-bool isPressed(Uint8);
-bool isReleased(Uint8);
+ bool isPressed(Uint8);
+ bool isReleased(Uint8);
-bool wasPressed(Uint8);
-bool wasReleased(Uint8);
+ bool wasPressed(Uint8);
+ bool wasReleased(Uint8);
+}
#endif // INPUT_H
void blockUpdate();
void updateFPSCounters();
-void input();
+void handleInput();
void update(float);
void draw();
{
installSignal();
- graphicsInit();
+ graphics::init();
- gameInit();
+ game::init();
- inputInit();
+ input::init();
#ifdef DEBUGGING
cout << "Initialization Complete" << endl;
cout << "Cleaning up" << endl;
#endif
- inputClean();
+ input::clean();
- gameClean();
+ game::clean();
- graphicsClean();
+ graphics::clean();
}
/// ***** Private Methods *****
// run the updates
for (int i = 1; i <= iupdate_sum; i++)
{
- input();
+ handleInput();
update(time_step*i / 1000);
}
// remove the updates that where run from the sum
}
}
-void input()
+void handleInput()
{
- inputUpdate();
+ input::update();
- gameInput();
+ game::input();
- if(wasReleased(SDLK_ESCAPE))
+ if(input::wasReleased(SDLK_ESCAPE))
is_Running = false;
}
{
update_Count++;
- gameUpdate(time_step);
+ game::update(time_step);
}
void draw()
{
draw_Count++;
- gameDraw();
+ game::draw();
SDL_GL_SwapBuffers();