Created
April 27, 2012 02:56
-
-
Save anonymous/2505308 to your computer and use it in GitHub Desktop.
gameloop, init and updatex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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