-
Notifications
You must be signed in to change notification settings - Fork 0
c2DModel
Holds an array of cSprites. The coordinates of the individual sets should be set relative to the c2DModel. For example, to place a sprite right where the model x & y is, the sprite's x & y should be (0,0). Another way to describe this is the individual cSprite's coordinates are added to the coordinates of the c2DModel when drawing.
In this way, each sprite's scale, flipping, rotation, and fixed status is also considered. Each sprite is drawn with its renderPriority relative to other sprites in the model. The renderPriority doesn't dictate when individual pieces are drawn relative to other outside sprites or cScene members.
cSprite*
An array of sprites, in no particular order. Draw priority and position is determined by each sprite's data.
int
The size of the sprite array sprites.
cDoubleRect
The rectangle that stores where the model will be drawn and how wide and tall it is.
cDoublePt
The center point of the model; where it rotates around. Defaults to {rect.w / 2.0, rect.h / 2.0}.
double
The multiplicative scaling factor for drawing the model. To resize the sprite by a certain factor, you must just modify this variable.
SDL_RendererFlip
The SDL flipping flag. SDL_FLIP_HORIZONTAL for mirroring across the y-axis, SDL_FLIP_VERTICAL for mirroring across the x-axis, and SDL_FLIP_NONE for no mirroring.
double
The rotation value of the model, in degrees clockwise from the +x axis.
int
Defines which layer the model is rendered on. 0 -> Not rendered. 1 -> rendered last, 2 -> rendered after 1, etc. until the last layer renderLayers -> rendered first. renderLayers is defined when running initCoSprite(), and defaults to 5.
bool
If true, the model won't be affected by the camera. It's useful in creating a HUD, or letting something important stick to the screen without camera rotation, panning, zoom, or scaling coming into play.
void*
Not used internally; this can be a pointer to any data or struct you wish to give it.
void initC2DModel(c2DModel* model, cSprite* sprites, int numSprites, cDoublePt position, cDoublePt* center, double scale, SDL_RendererFlip flip, double degrees, bool fixed, void* subclass, int drawPriority)
Initializes a C2DModel with a sprite array and its size, the point where it starts, optionally its center (pass NULL for default), scale, flipping, rotation, fixed flag, optional subclass, and draw priority.
void destroyC2DModel(c2DModel* model)
Destroys a given c2DModel, de-allocating all the memory associated with it. This must be done individually if the sprite is not both in a cScene and de-allocated by destroying that cScene.
void importC2DModel(c2DModel* model, char* filepath)
Takes in a file exported through exportC2DModel and writes it to the provided model.
void exportC2DModel(c2DModel* model, char* filepath)
Prints out the data representing a c2DModel to the filepath provided. The data is printed in array format, in the order of each member.
void sortCSpritesInModel(c2DModel* model)
Runs a sort function (currently Insertion) on the sprites in the model, sorting by renderLayer from high to low. Automatically done in the importC2DModel and initC2DModel functions to optimize draw speeds.
void drawC2DModel(c2DModel model, cCamera camera, bool update)
Draws a c2DModel with the given camera. Pass true to update if you want the changes to be shown, or in other words, if you want the SDL_Renderer to be presented.