void addProj(Player pl) { int x = pl.getPosX(); Projectile * tmp = new Projectile(x, SCREEN_HEIGHT - gProjTexture.getHeight()*2); tmp->setTex(&gProjTexture); Projects.push_back(tmp); gameObjects.push_back(tmp); }
bool ifShipHit(int projX, int projY, int shipX, int shipY) { if ( projX >= shipX && (projX < (shipX + (gShipTexture.getWidth()) ) ) && (projY > shipY ) && (projY < (shipY + (gShipTexture.getHeight()) ) ) ) { return true; } else return false; }
bool ifHitPlayer(int playerX, int playerY, int shipProjX, int shipProjY) { //cout << "px " << playerX << "py " << playerY << "sX" << shipProjX << "sY " << shipProjY << endl; if( shipProjX > playerX && shipProjX < playerX + gPlayerTexture.getWidth() && shipProjY > playerY - gPlayerTexture.getHeight() ) { cout << "curna TRUE"; return true; } else { return false; } }
Dot::Dot() { //Initialize the offsets mPosX = 0; mPosY = 0; //Set collision box dimension mCollider.w = gDotTexture.getWidth(); mCollider.h = gDotTexture.getHeight(); //Initialize the velocity mVelX = 0; mVelY = 0; }
int main() { if(!init()) { printf("Failed to initialize!\n"); return -1; } if(!loadMedia()) { printf("Failed to load media!\n"); return -1; } bool quit = false; SDL_Event e; //While application is running while(!quit) { //Handle events on queue while(SDL_PollEvent(&e) != 0) { //User request quit if(e.type == SDL_QUIT) { quit = true; } //Handle window events g_window.handleEvent(e); } //Only draw when not minimized if(!g_window.isMinimized()) { //Clear screen SDL_SetRenderDrawColor(g_renderer, 0xFF, 0xFF, 0xFF, 0xFF); SDL_RenderClear(g_renderer); //Render text textures g_sceneTexture.render((g_window.getWidth() - g_sceneTexture.getWidth()) / 2, (g_window.getHeight() - g_sceneTexture.getHeight()) / 2 ); //Update screen SDL_RenderPresent(g_renderer); } } close(); return 0; }
bool loadMedia() { //Loading success flag bool success = true; //Load foo' texture if( !gFooTexture.loadFromFile( "40_texture_manipulation/foo.png" ) ) { printf( "Failed to load corner texture!\n" ); success = false; } else { //Lock texture if( !gFooTexture.lockTexture() ) { printf( "Unable to lock Foo' texture!\n" ); } //Manual color key else { //Get pixel data Uint32* pixels = (Uint32*)gFooTexture.getPixels(); int pixelCount = ( gFooTexture.getPitch() / 4 ) * gFooTexture.getHeight(); //Map colors Uint32 colorKey = SDL_MapRGB( SDL_GetWindowSurface( gWindow )->format, 0, 0xFF, 0xFF ); Uint32 transparent = SDL_MapRGBA( SDL_GetWindowSurface( gWindow )->format, 0xFF, 0xFF, 0xFF, 0x00 ); //Color key pixels for( int i = 0; i < pixelCount; ++i ) { if( pixels[ i ] == colorKey ) { pixels[ i ] = transparent; } } //Unlock texture gFooTexture.unlockTexture(); } } return success; }
int main( int argc, char* args[] ) { //Start up SDL and create window if( !init() ) { printf( "Failed to initialize!\n" ); } else { //Load media if( !loadMedia() ) { printf( "Failed to load media!\n" ); } else { //Main loop flag bool quit = false; //Event handler SDL_Event e; //Angle of rotation double degrees = 0; //Flip type SDL_RendererFlip flipType = SDL_FLIP_NONE; //While application is running while( !quit ) { //Handle events on queue while( SDL_PollEvent( &e ) != 0 ) { //User requests quit if( e.type == SDL_QUIT ) { quit = true; } else if( e.type == SDL_KEYDOWN ) { switch( e.key.keysym.sym ) { case SDLK_a: degrees -= 60; break; case SDLK_d: degrees += 60; break; case SDLK_q: flipType = SDL_FLIP_HORIZONTAL; break; case SDLK_w: flipType = SDL_FLIP_NONE; break; case SDLK_e: flipType = SDL_FLIP_VERTICAL; break; } } } //Clear screen SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF ); SDL_RenderClear( gRenderer ); //Render arrow gArrowTexture.render( ( SCREEN_WIDTH - gArrowTexture.getWidth() ) / 2, ( SCREEN_HEIGHT - gArrowTexture.getHeight() ) / 2, NULL, degrees, NULL, flipType ); //Update screen SDL_RenderPresent( gRenderer ); } } } //Free resources and close SDL close(); return 0; }
int main( int argc, char* args[] ) { //Start up SDL and create window if( !init() ) { printf( "Failed to initialize!\n" ); } else { //Load media if( !loadMedia() ) { printf( "Failed to load media!\n" ); } else { //Main loop flag bool quit = false; //Event handler SDL_Event e; //Set text color as black SDL_Color textColor = { 0, 0, 0, 255 }; //The application timer LTimer timer; //In memory text stream std::stringstream timeText; //While application is running while( !quit ) { //Handle events on queue while( SDL_PollEvent( &e ) != 0 ) { //User requests quit if( e.type == SDL_QUIT ) { quit = true; } //Reset start time on return keypress else if( e.type == SDL_KEYDOWN ) { //Start/stop if( e.key.keysym.sym == SDLK_s ) { if( timer.isStarted() ) { timer.stop(); } else { timer.start(); } } //Pause/unpause else if( e.key.keysym.sym == SDLK_p ) { if( timer.isPaused() ) { timer.unpause(); } else { timer.pause(); } } } } //Set text to be rendered timeText.str( "" ); timeText << "Seconds since start time " << ( timer.getTicks() / 1000.f ) ; //Render text if( !gTimeTextTexture.loadFromRenderedText( timeText.str().c_str(), textColor ) ) { printf( "Unable to render time texture!\n" ); } //Clear screen SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF ); SDL_RenderClear( gRenderer ); //Render textures gStartPromptTexture.render( ( SCREEN_WIDTH - gStartPromptTexture.getWidth() ) / 2, 0 ); gPausePromptTexture.render( ( SCREEN_WIDTH - gPausePromptTexture.getWidth() ) / 2, gStartPromptTexture.getHeight() ); gTimeTextTexture.render( ( SCREEN_WIDTH - gTimeTextTexture.getWidth() ) / 2, ( SCREEN_HEIGHT - gTimeTextTexture.getHeight() ) / 2 ); //Update screen SDL_RenderPresent( gRenderer ); } } } //Free resources and close SDL close(); return 0; }
int main( int argc, char* args[] ) { //Start up SDL and create window if( !init() ) { printf( "Failed to initialize!\n" ); } else { //Load media if( !loadMedia() ) { printf( "Failed to load media!\n" ); } else { //Main loop flag bool quit = false; //Event handler SDL_Event e; //While application is running while( !quit ) { //Handle events on queue while( SDL_PollEvent( &e ) != 0 ) { //User requests quit if( e.type == SDL_QUIT ) { quit = true; } //Handle window events gWindow.handleEvent( e ); } //Only draw when not minimized if( !gWindow.isMinimized() ) { //Clear screen SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF ); SDL_RenderClear( gRenderer ); //Render text textures gSceneTexture.render( ( gWindow.getWidth() - gSceneTexture.getWidth() ) / 2, ( gWindow.getHeight() - gSceneTexture.getHeight() ) / 2 ); //Update screen SDL_RenderPresent( gRenderer ); } } } } //Free resources and close SDL close(); return 0; }
void LTexture::renderRelToScrnRel2Object(double x, double y, LTexture& obj2, double angle) { render( MidPositionRelative(SCREEN_WIDTH, obj2.getWidth(), getWidth(), x), MidPositionRelative(SCREEN_HEIGHT, obj2.getHeight(), getHeight(), y), angle); }
int main( int argc, char* args[] ) { //Start up SDL and create window if( !init() ) { printf( "Failed to initialize!\n" ); } else { //Load media if( !loadMedia() ) { printf( "Failed to load media!\n" ); } else { //Main loop flag bool quit = false; //Event handler SDL_Event e; //While application is running while( !quit ) { //Handle events on queue while( SDL_PollEvent( &e ) != 0 ) { //User requests quit if( e.type == SDL_QUIT ) { quit = true; } } //Clear screen SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF ); SDL_RenderClear( gRenderer ); //Render current frame gTextTexture.render( ( SCREEN_WIDTH - gTextTexture.getWidth() ) / 2, ( SCREEN_HEIGHT - gTextTexture.getHeight() ) / 2 ); //Update screen SDL_RenderPresent( gRenderer ); } } } //Free resources and close SDL close(); return 0; }
int main( int argc, char* args[] ) { //Start up SDL and create window if( !init() ) { printf( "Failed to initialize!\n" ); } else { //Load media if( !loadMedia() ) { printf( "Failed to load media!\n" ); } else { //Main loop flag bool quit = false; //Event handler SDL_Event e; //Set text color as black SDL_Color textColor = { 0, 0, 0, 255 }; //The frames per second timer LTimer fpsTimer; //In memory text stream std::stringstream timeText; //Start counting frames per second int countedFrames = 0; fpsTimer.start(); //While application is running while( !quit ) { //Handle events on queue while( SDL_PollEvent( &e ) != 0 ) { //User requests quit if( e.type == SDL_QUIT ) { quit = true; } } //Calculate and correct fps float avgFPS = countedFrames / ( fpsTimer.getTicks() / 1000.f ); if( avgFPS > 2000000 ) { avgFPS = 0; } //Set text to be rendered timeText.str( "" ); timeText << "Average Frames Per Second " << avgFPS; //Render text if( !gFPSTextTexture.loadFromRenderedText( timeText.str().c_str(), textColor ) ) { printf( "Unable to render FPS texture!\n" ); } //Clear screen SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF ); SDL_RenderClear( gRenderer ); //Render textures gFPSTextTexture.render( ( SCREEN_WIDTH - gFPSTextTexture.getWidth() ) / 2, ( SCREEN_HEIGHT - gFPSTextTexture.getHeight() ) / 2 ); //Update screen SDL_RenderPresent( gRenderer ); ++countedFrames; } } } //Free resources and close SDL close(); return 0; }
int main( int argc, char* args[] ) { //Start up SDL and create window if( !init() ) { printf( "Failed to initialize!\n" ); } else { //Load media if( !loadMedia() ) { printf( "Failed to load media!\n" ); } else { //Main loop flag bool quit = false; //Event handler SDL_Event e; //Text rendering color SDL_Color textColor = { 0, 0, 0, 0xFF }; SDL_Color highlightColor = { 0xFF, 0, 0, 0xFF }; //Current input point int currentData = 0; //While application is running while( !quit ) { //Handle events on queue while( SDL_PollEvent( &e ) != 0 ) { //User requests quit if( e.type == SDL_QUIT ) { quit = true; } else if( e.type == SDL_KEYDOWN ) { switch( e.key.keysym.sym ) { //Previous data entry case SDLK_UP: //Rerender previous entry input point gDataTextures[ currentData ].loadFromRenderedText( std::to_string( (_Longlong)gData[ currentData ] ), textColor ); --currentData; if( currentData < 0 ) { currentData = TOTAL_DATA - 1; } //Rerender current entry input point gDataTextures[ currentData ].loadFromRenderedText( std::to_string( (_Longlong)gData[ currentData ] ), highlightColor ); break; //Next data entry case SDLK_DOWN: //Rerender previous entry input point gDataTextures[ currentData ].loadFromRenderedText( std::to_string( (_Longlong)gData[ currentData ] ), textColor ); ++currentData; if( currentData == TOTAL_DATA ) { currentData = 0; } //Rerender current entry input point gDataTextures[ currentData ].loadFromRenderedText( std::to_string( (_Longlong)gData[ currentData ] ), highlightColor ); break; //Decrement input point case SDLK_LEFT: --gData[ currentData ]; gDataTextures[ currentData ].loadFromRenderedText( std::to_string( (_Longlong)gData[ currentData ] ), highlightColor ); break; //Increment input point case SDLK_RIGHT: ++gData[ currentData ]; gDataTextures[ currentData ].loadFromRenderedText( std::to_string( (_Longlong)gData[ currentData ] ), highlightColor ); break; } } } //Clear screen SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF ); SDL_RenderClear( gRenderer ); //Render text textures gPromptTextTexture.render( ( SCREEN_WIDTH - gPromptTextTexture.getWidth() ) / 2, 0 ); for( int i = 0; i < TOTAL_DATA; ++i ) { gDataTextures[ i ].render( ( SCREEN_WIDTH - gDataTextures[ i ].getWidth() ) / 2, gPromptTextTexture.getHeight() + gDataTextures[ 0 ].getHeight() * i ); } //Update screen SDL_RenderPresent( gRenderer ); } } } //Free resources and close SDL close(); return 0; }
void loop () { //Handle events on queue while( SDL_PollEvent( &e ) != 0 ) { //User requests quit if( e.type == SDL_QUIT ) { quit = true; } //Reset start time on return keypress else if( e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_RETURN ) { startTime = SDL_GetTicks(); } } //Set text to be rendered timeText.str( "" ); timeText << "Milliseconds since start time " << SDL_GetTicks() - startTime; //Render text if( !gTimeTextTexture.loadFromRenderedText( timeText.str().c_str(), textColor ) ) { printf( "Unable to render time texture!\n" ); } //Clear screen SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF ); SDL_RenderClear( gRenderer ); //Render textures gPromptTextTexture.render( ( SCREEN_WIDTH - gPromptTextTexture.getWidth() ) / 2, 0 ); gTimeTextTexture.render( ( SCREEN_WIDTH - gPromptTextTexture.getWidth() ) / 2, ( SCREEN_HEIGHT - gPromptTextTexture.getHeight() ) / 2 ); //Update screen SDL_RenderPresent( gRenderer ); }
void loop () { //Handle events on queue while( SDL_PollEvent( &e ) != 0 ) { //User requests quit if( e.type == SDL_QUIT ) { quit = true; } } //Calculate and correct fps float avgFPS = countedFrames / ( fpsTimer.getTicks() / 1000.f ); if( avgFPS > 2000000 ) { avgFPS = 0; } //Set text to be rendered timeText.str( "" ); timeText << "Average Frames Per Second " << avgFPS; //Render text if( !gFPSTextTexture.loadFromRenderedText( timeText.str().c_str(), textColor ) ) { printf( "Unable to render FPS texture!\n" ); } //Clear screen SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF ); SDL_RenderClear( gRenderer ); //Render textures gFPSTextTexture.render( ( SCREEN_WIDTH - gFPSTextTexture.getWidth() ) / 2, ( SCREEN_HEIGHT - gFPSTextTexture.getHeight() ) / 2 ); //Update screen SDL_RenderPresent( gRenderer ); ++countedFrames; }
int main( int argc, char* args[]) { SDL_Color textColor = { 255, 255, 200, 255 }; // int i = 0; int timer = 0; int direction = 1; // 1 : left moving / 2 : right bool screenHit = false; int PlayerLifes = 3; std::stringstream PlayerLifesText; if( !init() ) { printf( "Failed to initialize!\n" ); } else { if( !loadMedia() ) { printf( "Failed to load media!\n" ); } else { bool quit = false; SDL_Event e; Player player(0, SCREEN_HEIGHT - gPlayerTexture.getHeight()); player.setTex(&gPlayerTexture); gameObjects.push_back(&player); createArmy(100, 50, 0); while( !quit ) { while( SDL_PollEvent( &e ) != 0 ) { if( e.type == SDL_QUIT ) { quit = true; } //if(e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_n) //{ // PlayerLifes = 1; // deleteShips(); // createArmy(100, 50, 0); //} bool shouldShoot = player.handleEvent( e ); if (shouldShoot) addProj(player); } if(PlayerLifes <= 0) { SDL_SetRenderDrawColor( gRenderer, 0x00, 0x00, 0x00, 0x00 ); SDL_RenderClear( gRenderer ); gLoseScreen.render(0, 0, gRenderer); } else { PlayerLifesText.str(""); PlayerLifesText << "Lifes " << PlayerLifes; gPlayerLifesTexture.loadFromRenderedText( PlayerLifesText.str().c_str(), textColor, gRenderer, gFont ); if( timer > 100 ) timer = 0; timer += 1; if( timer % 3 == 0) { if(ifScreenEndHit()) { screenHit = true; direction += 1; } movingShips(direction, screenHit); if(screenHit) screenHit = false; } if( timer % 50 == 0) { shipFire(); } ifProjCollShip(); projCollPlayer(player, PlayerLifes); //cout << PlayerLifes << endl; for(std::list<GameObject*>::iterator it = gameObjects.begin(); it != gameObjects.end();) { if( (*it)->alive == true ) (*it)->update(); ++it; } for(vector<Projectile*>::iterator it = shipProjects.begin(); it != shipProjects.end(); ++it) { if( (*it)->alive == true) (*it)->move(); } // RENDERING SDL_SetRenderDrawColor( gRenderer, 0x00, 0x00, 0x00, 0x00 ); SDL_RenderClear( gRenderer ); for(vector<Projectile*>::iterator it = shipProjects.begin(); it != shipProjects.end(); ++it) { if( (*it)->alive == true) (*it)->render(gRenderer); } for(std::list<GameObject*>::iterator it = gameObjects.begin(); it != gameObjects.end();) { if ((*it)->alive == true ) (*it)->render(gRenderer); ++it; } for(vector<vector<Ships*>>::iterator it = ships.begin(); it != ships.end(); ++it ) { for(vector<Ships*>::iterator itt = (*it).begin(); itt != (*it).end(); ++itt) { if( (*itt)->alive == true ) (*itt)->render(gRenderer); } } } gPlayerLifesTexture.render(5, 5, gRenderer); SDL_RenderPresent( gRenderer ); //deleteDeadShips(); m } } } close(); //system("pause"); return 0; }
int main( int argc, char* args[] ) { //Start up SDL and create window if( !init() ) { printf( "Failed to initialize!\n" ); } else { //Load media if( !loadMedia() ) { printf( "Failed to load media!\n" ); } else { //Main loop flag bool quit = false; //Event handler SDL_Event e; //Set text color as black SDL_Color textColor = { 0, 0, 0, 0xFF }; //The current input text. std::string inputText = "Some Text"; gInputTextTexture.loadFromRenderedText( inputText.c_str(), textColor ); //Enable text input SDL_StartTextInput(); //While application is running while( !quit ) { //The rerender text flag bool renderText = false; //Handle events on queue while( SDL_PollEvent( &e ) != 0 ) { //User requests quit if( e.type == SDL_QUIT ) { quit = true; } //Special key input else if( e.type == SDL_KEYDOWN ) { //Handle backspace if( e.key.keysym.sym == SDLK_BACKSPACE && inputText.length() > 0 ) { //lop off character inputText.pop_back(); renderText = true; } //Handle copy else if( e.key.keysym.sym == SDLK_c && SDL_GetModState() & KMOD_CTRL ) { SDL_SetClipboardText( inputText.c_str() ); } //Handle paste else if( e.key.keysym.sym == SDLK_v && SDL_GetModState() & KMOD_CTRL ) { inputText = SDL_GetClipboardText(); renderText = true; } } //Special text input event else if( e.type == SDL_TEXTINPUT ) { //Not copy or pasting if( !( ( e.text.text[ 0 ] == 'c' || e.text.text[ 0 ] == 'C' ) && ( e.text.text[ 0 ] == 'v' || e.text.text[ 0 ] == 'V' ) && SDL_GetModState() & KMOD_CTRL ) ) { //Append character inputText += e.text.text; renderText = true; } } } //Rerender text if needed if( renderText ) { //Text is not empty if( inputText != "" ) { //Render new text gInputTextTexture.loadFromRenderedText( inputText.c_str(), textColor ); } //Text is empty else { //Render space texture gInputTextTexture.loadFromRenderedText( " ", textColor ); } } //Clear screen SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF ); SDL_RenderClear( gRenderer ); //Render text textures gPromptTextTexture.render( ( SCREEN_WIDTH - gPromptTextTexture.getWidth() ) / 2, 0 ); gInputTextTexture.render( ( SCREEN_WIDTH - gInputTextTexture.getWidth() ) / 2, gPromptTextTexture.getHeight() ); //Update screen SDL_RenderPresent( gRenderer ); } //Disable text input SDL_StopTextInput(); } } //Free resources and close SDL close(); return 0; }
bool loadLetters() { bool success = true; if (!gFontTexture.loadFromFile("font.png")) { printf("Failed to load corner texture!\n"); success = false; } else { if (!gFontTexture.lockTexture()) { printf("Unable to lock font texture!\n"); } else { Uint32* pixels = (Uint32*)gFontTexture.getPixels(); int pixelCount = (gFontTexture.getPitch() / 4) * gFontTexture.getHeight(); int width = gFontTexture.getWidth(); int height = gFontTexture.getHeight(); std::vector<std::vector<Uint32>> pixelGrid; pixelGrid.resize(height, std::vector<Uint32>(width)); Uint32 white = SDL_MapRGB(SDL_GetWindowSurface(gWindow)->format, 255, 255, 255); Uint32 cyan = SDL_MapRGB(SDL_GetWindowSurface(gWindow)->format, 0, 255, 255); int k = 0; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { pixelGrid[i][j] = pixels[k]; k++; } } std::vector<SDL_Rect> boxes; int current = 0; int rightEdge = 0; int leftEdge = 0; int state = 1; int rowCount = height / LINE_HEIGHT; printf("%d\n", rowCount); for (int i = 0; i < rowCount; i++) { for (int j = 0; j < width; j++) { printf("%d %d\n", i, j); int value = hasBlack(pixelGrid, i, j, white, cyan); if (value == 1) { if (state == 1) { leftEdge = j; state = 2; } if (state == 2) { rightEdge = j; } } if (value == 2) { SDL_Rect currentBox; currentBox.x = leftEdge; currentBox.y = i * LINE_HEIGHT; currentBox.w = rightEdge - leftEdge; currentBox.h = LINE_HEIGHT - 1; if (currentBox.w < 10) { currentBox.w = 10; } printf("%d %d %d %d\n", currentBox.x, currentBox.y, currentBox.w, currentBox.h); boxes.push_back(currentBox); state = 1; } } } convert(boxes); gFontTexture.unlockTexture(); } } return success; }
int main(int argc, char *argv[]) { int quit = 0; /* event handler */ SDL_Event event; /* set text color as black */ SDL_Color textColor = { 0, 0, 0, 255 }; /* current time start time */ Uint32 startTime = 0; char timeText[128]; /* starts up SDL and create window */ if (init_sdl() == -1) { fprintf(stderr, "Failed to initialize SDL!\n"); return -1; } /* load media */ if (load_media() == -1) { fprintf(stderr, "Failed to load media!\n"); return -2; } /* main loop */ while (quit == 0) { /* handle events on queue */ while (SDL_PollEvent(&event) != 0) { /* users request quit */ if (event.type == SDL_QUIT) quit = 1; /* reset start time on return key press */ else if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_RETURN) { startTime = SDL_GetTicks(); } } /* set text to be rendered */ snprintf(timeText, sizeof(timeText), "%d", SDL_GetTicks() - startTime); /* render text */ if (gTimeTextTexture.loadFromRenderedText(timeText, textColor) == -1) fprintf(stderr, "Unable to render time texture!\n"); /* clear screen */ SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF); SDL_RenderClear(gRenderer); /* render texture */ gPromptTexture.render((SCREEN_WIDTH - gPromptTexture.getWidth()) / 2, 0); gTimeTextTexture.render((SCREEN_WIDTH - gTimeTextTexture.getWidth()) / 2, (SCREEN_HEIGHT - gTimeTextTexture.getHeight()) / 2); /* update screen */ SDL_RenderPresent(gRenderer); } /* free resources and close */ close_sdl(); return 0; }