3 Demonstration of using different timelines (sprites)
7 * rfxswf uses a flat tag list
8 All sprite tags between ST_DEFINESPRITE and ST_END
9 will be packed into the data of the ST_DEFINESPRITE
10 by the output routines
12 * make sure, that all defining tags are placed
13 outside the sub-timelines (i.e. before ST_DEFINESPRITE)
15 * framerate is global (sad but true!)
17 Part of the swftools package.
19 Copyright (c) 2001 Rainer Böhme <rfxswf@reflex-studio.de>
21 This program is free software; you can redistribute it and/or modify
22 it under the terms of the GNU General Public License as published by
23 the Free Software Foundation; either version 2 of the License, or
24 (at your option) any later version.
26 This program is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 GNU General Public License for more details.
31 You should have received a copy of the GNU General Public License
32 along with this program; if not, write to the Free Software
33 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
38 #include "../rfxswf.h"
41 RGBA rgba(U8 r,U8 g,U8 b,U8 a)
42 { RGBA c; c.r = r; c.g = g; c.b = b; c.a = a;
49 #define GET_ID (last_id++)
50 #define GET_DEPTH (last_depth++)
52 int main(int argc, char ** argv)
69 last_id = last_depth = 1;
71 memset(&swf,0x00,sizeof(SWF));
74 swf.frameRate = 0x1000;
75 swf.movieSize.xmax = width*20;
76 swf.movieSize.ymax = height*20;
79 t = swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
81 rgb.r = rgb.g = rgb.b = rgb.a = 0xff;
84 t = swf_InsertTag(t,ST_DEFINESHAPE);
88 ls = swf_ShapeAddLineStyle(s,40,&rgb);
91 swf_SetU16(t,id_circle);
99 swf_SetShapeHeader(t,s);
100 swf_ShapeSetAll(t,s,0,0,ls,0,0);
101 swf_ShapeSetCircle(t,s,width/2,height/2,width/2,height/2);
104 // SPRITE #1 TIMELINE
106 t = swf_InsertTag(t,ST_DEFINESPRITE);
109 swf_SetU16(t,id_sprite);
110 swf_SetU16(t,32); // frame count
112 for (i=0;i<32;i++) // 32 frames
114 swf_GetMatrix(NULL,&m);
115 m.tx = width*2+(int)((float)width*2*sin((float)i/16*3.14152));
116 m.ty = width*2+(int)((float)height*2*cos((float)i/16*3.14152));
117 t = swf_InsertTag(t,ST_PLACEOBJECT2);
118 swf_ObjectPlace(t,(i==0)?id_circle:0,1,&m,NULL,NULL);
119 t = swf_InsertTag(t,ST_SHOWFRAME);
122 t = swf_InsertTag(t,ST_END);
124 // SPRITE #2 TIMELINE
126 t = swf_InsertTag(t,ST_DEFINESPRITE);
129 swf_SetU16(t,id_sprite2);
130 swf_SetU16(t,80); // frame count
132 for (i=0;i<80;i++) // 80 frames
134 swf_GetMatrix(NULL,&m);
135 m.tx = width*4+(int)((float)width*4*sin((float)i/40*3.14152));
136 m.ty = width*4+(int)((float)height*4*cos((float)i/40*3.14152));
137 t = swf_InsertTag(t,ST_PLACEOBJECT2);
138 swf_ObjectPlace(t,(i==0)?id_sprite:0,1,&m,NULL,NULL);
142 t = swf_InsertTag(t,ST_PLACEOBJECT2);
143 swf_ObjectPlace(t,(i==0)?id_sprite:0,2,&m,NULL,NULL);
144 t = swf_InsertTag(t,ST_SHOWFRAME);
147 t = swf_InsertTag(t,ST_END);
149 // MAIN MOVIE TIMELINE
151 t = swf_InsertTag(t,ST_PLACEOBJECT2);
153 swf_ObjectPlace(t,id_sprite2,1,NULL,NULL,NULL);
155 t = swf_InsertTag(t,ST_SHOWFRAME); // just one frame
157 t = swf_InsertTag(t,ST_END);
159 // swf_WriteCGI(&swf);
161 f = open("sprites.swf",O_RDWR|O_CREAT|O_TRUNC|O_BINARY,0644);
162 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
168 system("start ..\\sprites.swf");