summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLAMMJohnson <john_anthony@lavabit.com>2011-04-26 21:02:10 +0100
committerLAMMJohnson <john_anthony@lavabit.com>2011-04-26 21:02:10 +0100
commit3e124e00f6f3425ef27de31378d6c0187ca75f0e (patch)
tree0e1b93ce2e8c2a09451ef5e17fa3cb7ab6368c22
parentfcb47a91c17d0d4e65c719892ebac1c87d12ddd6 (diff)
downloadnyancat-3e124e00f6f3425ef27de31378d6c0187ca75f0e.tar.gz
nyancat-3e124e00f6f3425ef27de31378d6c0187ca75f0e.tar.bz2
nyancat-3e124e00f6f3425ef27de31378d6c0187ca75f0e.zip
Fixed alpha and background color
-rw-r--r--nyah.c54
-rw-r--r--res/frame00.pngbin1102 -> 1109 bytes
-rw-r--r--res/frame01.pngbin1094 -> 1099 bytes
-rw-r--r--res/frame02.pngbin1096 -> 1102 bytes
-rw-r--r--res/frame03.pngbin1107 -> 1110 bytes
-rw-r--r--res/frame04.pngbin1092 -> 1104 bytes
6 files changed, 40 insertions, 14 deletions
diff --git a/nyah.c b/nyah.c
index 743aba9..3e3a013 100644
--- a/nyah.c
+++ b/nyah.c
@@ -28,7 +28,7 @@ SDL_Surface* cat_img[5];
SDL_Surface* sparkle_img[5];
sparkle_instance* sparkles_list = NULL;
cat_instance* cat_list = NULL;
-Uint8 bgcolor;
+Uint32 bgcolor;
void add_sparkle(void);
void add_cat(unsigned int x, unsigned int y);
@@ -37,6 +37,7 @@ void draw_sparkles(unsigned int layer);
void fillsquare(SDL_Surface* surf, int x, int y, int w, int h, Uint32 col);
void handleinput(void);
void load_images(void);
+SDL_Surface* load_image(const char* path);
void putpix(SDL_Surface* surf, int x, int y, Uint32 col);
void remove_sparkle(sparkle_instance* s);
void update_sparkles(void);
@@ -161,17 +162,42 @@ handleinput(void) {
void
load_images(void) {
- cat_img[0] = IMG_Load("res/frame00.png");
- cat_img[1] = IMG_Load("res/frame01.png");
- cat_img[2] = IMG_Load("res/frame02.png");
- cat_img[3] = IMG_Load("res/frame03.png");
- cat_img[4] = IMG_Load("res/frame04.png");
-
- sparkle_img[0] = IMG_Load("res/sparkle0.png");
- sparkle_img[1] = IMG_Load("res/sparkle1.png");
- sparkle_img[2] = IMG_Load("res/sparkle2.png");
- sparkle_img[3] = IMG_Load("res/sparkle3.png");
- sparkle_img[4] = IMG_Load("res/sparkle4.png");
+ cat_img[0] = load_image("res/frame00.png");
+ cat_img[1] = load_image("res/frame01.png");
+ cat_img[2] = load_image("res/frame02.png");
+ cat_img[3] = load_image("res/frame03.png");
+ cat_img[4] = load_image("res/frame04.png");
+
+ sparkle_img[0] = load_image("res/sparkle0.png");
+ sparkle_img[1] = load_image("res/sparkle1.png");
+ sparkle_img[2] = load_image("res/sparkle2.png");
+ sparkle_img[3] = load_image("res/sparkle3.png");
+ sparkle_img[4] = load_image("res/sparkle4.png");
+}
+
+SDL_Surface*
+load_image( const char* path ) {
+ //Temporary storage for the image that's loaded
+ SDL_Surface* loadedImage = NULL;
+
+ //The optimized image that will be used
+ SDL_Surface* optimizedImage = NULL;
+
+ //Load the image
+ loadedImage = IMG_Load( path );
+
+ //If nothing went wrong in loading the image
+ if(loadedImage)
+ {
+ //Create an optimized image
+ optimizedImage = SDL_DisplayFormatAlpha( loadedImage );
+
+ //Free the old image
+ SDL_FreeSurface( loadedImage );
+ }
+
+ //Return the optimized image
+ return optimizedImage;
}
void
@@ -234,9 +260,9 @@ int main( int argc, char *argv[] )
SDL_Init( SDL_INIT_EVERYTHING );
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SURF_TYPE);
- bgcolor = SDL_MapRGB(screen->format, 0, 51, 102);
-
load_images();
+
+ bgcolor = SDL_MapRGB(screen->format, 0x00, 0x33, 0x66);
add_cat((SCREEN_WIDTH - cat_img[0]->w) / 2 , (SCREEN_HEIGHT - cat_img[0]->h) / 2);
diff --git a/res/frame00.png b/res/frame00.png
index b10bf5d..6e04a1a 100644
--- a/res/frame00.png
+++ b/res/frame00.png
Binary files differ
diff --git a/res/frame01.png b/res/frame01.png
index b027bcb..1f494bc 100644
--- a/res/frame01.png
+++ b/res/frame01.png
Binary files differ
diff --git a/res/frame02.png b/res/frame02.png
index 9f7b318..6f1e105 100644
--- a/res/frame02.png
+++ b/res/frame02.png
Binary files differ
diff --git a/res/frame03.png b/res/frame03.png
index 7a2b84c..128ce00 100644
--- a/res/frame03.png
+++ b/res/frame03.png
Binary files differ
diff --git a/res/frame04.png b/res/frame04.png
index 62cc7f3..da14316 100644
--- a/res/frame04.png
+++ b/res/frame04.png
Binary files differ