Background.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: Beerware
7 #pragma once
8 
9 #include <SDL.h>
10 #include "Constants.h"
11 
18 typedef struct BGLayer_t
19 {
20  SDL_Texture* pstLayer;
21  Sint32 s32Width;
22  Sint32 s32Height;
23  double dPosX;
24  double dPosY;
25  double dVelocity;
26 
27 } BGLayer;
28 
35 typedef struct Background_t
36 {
37  Uint8 u8Num;
41 
42 } Background;
43 
44 Sint8 Background_Draw(
45  const Direction eDirection,
46  const Sint32 s32LogicalWindowHeight,
47  const double dCameraPosY,
48  const double dVelocity,
49  SDL_Renderer* pstRenderer,
50  Background* pstBackground);
51 
53 
54 Sint8 Background_Init(
55  const Uint8 u8Num,
56  const char* pacFilenames[static u8Num],
57  const Sint32 s32WindowWidth,
58  const Alignment eAlignment,
59  SDL_Renderer* pstRenderer,
60  Background** pstBackground);
Alignment eAlignment
Background alignment.
Definition: Background.h:38
double dVelocity
Velocity.
Definition: Background.h:25
Background handler include header.
BGLayer acLayer[]
Array of background layers.
Definition: Background.h:40
Sint8 Background_Draw(const Direction eDirection, const Sint32 s32LogicalWindowHeight, const double dCameraPosY, const double dVelocity, SDL_Renderer *pstRenderer, Background *pstBackground)
Draw background.
Definition: Background.c:227
Constants include header.
Sint8 Background_Init(const Uint8 u8Num, const char *pacFilenames[static u8Num], const Sint32 s32WindowWidth, const Alignment eAlignment, SDL_Renderer *pstRenderer, Background **pstBackground)
Initialise background.
Definition: Background.c:281
struct Background_t Background
Background handle type.
Background layer data.
Definition: Background.h:18
Uint8 u8Num
Number of layers.
Definition: Background.h:37
Direction eDirection
Scroll direction.
Definition: Background.h:39
double dPosX
Position along the x-axis.
Definition: Background.h:23
Sint8 Background_Draw(const Direction eDirection, const Sint32 s32LogicalWindowHeight, const double dCameraPosY, const double dVelocity, SDL_Renderer *pstRenderer, Background *pstBackground)
Draw background.
Definition: Background.c:227
SDL_Texture * pstLayer
Pointer to SDL2 texture.
Definition: Background.h:20
Sint32 s32Height
Background height in pixel.
Definition: Background.h:22
void Background_Free(Background *pstBackground)
Free background.
Definition: Background.c:256
struct BGLayer_t BGLayer
Background layer type.
Sint32 s32Width
Background width in pixel.
Definition: Background.h:21
double dPosY
Position along the y-axis.
Definition: Background.h:24
Sint8 Background_Init(const Uint8 u8Num, const char *pacFileNames[static u8Num], const Sint32 s32WindowWidth, const Alignment eAlignment, SDL_Renderer *pstRenderer, Background **pstBackground)
Initialise background.
Definition: Background.c:281
enum Alignment_t Alignment
Alignment constants type.
Background handle data.
Definition: Background.h:35
void Background_Free(Background *Background)
Free background.
Definition: Background.c:256
enum Direction_t Direction
Directional constants type.