FANDOM


Sprites are the moving objects found in every videogame. These are characters, the weapons, the enemies and the items like coins, fruits, etc. Sprites are very different to tiles which are the actual background artwork for the game.

A simple sprite structure in C would look like this:

typedef struct _sprite
{
  // Position and dimensions
  int x;
  int y;
  int w;
  int h;
  unsigned int flags; // boolean data
  Bitmap * image; // the image to draw
  Sprite * owner; // for weapons
  Player * player; // for ownership, NULL if it is an enemy
} SPRITE;

Thus, with this data, a sprite could be drawn at screen or world position x, y, with a width and height w, h and the picture "image". A sprite must have some functions to allow loading of image data, setting positions, calculating collisions and so on.