From a17dcfdcba9f7da5a91c554eef88cea73d6598b0 Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Sun, 14 Jul 2024 13:04:54 -0400 Subject: Redid the Cmake Config and fell back to C17 --- screen.c | 58 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'screen.c') diff --git a/screen.c b/screen.c index b346bc5..054beb4 100644 --- a/screen.c +++ b/screen.c @@ -8,62 +8,62 @@ SDL_Surface *rightPaddleSurface = NULL; static const char * const SPRITE_PATH = "sprite.bmp"; -static SDL_Surface *LoadSurface ( const char * const path ) { +static SDL_Surface *LoadSurface(const char * const path) { SDL_Surface *optimizedSurface = NULL; - SDL_Surface * loadedSurface = SDL_LoadBMP( path ); - if ( loadedSurface == NULL ) { - printf( "Unable to load image %s! SDL Error: %s\n", path, SDL_GetError() ); + SDL_Surface * loadedSurface = SDL_LoadBMP(path); + if (loadedSurface == NULL) { + printf("Unable to load image %s! SDL Error: %s\n", path, SDL_GetError()); return NULL; } - optimizedSurface = SDL_ConvertSurface( loadedSurface, gScreenSurface->format, 0 ); - if ( optimizedSurface == NULL ) { - printf( "Unable to optimize image %s! SDL Error: %s\n", path, SDL_GetError() ); + optimizedSurface = SDL_ConvertSurface(loadedSurface, gScreenSurface->format, 0); + if (optimizedSurface == NULL) { + printf("Unable to optimize image %s! SDL Error: %s\n", path, SDL_GetError()); return NULL; } - SDL_FreeSurface( loadedSurface ); + SDL_FreeSurface(loadedSurface); return optimizedSurface; } -bool InitScreen ( void ) { - if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { - printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() ); +bool InitScreen(void) { + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + printf("SDL could not initialize! SDL Error: %s\n", SDL_GetError()); return false; } gWindow = SDL_CreateWindow( "Pong", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN ); - if ( gWindow == NULL ) { - printf( "Window could not be created! SDL Error: %s\n", SDL_GetError() ); + if (gWindow == NULL) { + printf("Window could not be created! SDL Error: %s\n", SDL_GetError()); return false; } - gScreenSurface = SDL_GetWindowSurface( gWindow ); + gScreenSurface = SDL_GetWindowSurface(gWindow); - SDL_FillRect( gScreenSurface, NULL, SDL_MapRGB( gScreenSurface->format, 0x00, 0x00, 0x00 ) ); + SDL_FillRect(gScreenSurface, NULL, SDL_MapRGB(gScreenSurface->format, 0x00, 0x00, 0x00)); - ballSurface = LoadSurface( SPRITE_PATH ); - leftPaddleSurface = LoadSurface( SPRITE_PATH ); - rightPaddleSurface = LoadSurface( SPRITE_PATH ); + ballSurface = LoadSurface(SPRITE_PATH); + leftPaddleSurface = LoadSurface(SPRITE_PATH); + rightPaddleSurface = LoadSurface(SPRITE_PATH); return true; } -void Close ( void ) { - SDL_FreeSurface( rightPaddleSurface ); +void Close(void) { + SDL_FreeSurface(rightPaddleSurface); rightPaddleSurface = NULL; - SDL_FreeSurface( leftPaddleSurface ); + SDL_FreeSurface(leftPaddleSurface); leftPaddleSurface = NULL; - SDL_FreeSurface( ballSurface ); + SDL_FreeSurface(ballSurface); ballSurface = NULL; - SDL_FreeSurface( gScreenSurface ); + SDL_FreeSurface(gScreenSurface); gScreenSurface = NULL; - SDL_DestroyWindow( gWindow ); + SDL_DestroyWindow(gWindow); gWindow = NULL; SDL_Quit(); } -void Draw ( const struct moveable_t m, SDL_Surface * const surface ) { - SDL_Rect drect = { m.position.x, m.position.y, m.width, m.height }; - const int status = SDL_BlitScaled( surface, NULL, gScreenSurface, &drect ); - if ( status < 0 ) { - printf( "Error with draw! SDL Error: %s\n", SDL_GetError() ); +void Draw(const struct moveable_t m, SDL_Surface * const surface) { + SDL_Rect drect = {m.position.x, m.position.y, m.width, m.height}; + const int status = SDL_BlitScaled(surface, NULL, gScreenSurface, &drect); + if (status < 0) { + printf("Error with draw! SDL Error: %s\n", SDL_GetError()); } } -- cgit v1.2.3