diff options
| -rw-r--r-- | game.c | 3 | ||||
| -rw-r--r-- | level.c | 34 | ||||
| -rw-r--r-- | main.c | 2 | ||||
| -rw-r--r-- | render.c | 4 | 
4 files changed, 20 insertions, 23 deletions
| @@ -148,11 +148,8 @@ int play_level(SDL_Renderer* renderer, struct level_struct *currentlevel, SDL_Te  			// Show a losing screen if applicable
  			if (player_status == PLAYER_IS_DEAD) render_a_losingscreen(renderer, currentlevel, surf_screen);
  		}
 -
  	}
 -	
 -	
  	// The code running play_level needs to know if too advance to the next level
  	// or just repeat the current one ( if the player has died )
  	return player_status;
 @@ -102,13 +102,23 @@ void eat_until_newline( FILE *currentfile )  void level_load_resources(SDL_Renderer* renderer, struct level_struct *level )
  {
  	// Load the images for things into their own 'surfaces'
 -	level->surf_entities = IMG_Load( "entities.png" );
 +	SDL_Surface* surf_entities = IMG_Load( "entities.png" );
 +	level->surf_entities = SDL_ConvertSurfaceFormat(surf_entities,
 +			SDL_PIXELFORMAT_ARGB8888, 0);
 -  level->surf_tiles = IMG_Load( "tiles.png" );
 +	SDL_Surface* surf_tiles = IMG_Load( "tiles.png" );
 +	level->surf_tiles = SDL_ConvertSurfaceFormat(surf_tiles,
 +			SDL_PIXELFORMAT_ARGB8888, 0);
  	// Do the same for the losing screens
 -  level->surf_losingscreens[0] = IMG_Load("failscreen_01.png");
 -  level->surf_winning_screen = IMG_Load("winningscreen.png");
 +
 +	SDL_Surface* surf_losing = IMG_Load("failscreen_01.png");
 +	level->surf_losingscreens[0] = SDL_ConvertSurfaceFormat(surf_losing,
 +			SDL_PIXELFORMAT_ARGB8888, 0);
 +
 +	SDL_Surface* surf_win = IMG_Load("winningscreen.png");
 +	level->surf_winning_screen = SDL_ConvertSurfaceFormat(surf_win,
 +			SDL_PIXELFORMAT_ARGB8888, 0);
  }
 @@ -149,7 +159,7 @@ void level_load( int level_number, struct level_struct *level )  	/* Ieterate through the file and load the squares into the level's structure
  	 * Each row/line in the file represents a row of squares in the level
  	 * Each square is represented in the rows by a number from 0 to 255
 -     * Open up one of the level files with a text editor to study its structure further
 +	* Open up one of the level files with a text editor to study its structure further
  	 */
  	/* WARNING:  This code assumes the file is structured correctly in the first place!
 @@ -206,8 +216,6 @@ void level_load( int level_number, struct level_struct *level )  }
 -
 -
  // Replace every tile in the level of firsttype with secondtype
  // Useful for eg opening doors
  void level_replace_tiles( struct level_struct *currentlevel, char firsttype, char secondtype )
 @@ -222,15 +230,3 @@ void level_replace_tiles( struct level_struct *currentlevel, char firsttype, cha  		}
  	}
  }
 -
 -
 -
 -
 -
 -
 -
 -
 -
 -
 -
 -
 @@ -76,6 +76,8 @@ int main(int argc, char *argv[])  	if (!surf_title) {
  		error_sdl("could not get title surface\n");
  	}
 +	surf_title = SDL_ConvertSurfaceFormat(surf_title,
 +			SDL_PIXELFORMAT_ARGB8888, 0);
  	SDL_Texture *surf_title_tex = SDL_CreateTextureFromSurface(renderer, surf_title);
  	if (!surf_title_tex) {
 @@ -87,6 +87,8 @@ void render(SDL_Renderer* renderer, struct level_struct *currentlevel, SDL_Textu  			/// Draw this tile onto the screen
  			//SDL_BlitSurface ( currentlevel->surf_tiles, &pixmap_crop, surf_screen, &destination );
 +			// TODO: use pixmap_crop
 +			// printf("surf_tile format: %s\n", SDL_GetPixelFormatName(currentlevel->surf_tiles->format->format));
  			SDL_UpdateTexture(surf_screen, &destination,
  					currentlevel->surf_tiles->pixels,
  					currentlevel->surf_tiles->pitch);
 @@ -122,7 +124,7 @@ void render(SDL_Renderer* renderer, struct level_struct *currentlevel, SDL_Textu  			// Draw it onscreen
  			// SDL_BlitSurface ( currentlevel->surf_entities, &pixmap_crop, surf_screen, &destination );
 -	    SDL_UpdateTexture(surf_screen, &destination,
 +			SDL_UpdateTexture(surf_screen, &destination,
  					currentlevel->surf_entities->pixels,
  					currentlevel->surf_entities->pitch);
  		}
 | 
