<-- Back to AG_Intro.3


#include <agar/core.h>
#include <agar/gui.h>
#include <agar/rg.h>


The RG_Anim structure describes an animation (an array of frames) generated from a set of instructions.

Note: Unless you need to import animations, generate or manipulate animation instructions or frames programmatically, you do not need to use this interface. Libraries such as MAP(3) use this interface to display animations.

Public members of the RG_Anim structure include:
typedef struct rg_anim {
	char name[RG_ANIMATION_NAME_MAX]; /* User identifier */
	Uint32 main_id;			  /* Default ID mapping */
	Uint flags;
#define RG_ANIM_SRCALPHA	0x01
	Uint w, h;			/* Sprite geometry */
	RG_AnimFrame *frames;		/* Generated frames */
	Uint	     nframes;
	Uint	     gframe;		   /* Current frame (global) */
	AG_SLIST_HEAD_(rg_anim_variant) vars; /* Transformed variants */

typedef struct rg_anim_frame {
	Uint name;
	Uint delay;
	AG_Surface *su;
	Uint texture;
} RG_AnimFrame;

typedef struct rg_anim_variant {
	RG_TransformChain transforms;		/* Applied transforms */
	RG_Anim *anim;				/* Transformed anim */
} RG_AnimVariant;


RG_Anim * RG_AnimInit (RG_Anim *anim, RG_Tileset *ts, const char *name, Uint flags)

void RG_AnimDestroy (RG_Anim *anim)

void RG_AnimScale (RG_Anim *anim, Uint width, Uint height)

void RG_AnimGenerate (RG_Anim *anim)

Uint RG_AnimInsertInsn (RG_Anim *anim, enum rg_anim_insn_type type)

void RG_AnimRemoveInsn (RG_Anim *anim, Uint insn)

Uint RG_AnimInsertFrame (RG_Anim *anim, AG_Surface *s)

void RG_AnimRemoveFrame (RG_Anim *anim, Uint frame)

RG_AnimFrame * RG_ANIM_FRAME (RG_Anim *anim, Uint frame)

The RG_AnimInit() initializes a RG_Anim attached to the given RG_Tileset 3 identified by name. The flags may include:
RG_ANIM_SRCCOLORKEYUse colorkeying with the animation surfaces.
RG_ANIM_SRCALPHAUse alpha blending with the animation surfaces.

RG_AnimScale() resizes the canvas of the animation to width by height pixels.

The RG_AnimGenerate() function compiles the array of frames for the animation, from the instructions.

The RG_AnimInsertInsn() function inserts a new instruction, and returns its new index. type is one of:
	enum rg_anim_insn_type {
		RG_ANIM_TILE,		/* Replace/blend with prev tile */
		RG_ANIM_DISPX,		/* Pixmap translation */
		RG_ANIM_ROTPX		/* Pixmap rotation */

The RG_AnimRemoveInsn() removes the given instruction.

RG_AnimInsertFrame() manually inserts a frame containing the given surface into the animation array, and returns the index of the frame. RG_AnimRemoveFrame() removes the frame of the given index. These functions are useful to manipulate the frames directly when the animation is imported from some external source, for example.

The RG_ANIM_FRAME() macro returns a pointer to the RG_AnimFrame structure for the given frame index.


RG(3), RG_Feature(3), RG_Pixmap(3), RG_Sketch(3), RG_Texture(3), RG_Tile(3), RG_Tileview(3) ElectronTubeStore