summaryrefslogtreecommitdiff
path: root/level.c
diff options
context:
space:
mode:
Diffstat (limited to 'level.c')
-rw-r--r--level.c25
1 files changed, 15 insertions, 10 deletions
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);
}