コード例 #1
0
ファイル: title.c プロジェクト: AMDmi3/FallingTime
void TitleImagesFree(void)
{
	AnimationFree(&TitleAnim);
	AnimationFree(&GameOverAnim);
	for (int i = 0; i < MAX_PLAYERS; i++)
	{
		SDL_DestroyTexture(ControlTexes[i].T);
	}
#ifdef __GCW0__
	SDL_DestroyTexture(ControlTex0Analog.T);
	SDL_DestroyTexture(ControlTex0G.T);
#endif
}
コード例 #2
0
ファイル: animation.c プロジェクト: gameblabla/fallingtime
bool AnimationLoad(
	Animation *a, const char *filename, const int w, const int h,
	const int frameRate)
{
	SDL_Surface *tmp;
#ifdef EMBED
	SDL_RWops *rw = NULL;
#endif

#ifdef EMBED
	if (strcmp(filename,IMAGE_SPARKS) == 0) rw = SDL_RWFromMem(IMG_SPARKS, SPARKS_SIZE);
	else if (strcmp(filename,IMAGE_SPARKS_RED) == 0) rw = SDL_RWFromMem(IMG_SPARKS_RED, SPARKS_RED_SIZE);
	else if (strcmp(filename,IMAGE_TAIL) == 0) rw = SDL_RWFromMem(IMG_TAIL, TAIL_SIZE);
	else if (strcmp(filename,IMAGE_ANIM) == 0) rw = SDL_RWFromMem(IMG_ANIM, ANIM_SIZE);
	else if (strcmp(filename,IMAGE_GAMEOVER) == 0) rw = SDL_RWFromMem(IMG_GAMEOVER, GAMEOVER_SIZE);
    tmp = SDL_LoadBMP_RW(rw, 0);
    if (rw) SDL_FreeRW(rw);
#else
	tmp = SDL_LoadBMP(filename);
#endif
	
	if (strcmp(filename,IMAGE_GAMEOVER) == 0) 
	{
		SDL_SetColorKey(tmp, (SDL_SRCCOLORKEY | SDL_ACCELERATION_RLE), SDL_MapRGB(tmp->format, 255, 0, 255));
	}
	else 
	{
		SDL_SetColorKey(tmp, (SDL_SRCCOLORKEY | SDL_ACCELERATION_RLE), 0);
	}
	
	a->image = SDL_DisplayFormat(tmp);
	if (tmp) SDL_FreeSurface(tmp);

	if (a->image == NULL) 
	{
		printf("Failure to load %s\n", filename);
		goto bail;
	}
	a->w = w;
	a->h = h;
	a->frame = 0;
	a->frameCounter = 0;
	a->frameRate = frameRate;

	return true;

bail:
	AnimationFree(a);
	return false;
}