Imported updates from Codebase

This commit is contained in:
Kayne Ruse
2013-05-15 19:49:27 +10:00
parent 9f76b19a3c
commit 613d9cec08
13 changed files with 383 additions and 50 deletions
+13 -1
View File
@@ -21,6 +21,10 @@
*/
#include "image.hpp"
Image::Image() {
SetSurface(nullptr);
}
Image::Image(SDL_Surface* p) {
SetSurface(p);
}
@@ -31,7 +35,12 @@ Image::Image(SDL_Surface* p, SDL_Rect r) {
SDL_Surface* Image::SetSurface(SDL_Surface* p) {
surface = p;
clip = {0, 0, (Uint16)surface->w, (Uint16)surface->h};
if (!surface) {
clip = {0, 0, 0, 0};
}
else {
clip = {0, 0, (Uint16)surface->w, (Uint16)surface->h};
}
return surface;
}
@@ -46,6 +55,9 @@ SDL_Surface* Image::GetSurface() const {
}
void Image::DrawTo(SDL_Surface* dest, Sint16 x, Sint16 y) {
if (!surface) {
return;
}
SDL_Rect sclip = clip, dclip = {x,y};
SDL_BlitSurface(surface, &sclip, dest, &dclip);