Background.h File Reference

Background handler include header. More...

#include <SDL.h>
#include "Constants.h"
Include dependency graph for Background.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  BGLayer_t
 Background layer data. More...
 
struct  Background_t
 Background handle data. More...
 

Typedefs

typedef struct BGLayer_t BGLayer
 Background layer type.
 
typedef struct Background_t Background
 Background handle type.
 

Functions

Sint8 Background_Draw (const Direction eDirection, const Sint32 s32LogicalWindowHeight, const double dCameraPosY, const double dVelocity, SDL_Renderer *pstRenderer, Background *pstBackground)
 Draw background. More...
 
void Background_Free (Background *Background)
 Free background. More...
 
Sint8 Background_Init (const Uint8 u8Num, const char *pacFilenames[static u8Num], const Sint32 s32WindowWidth, const Alignment eAlignment, SDL_Renderer *pstRenderer, Background **pstBackground)
 Initialise background. More...
 

Detailed Description

Background handler include header.

Function Documentation

◆ Background_Draw()

Sint8 Background_Draw ( const Direction  eDirection,
const Sint32  s32LogicalWindowHeight,
const double  dCameraPosY,
const double  dVelocity,
SDL_Renderer *  pstRenderer,
Background pstBackground 
)

Draw background.

Draws the layers of a parallax-scrolling background

Parameters
eDirectionScroll direction
s32LogicalWindowHeightLogical window height in pixel
dCameraPosYCamera position along the y-axis
dVelocityScroll velocity
pstRendererPointer to SDL2 rendering context
pstBackgroundPointer to background handle
Returns
Error code
Return values
0OK

◆ Background_Free()

void Background_Free ( Background pstBackground)

Free background.

Frees up allocated memory and unload parallax-scrolling background

Parameters
pstBackgroundPointer to background handle

◆ Background_Init()

Sint8 Background_Init ( const Uint8  u8Num,
const char *  pacFileNames[static u8Num],
const Sint32  s32WindowWidth,
const Alignment  eAlignment,
SDL_Renderer *  pstRenderer,
Background **  pstBackground 
)

Initialise background.

Initialises parallax-scrolling background

Parameters
u8NumNumber of backgrounds
pacFileNamesPointer to array with list of filenames
s32WindowWidthWindow width in pixel
eAlignmentBackground alignment
pstRendererPointer to SDL2 rendering context
pstBackgroundPointer to background handle
Returns
Error code
Return values
0OK
-1Error