bool t3f_save_vector_object_f(T3F_VECTOR_OBJECT * vp, ALLEGRO_FILE * fp)
{
	unsigned char r, g, b, a;
	char header[16] = {'T', '3', 'F', 'V'};
	int i;
	
	if(al_fwrite(fp, header, 16) != 16)
	{
		return false;
	}
	al_fwrite32le(fp, vp->segments);
	for(i = 0; i < vp->segments; i++)
	{
		t3f_fwrite_float(fp, vp->segment[i]->point[0].x);
		t3f_fwrite_float(fp, vp->segment[i]->point[0].y);
		t3f_fwrite_float(fp, vp->segment[i]->point[0].z);
		t3f_fwrite_float(fp, vp->segment[i]->point[1].x);
		t3f_fwrite_float(fp, vp->segment[i]->point[1].y);
		t3f_fwrite_float(fp, vp->segment[i]->point[1].z);
		al_unmap_rgba(vp->segment[i]->color, &r, &g, &b, &a);
		al_fputc(fp, r);
		al_fputc(fp, g);
		al_fputc(fp, b);
		al_fputc(fp, a);
		t3f_fwrite_float(fp, vp->segment[i]->thickness);
	}
	return true;
}
Esempio n. 2
0
int t3f_save_animation_f(T3F_ANIMATION * ap, ALLEGRO_FILE * fp)
{
	int i;

	ani_header[11] = T3F_ANIMATION_REVISION; // put the version number in
	al_fwrite(fp, ani_header, 12);
	al_fwrite16le(fp, ap->bitmaps->count);
	for(i = 0; i < ap->bitmaps->count; i++)
	{
		if(!t3f_save_bitmap_f(fp, ap->bitmaps->bitmap[i]))
		{
			printf("failed to save bitmap\n");
			return 0;
		}
	}
	al_fwrite16le(fp, ap->frames);
	for(i = 0; i < ap->frames; i++)
	{
		al_fwrite16le(fp, ap->frame[i]->bitmap);
		t3f_fwrite_float(fp, ap->frame[i]->x);
		t3f_fwrite_float(fp, ap->frame[i]->y);
		t3f_fwrite_float(fp, ap->frame[i]->z);
		t3f_fwrite_float(fp, ap->frame[i]->width);
		t3f_fwrite_float(fp, ap->frame[i]->height);
		t3f_fwrite_float(fp, ap->frame[i]->angle);
		al_fwrite32le(fp, ap->frame[i]->ticks);
		al_fwrite32le(fp, ap->frame[i]->flags);
	}
	al_fwrite32le(fp, ap->flags);
	return 1;
}
Esempio n. 3
0
int t3f_save_tilemap_f(T3F_TILEMAP * tmp, ALLEGRO_FILE * fp)
{
	int i, j, k;
	char header[16] = {0};
	strcpy(header, "T3F_TILEMAP");
	header[15] = 0;

	al_fwrite(fp, header, 16);
	al_fwrite16le(fp, tmp->layers);
	for(i = 0; i < tmp->layers; i++)
	{
		al_fwrite16le(fp, tmp->layer[i]->width);
		al_fwrite16le(fp, tmp->layer[i]->height);
		for(j = 0; j < tmp->layer[i]->height; j++)
		{
			for(k = 0; k < tmp->layer[i]->width; k++)
			{
				al_fwrite16le(fp, tmp->layer[i]->data[j][k]);
			}
		}
		t3f_fwrite_float(fp, tmp->layer[i]->x);
		t3f_fwrite_float(fp, tmp->layer[i]->y);
		t3f_fwrite_float(fp, tmp->layer[i]->z);
		t3f_fwrite_float(fp, tmp->layer[i]->scale);
		t3f_fwrite_float(fp, tmp->layer[i]->speed_x);
		t3f_fwrite_float(fp, tmp->layer[i]->speed_y);
		al_fwrite32le(fp, tmp->layer[i]->flags);
	}
	al_fwrite32le(fp, tmp->flags);
	return 1;
}
bool t3f_save_vector_font_f(T3F_VECTOR_FONT * vfp, ALLEGRO_FILE * fp)
{
	char header[16] = {'T', '3', 'F', 'V', 'F'};
	int i;
	
	if(al_fwrite(fp, header, 16) != 16)
	{
		return false;
	}
	for(i = 0; i < T3F_VECTOR_FONT_MAX_CHARACTERS; i++)
	{
		if(vfp->character[i])
		{
			al_fputc(fp, 1);
			t3f_save_vector_object_f(vfp->character[i]->object, fp);
			t3f_fwrite_float(fp, vfp->character[i]->width);
		}
		else
		{
			al_fputc(fp, 0);
		}
	}
	return true;
}