Skip to content

Instantly share code, notes, and snippets.

Created April 27, 2012 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2505308 to your computer and use it in GitHub Desktop.
Save anonymous/2505308 to your computer and use it in GitHub Desktop.
gameloop, init and updatex
//game loop
int main()
{
init(); //initalize the window, openGL and variables.
while (App->IsOpened())
{
handleWindowEvents(); //handle key presses and mouse events
draw(); //draw the scene
App->Display(); //display the scene on screen
while (Clock->GetElapsedTime() < 1.0/60.0);
currentTime = Clock->GetElapsedTime();
Clock->Reset();
}
return EXIT_SUCCESS;
}
//initalize the window and openGL
void init()
{
width = 1000;
height = 800;
currentTime = 0;
Clock = new sf::Clock();
App = new sf::RenderWindow(sf::VideoMode(width, height, 32), TITLE);
App->UseVerticalSync(true);
//App->SetFramerateLimit(60);
world = new World(width, height);
initGL(width,height);
}
void Sprite::updateX(float tempX)
{
x += tempX;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment