From dc9b56a7650dd65d574c0e33ea7cb9e1612622f7 Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Mon, 7 Jan 2019 21:59:53 +0100 Subject: Start porting code to SDL2 (WIP) --- level.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'level.c') diff --git a/level.c b/level.c index bfa3ec1..0db6d88 100644 --- a/level.c +++ b/level.c @@ -66,14 +66,14 @@ struct level_struct int sx, sy; // Player X and Y starting positions // Resources - SDL_Surface * surf_entities; // Player and echidna pictures - SDL_Surface * surf_tiles; // Level tiles/squares + SDL_Texture * surf_entities; // Player and echidna pictures + SDL_Texture * surf_tiles; // Level tiles/squares // A various selection of losing screens - SDL_Surface * surf_losingscreens[5]; + SDL_Texture * surf_losingscreens[5]; // The screen to display when the game ends - SDL_Surface * surf_winning_screen; + SDL_Texture * surf_winning_screen; // Up to ten echidnas struct echidna echidnas[10]; @@ -99,16 +99,21 @@ void eat_until_newline( FILE *currentfile ) // Load the graphics used in levels -void level_load_resources( struct level_struct *level ) +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" ); - level->surf_tiles = IMG_Load( "tiles.png" ); + SDL_Surface* surf_entities = IMG_Load( "entities.png" ); + level->surf_entities = SDL_CreateTextureFromSurface(renderer, surf_entities); + + SDL_Surface* surf_tiles = IMG_Load( "tiles.png" ); + level->surf_tiles = SDL_CreateTextureFromSurface(renderer, surf_tiles); // 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_losingscreen = IMG_Load("failscreen_01.png"); + level->surf_losingscreens[0] = SDL_CreateTextureFromSurface(renderer, surf_losingscreen); + + SDL_Surface* surf_winning_screen = IMG_Load("winningscreen.png"); + level->surf_winning_screen = SDL_CreateTextureFromSurface(renderer, surf_winning_screen); } -- cgit v1.2.1-18-gbd029