@@ -257,7 +257,7 @@ void ST_RenderAnimationNext(st_animation *animation, int x, int y)
257
257
animation -> currentFrame ++ ;
258
258
if (animation -> currentFrame >= animation -> length )
259
259
animation -> currentFrame = animation -> loopFrame ;
260
- ST_RenderFramePosition (animation -> frames [ animation -> currentFrame ] , x , y );
260
+ ST_RenderAnimationCurrent (animation , x , y );
261
261
}
262
262
263
263
/* Draw the previous frame of an animation at given position */
@@ -268,7 +268,7 @@ void ST_RenderAnimationPrevious(st_animation *animation, int x, int y)
268
268
animation -> currentFrame -- ;
269
269
if (animation -> currentFrame >= animation -> length )
270
270
animation -> currentFrame = animation -> loopFrame ;
271
- ST_RenderFramePosition (animation -> frames [ animation -> currentFrame ] , x , y );
271
+ ST_RenderAnimationCurrent (animation , x , y );
272
272
}
273
273
274
274
/* Plays an animation at given position */
@@ -291,7 +291,7 @@ void ST_RenderAnimationPlay(st_animation *animation, int x, int y)
291
291
}
292
292
else
293
293
{
294
- if (animation -> ftn > abs ( animation -> fpf ) )
294
+ if (animation -> ftn > -1 * animation -> fpf )
295
295
{
296
296
animation -> ftn = 0 ;
297
297
ST_RenderAnimationPrevious (animation , x , y );
@@ -302,3 +302,77 @@ void ST_RenderAnimationPlay(st_animation *animation, int x, int y)
302
302
}
303
303
}
304
304
}
305
+
306
+
307
+ /****************************************\
308
+ |* Advanced Animation Rendering *|
309
+ \****************************************/
310
+ /* The following functions also take a scalar multiplier, */
311
+ /* rotation in radians, and red, green, blue, and alpha of a */
312
+ /* color to blend with */
313
+
314
+
315
+ void ST_RenderAnimationCurrentAdvanced (st_animation * animation , int x , int y ,
316
+ double scale , double rotate ,
317
+ u8 red , u8 green , u8 blue , u8 alpha )
318
+ {
319
+ ST_RenderFramePositionAdvanced (animation -> frames [animation -> currentFrame ],
320
+ x , y , scale , rotate , red , green , blue , alpha );
321
+ }
322
+
323
+ void ST_RenderAnimationNextAdvanced (st_animation * animation , int x , int y ,
324
+ double scale , double rotate ,
325
+ u8 red , u8 green , u8 blue , u8 alpha )
326
+ {
327
+ animation -> currentFrame ++ ;
328
+ if (animation -> currentFrame >= animation -> length )
329
+ animation -> currentFrame = animation -> loopFrame ;
330
+ ST_RenderAnimationCurrentAdvanced (animation , x , y ,
331
+ scale , rotate , red , green , blue , alpha );
332
+ }
333
+
334
+ void ST_RenderAnimationPreviousAdvanced (st_animation * animation , int x , int y ,
335
+ double scale , double rotate ,
336
+ u8 red , u8 green , u8 blue , u8 alpha )
337
+ {
338
+ animation -> currentFrame -- ;
339
+ if (animation -> currentFrame >= animation -> length )
340
+ animation -> currentFrame = animation -> loopFrame ;
341
+ ST_RenderAnimationCurrentAdvanced (animation , x , y ,
342
+ scale , rotate , red , green , blue , alpha );
343
+ }
344
+
345
+ void ST_RenderAnimationPlayAdvanced (st_animation * animation , int x , int y ,
346
+ double scale , double rotate ,
347
+ u8 red , u8 green , u8 blue , u8 alpha )
348
+ {
349
+ animation -> ftn ++ ;
350
+ if (animation -> fpf >= 0 )
351
+ {
352
+ if (animation -> ftn > animation -> fpf )
353
+ {
354
+ animation -> ftn = 0 ;
355
+ ST_RenderAnimationNextAdvanced (animation , x , y ,
356
+ scale , rotate , red , green , blue , alpha );
357
+ }
358
+ else
359
+ {
360
+ ST_RenderAnimationCurrentAdvanced (animation , x , y ,
361
+ scale , rotate , red , green , blue , alpha );
362
+ }
363
+ }
364
+ else
365
+ {
366
+ if (animation -> ftn > -1 * animation -> fpf )
367
+ {
368
+ animation -> ftn = 0 ;
369
+ ST_RenderAnimationPreviousAdvanced (animation , x , y ,
370
+ scale , rotate , red , green , blue , alpha );
371
+ }
372
+ else
373
+ {
374
+ ST_RenderAnimationCurrentAdvanced (animation , x , y ,
375
+ scale , rotate , red , green , blue , alpha );
376
+ }
377
+ }
378
+ }
0 commit comments