SDLGameEngine

SgeSpriteImage

Single sprite image low level functions. More...

Data Structures

struct  SGESPRITEIMAGE

Functions

SGESPRITEIMAGEsgeSpriteImageNew (void)
 create a empty sprite image
SGESPRITEIMAGEsgeSpriteImageNewFile (SGEFILE *f, const char *name)
 create a sprite image from a file
void sgeSpriteImageDestroy (SGESPRITEIMAGE *s)
 destroy a sprite image and free memory
SGESPRITEIMAGEsgeSpriteImageDuplicate (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:
aa pointer to the first SGESPRITEIMAGE
ba 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:
aa pointer to the first SGESPRITEIMAGE
ba 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:
sa 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:
sa pointer to a SGESPRITEIMAGE
alphaa alpha value (0-255)
destthe 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:
sa pointer to a SGESPRITEIMAGE
xthe x position to draw the image at
ythe y position to draw the image at
alphaa alpha value (0-255)
destthe 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:
sa 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:
sa 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:
fa pointer to SGEFILE
namethe 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:
sa pointer to a SGESPRITEIMAGE
rthe red value of the color (0-255)
gthe green value of the color (0-255)
bthe blue value of the color (0-255)
athe 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:
sa pointer to a SGESPRITEIMAGE
imagea 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:
sa pointer to a SGESPRITEIMAGE

Definition at line 202 of file sgespriteimage.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines