summaryrefslogtreecommitdiff
path: root/intensemarcus.cpp
diff options
context:
space:
mode:
authorLuke Bratch <l_bratch@yahoo.co.uk>2010-11-25 20:35:18 +0000
committerLuke Bratch <l_bratch@yahoo.co.uk>2010-11-25 20:35:18 +0000
commit413302330666a135389b759139ff9d5b6eb20052 (patch)
tree15cbb0a0651417871d8d20033227339553f4ec3c /intensemarcus.cpp
parent71926d883a678be983a434f8c0da435178d7585d (diff)
Add background to Level, add sample background, modify Screen::blit() to always blit
onto the game window
Diffstat (limited to 'intensemarcus.cpp')
-rw-r--r--intensemarcus.cpp24
1 files changed, 24 insertions, 0 deletions
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;
+}