Exemple #1
0
Fichier : anim.c Projet : adsr/agar
/* Create a new animation of the specified pixel format. */
AG_Anim *
AG_AnimNew(enum ag_anim_type type, Uint w, Uint h, const AG_PixelFormat *pf,
    Uint flags)
{
	AG_Anim *a;

	if ((a = TryMalloc(sizeof(AG_Anim))) == NULL) {
		return (NULL);
	}
	if ((a->format = AG_PixelFormatDup(pf)) == NULL) {
		Free(a);
		return (NULL);
	}
	a->type = type;
	a->flags = flags;
	a->w = w;
	a->h = h;
	a->n = 0;
	a->pitch = w*pf->BytesPerPixel;
	a->clipRect = AG_RECT(0,0,w,h);
	a->f = NULL;
	a->fpsOrig = 30.0;
	AG_MutexInitRecursive(&a->lock);

	return (a);
}
Exemple #2
0
Fichier : anim.c Projet : adsr/agar
void
AG_AnimStateInit(AG_Anim *an, AG_AnimState *ast)
{
	AG_MutexInitRecursive(&ast->lock);
	ast->an = an;
	ast->flags = 0;
	ast->play = 0;
	ast->f = 0;
	
	AG_MutexLock(&an->lock);
	ast->fps = an->fpsOrig;
	AG_MutexUnlock(&an->lock);
}
Exemple #3
0
AU_Wave *
AU_WaveNew(void)
{
	AU_Wave *w;

	if ((w = AG_TryMalloc(sizeof(AU_Wave))) == NULL) {
		return (NULL);
	}
	w->flags = 0;
	w->file = NULL;
	w->frames = NULL;
	w->nFrames = 0;
	w->ch = 0;
	w->vizFrames = NULL;
	w->nVizFrames = 0;
	w->peak = 0.0;
	memset(&w->info, 0, sizeof(w->info));
	AG_MutexInitRecursive(&w->lock);
	return (w);
}