From dac6b72f8f5fc9ecf564412927dcff7a04d37dc0 Mon Sep 17 00:00:00 2001 From: Victor Gamper Date: Sun, 26 Jan 2020 13:20:28 +0100 Subject: Added birds and a readme file --- PidginImage.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 PidginImage.c (limited to 'PidginImage.c') diff --git a/PidginImage.c b/PidginImage.c new file mode 100644 index 0000000..70dcb78 --- /dev/null +++ b/PidginImage.c @@ -0,0 +1,36 @@ +/* + * PidginImage.c + * + * Created on: 26.01.2020 + * Author: victor + */ +#include "pidgin_image.h" +#include "catch.h" + +static int animation_index = 0, ax = 1; +static SDL_Rect sdl_rect_output, sdl_rect_source; +static SDL_Surface* image_pidgin; + +void Pidgin_Init() { + SDL_RWops* rwops = SDL_RWFromConstMem(pidgin_bmp, sizeof(pidgin_bmp) / sizeof(char)); + image_pidgin = SDL_LoadBMP_RW(rwops,1); + SDL_SetColorKey(image_pidgin, SDL_SRCCOLORKEY, SDL_MapRGB(image_pidgin->format, 255, 0, 255)); + //SDL_FreeRW(rwops); + + sdl_rect_source.x = 0; + sdl_rect_source.w = PIDGIN_WIDTH; + sdl_rect_source.h = PIDGIN_HEIGHT; +} + +void draw_Pidgin(SDL_Surface* surface, int x, int y) { + sdl_rect_output.x = x; + sdl_rect_output.y = y; + SDL_BlitSurface(image_pidgin, &sdl_rect_source, surface, &sdl_rect_output); +} + +void Pidgin_IncrementFrame() { + animation_index+=ax; + sdl_rect_source.y = animation_index * PIDGIN_HEIGHT; + if(animation_index > 1) ax = -1; + if(animation_index < 1) ax = 1; +} -- cgit v1.2.3