From 9e4797d2fe599acfbf13ed626df46650a88ef891 Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Tue, 20 Feb 2024 18:33:42 -0500 Subject: Changed loading of the sprite --- screen.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'screen.c') diff --git a/screen.c b/screen.c index b00c97e..b346bc5 100644 --- a/screen.c +++ b/screen.c @@ -6,7 +6,9 @@ SDL_Surface *ballSurface = NULL; SDL_Surface *leftPaddleSurface = NULL; SDL_Surface *rightPaddleSurface = NULL; -static SDL_Surface *LoadSurface( const char * const path ) { +static const char * const SPRITE_PATH = "sprite.bmp"; + +static SDL_Surface *LoadSurface ( const char * const path ) { SDL_Surface *optimizedSurface = NULL; SDL_Surface * loadedSurface = SDL_LoadBMP( path ); if ( loadedSurface == NULL ) { @@ -37,9 +39,9 @@ bool InitScreen ( void ) { SDL_FillRect( gScreenSurface, NULL, SDL_MapRGB( gScreenSurface->format, 0x00, 0x00, 0x00 ) ); - ballSurface = LoadSurface( "ball.bmp" ); - leftPaddleSurface = LoadSurface( "paddle.bmp" ); - rightPaddleSurface = LoadSurface( "paddle.bmp" ); + ballSurface = LoadSurface( SPRITE_PATH ); + leftPaddleSurface = LoadSurface( SPRITE_PATH ); + rightPaddleSurface = LoadSurface( SPRITE_PATH ); return true; } @@ -60,7 +62,7 @@ void Close ( void ) { 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_BlitSurface( surface, NULL, gScreenSurface, &drect ); + 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