Background.c File Reference

Background handler source. More...

#include <SDL.h>
#include <SDL_image.h>
#include "Background.h"
#include "Constants.h"
Include dependency graph for Background.c:

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 *pstBackground)
 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 source.

Author
Michael Fitzmayer

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