SDLGameEngine

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

Data Structures | Functions | Variables

# SgeSpriteImage

Single sprite image low level functions. More...

## Data Structures
struct | SGESPRITEIMAGE
## Functions
SGESPRITEIMAGE * | sgeSpriteImageNew (void)
| create a empty sprite image
SGESPRITEIMAGE * | sgeSpriteImageNewFile (SGEFILE *f, const char *name)
| create a sprite image from a file
void | sgeSpriteImageDestroy (SGESPRITEIMAGE *s)
| destroy a sprite image and free memory
SGESPRITEIMAGE * | sgeSpriteImageDuplicate (SGESPRITEIMAGE *s)
| duplicate (copy) a sprite image
void | sgeSpriteImageSetImage (SGESPRITEIMAGE *s, SDL_Surface *image)
| change or set the actual image of a sprite image
void | sgeSpriteImageDraw (SGESPRITEIMAGE *s, Uint8 alpha, SDL_Surface *dest)
| draw a sprite image on its position
void | sgeSpriteImageDrawXY (SGESPRITEIMAGE *s, int x, int y, Uint8 alpha, SDL_Surface *dest)
| draw a sprite image on its position
int | sgeSpriteImageBoxCollide (SGESPRITEIMAGE *a, SGESPRITEIMAGE *b)
| check if the outbox of two images overlap
int | sgeSpriteImageCollide (SGESPRITEIMAGE *a, SGESPRITEIMAGE *b)
| pixel exact collision detection between two images
void | sgeSpriteImageUseAlpha (SGESPRITEIMAGE *s)
| use image alpha information for collision detection
void | sgeSpriteImageIgnoreAlpha (SGESPRITEIMAGE *s)
| use a certain color of the image for collision detection
void | sgeSpriteImageSetCollisionColor (SGESPRITEIMAGE *s, int r, int g, int b, int a)
| set the collision color if no alpha is used
## Variables
Uint32 | SGESPRITEIMAGE::collisionColor
| if no alpha used, use this color as 'transparent' (for collision only)
int | SGESPRITEIMAGE::x
| the x position of the image
int | SGESPRITEIMAGE::y
| the y position of the image
int | SGESPRITEIMAGE::w
| width of the image
int | SGESPRITEIMAGE::h
| height of the image
SDL_Surface * | SGESPRITEIMAGE::image
| the sdl surface element of the image

## Detailed Description

Single sprite image low level functions.

Usually you would want to use sgeSprite. sgeSpriteImage is more like a low level acess to the sprite data itself.

## Function Documentation

int sgeSpriteImageBoxCollide | ( | SGESPRITEIMAGE * | a,
|  | SGESPRITEIMAGE * | b
| ) |  |

check if the outbox of two images overlap

Parameters:

  a | a pointer to the first SGESPRITEIMAGE
  b | a pointer to the second SGESPRITEIMAGE

Returns:
  0 or 1 if there is overlapping

This is a fast check if two images overlap at all, it is not pixel based.

Definition at line 90 of file sgespriteimage.c.

int sgeSpriteImageCollide | ( | SGESPRITEIMAGE * | a,
|  | SGESPRITEIMAGE * | b
| ) |  |

pixel exact collision detection between two images

Parameters:

  a | a pointer to the first SGESPRITEIMAGE
  b | a pointer to the second SGESPRITEIMAGE

Returns:
  0 or 1 if there is a collision

This uses sgeSpriteImageBoxCollide to speed up the test, you do not need to call it yourself.

Definition at line 138 of file sgespriteimage.c.

void sgeSpriteImageDestroy | ( | SGESPRITEIMAGE * | s | ) |

destroy a sprite image and free memory

Parameters:

  s | a pointer to a SGESPRITEIMAGE

Definition at line 31 of file sgespriteimage.c.

void sgeSpriteImageDraw | ( | SGESPRITEIMAGE * | s,
|  | Uint8 | alpha,
|  | SDL_Surface * | dest
| ) |  |

draw a sprite image on its position

Parameters:

  s | a pointer to a SGESPRITEIMAGE
  alpha | a alpha value (0-255)
  dest | the destination surface, either a SDL_Surface or screen

The position of the sprite is taken from the SGESPRITEIMAGE x and y values.

Definition at line 61 of file sgespriteimage.c.

void sgeSpriteImageDrawXY | ( | SGESPRITEIMAGE * | s,
|  | int | x,
|  | int | y,
|  | Uint8 | alpha,
|  | SDL_Surface * | dest
| ) |  |

draw a sprite image on its position

Parameters:

  s | a pointer to a SGESPRITEIMAGE
  x | the x position to draw the image at
  y | the y position to draw the image at
  alpha | a alpha value (0-255)
  dest | the destination surface, either a SDL_Surface or screen

This overrides the position information from SGESPRITEIMAGE

Definition at line 75 of file sgespriteimage.c.

SGESPRITEIMAGE* sgeSpriteImageDuplicate | ( | SGESPRITEIMAGE * | s | ) |

duplicate (copy) a sprite image

Parameters:

  s | a pointer to a SGESPRITEIMAGE

Returns:
  a pointer to a new copy of the image

Definition at line 36 of file sgespriteimage.c.

void sgeSpriteImageIgnoreAlpha | ( | SGESPRITEIMAGE * | s | ) |

use a certain color of the image for collision detection

Parameters:

  s | a pointer to a SGESPRITEIMAGE

Definition at line 207 of file sgespriteimage.c.

SGESPRITEIMAGE* sgeSpriteImageNew | ( | void |  | ) |

create a empty sprite image

Returns:
  a pointer to SGESPRITEIMAGE

Definition at line 11 of file sgespriteimage.c.

SGESPRITEIMAGE* sgeSpriteImageNewFile | ( | SGEFILE * | f,
|  | const char * | name
| ) |  |

create a sprite image from a file

Parameters:

  f | a pointer to SGEFILE
  name | the name of the file

Returns:
  a pointer to SGESPRITEIMAGE

Definition at line 23 of file sgespriteimage.c.

void sgeSpriteImageSetCollisionColor | ( | SGESPRITEIMAGE * | s,
|  | int | r,
|  | int | g,
|  | int | b,
|  | int | a
| ) |  |

set the collision color if no alpha is used

Parameters:

  s | a pointer to a SGESPRITEIMAGE
  r | the red value of the color (0-255)
  g | the green value of the color (0-255)
  b | the blue value of the color (0-255)
  a | the alpha value of the color (0-255)

Sets the color which is used as 'transparent' if collision detection is not using alpha.

See also:
  sgeSpriteImageIgnoreAlpha

Definition at line 212 of file sgespriteimage.c.

void sgeSpriteImageSetImage | ( | SGESPRITEIMAGE * | s,
|  | SDL_Surface * | image
| ) |  |

change or set the actual image of a sprite image

Parameters:

  s | a pointer to a SGESPRITEIMAGE
  image | a pointer to a SDL_Surface

Returns:
  a pointer to a new copy of the image

Either sets the new image, or replaces a existing one. If there already was a SDL_Surface, it's memory is freed.

Definition at line 49 of file sgespriteimage.c.

void sgeSpriteImageUseAlpha | ( | SGESPRITEIMAGE * | s | ) |

use image alpha information for collision detection

Parameters:

  s | a pointer to a SGESPRITEIMAGE

Definition at line 202 of file sgespriteimage.c.

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines