void GameLoop::Loop() { SDL_Event sdlEvent; // Will hold the next event to be parsed while (m_bRunning) { // Events get called one at a time, so if multiple things happen in one frame, they get parsed individually through 'SDL_PollEvent' // The next event to parse gets stored into 'sdlEvent', and then passed to the 'EventHandler' class which will call it's appropriate function here // 'SDL_PollEvent' returns 0 when there are no more events to parse while (SDL_PollEvent(&sdlEvent)) { // Calls the redefined event function for the EventHandler class // Refer to its header file and cpp for more information on what each inherited function is capable of // and its syntax OnEvent(sdlEvent); } Update(); LateUpdate(); Draw(); Graphics::Flip(); // Required to update the window with all the newly drawn content } }
void InputHandler::OnMouseMove(int _x, int _y) { previousCursorPosition = cursorPosition; cursorPosition = vec2(_x, _y); if (previousCursorPosition.x == 0 && previousCursorPosition.y == 0) { LateUpdate(); } }
void GameLoop::Loop() { while (m_bRunning) { SDL_Event sdlEvent; // Will hold the next event to be parsed while (m_bRunning) { // Events get called one at a time, so if multiple things happen in one frame, they get parsed individually through 'SDL_PollEvent' // The next event to parse gets stored into 'sdlEvent', and then passed to the 'EventHandler' class which will call it's appropriate function here // 'SDL_PollEvent' returns 0 when there are no more events to parse while (SDL_PollEvent(&sdlEvent)) { // Calls the redefined event function for the EventHandler class // Refer to its header file and cpp for more information on what each inherited function is capable of // and its syntax OnEvent(sdlEvent); } float div = 1000; //div of data type float //used for delta time //made by me (Brock Barlow) float ct = clock(); //float data type ct equals clock() //used for delta time //made by me (Brock Barlow) currentTime = (float)ct / div; //currentTime will equal the value of (float)ct divided by div //used for delta time //made by me (Brock Barlow) deltaTime = currentTime - perviousTime; //deltaTime will equal the value of currentTime minus previousTime //used for delta time //made by me (Brock Barlow) perviousTime = currentTime; //previousTime will equal currentTime //used for delta time //made by me (Brock Barlow) Update(); LateUpdate(); Draw(); DrawGraph(); //DrawGraph function used to draw a graph //made by me (Brock Barlow) Graphics::Flip(); // Required to update the window with all the newly drawn content } } }