From 413302330666a135389b759139ff9d5b6eb20052 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Thu, 25 Nov 2010 20:35:18 +0000 Subject: Add background to Level, add sample background, modify Screen::blit() to always blit onto the game window --- intensemarcus.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 intensemarcus.cpp (limited to 'intensemarcus.cpp') diff --git a/intensemarcus.cpp b/intensemarcus.cpp new file mode 100644 index 0000000..c866a1a --- /dev/null +++ b/intensemarcus.cpp @@ -0,0 +1,24 @@ +#include "intensemarcus.h" + +/* SDL_Surface loads an image from a file, and + converts it into the same format as the + display, for faster blitting. */ +SDL_Surface *loadImage(std::string filename) { + // Image as it is loaded + SDL_Surface* raw = NULL; + + // Image converted into same format as display + SDL_Surface* image = NULL; + + raw = IMG_Load(filename.c_str()); + + if(raw != NULL) { + // Convert the image, using the PNG's alpha channel + image = SDL_DisplayFormatAlpha(raw); + + // Free raw image + SDL_FreeSurface(raw); + } + + return image; +} -- cgit v1.2.3