To The Flag by ML (mlefebvre.fr)
Data Structures | Functions
play.h File Reference

Contains every functions declaration for play.c. More...

Go to the source code of this file.

Data Structures

struct  LAYOUT
 
struct  LAYOUT_TEXT
 
struct  SUCCESS_TEXT
 

Functions

void playGame (SDL_Surface *w)
 
int shoot (SDL_Surface *w, LAYOUT *l, float a, float sp)
 
void loadFont (LAYOUT_TEXT *t, SUCCESS_TEXT *s)
 
void setParameters (LAYOUT_TEXT *t, float a, float sp)
 
void loadLayout (LAYOUT *l)
 
void reloadLayout (LAYOUT *l)
 
void drawLayout (SDL_Surface *w, LAYOUT *l)
 
void drawLine (LAYOUT *l, float a)
 
void drawText (SDL_Surface *w, LAYOUT_TEXT *t)
 
void drawResult (SDL_Surface *w, SUCCESS_TEXT *s, int result)
 
void cleanUp (LAYOUT *l, LAYOUT_TEXT *t, SUCCESS_TEXT *s)
 

Detailed Description

Contains every functions declaration for play.c.

Author
Maxime LEFEBVRE
Date
23/02/2018
Version
1.0

Definition in file play.h.

Function Documentation

◆ cleanUp()

void cleanUp ( LAYOUT l,
LAYOUT_TEXT t,
SUCCESS_TEXT s 
)

Free the allocated memory for every game related surfaces.

Parameters
lReference to the main general layout
tReference angle and speed texts
sReference to the results text

Definition at line 300 of file play.c.

◆ drawLayout()

void drawLayout ( SDL_Surface *  w,
LAYOUT l 
)

Draw the layout on the main window for each shot.

Parameters
wReference to the main window
lReference to the general layout

Definition at line 242 of file play.c.

◆ drawLine()

void drawLine ( LAYOUT l,
float  a 
)

Given an angle and a speed, define and draw the line that helps the player. Used functions : $ x = i * cos(a) $ $ y = l->line->h - (i * sin(a)) $

Parameters
lReference to the general layout
aAngle value set by the player, pre-shot

Definition at line 253 of file play.c.

◆ drawResult()

void drawResult ( SDL_Surface *  w,
SUCCESS_TEXT s,
int  result 
)

Draw the the result on the main window after each shot.

Parameters
wReference to the main window
sReference to the results text
resultControl variable, testing if the shot is a fail or not

Definition at line 276 of file play.c.

◆ drawText()

void drawText ( SDL_Surface *  w,
LAYOUT_TEXT t 
)

Draw the angle and speed texts on the main window.

Parameters
wReference to the main window
tReference angle and speed texts

Definition at line 268 of file play.c.

◆ loadFont()

void loadFont ( LAYOUT_TEXT t,
SUCCESS_TEXT s 
)

Load all the fonts needed for in-game display.

Parameters
tReference to the angle and speed texts
sReference to the results text

Definition at line 165 of file play.c.

◆ loadLayout()

void loadLayout ( LAYOUT l)

Load the game layout with background, ball, line, flag.

Parameters
lReference to the general layout

Definition at line 199 of file play.c.

◆ playGame()

void playGame ( SDL_Surface *  w)

Load the new game window so that the player can play.

Parameters
wReference to the main window

Definition at line 23 of file play.c.

◆ reloadLayout()

void reloadLayout ( LAYOUT l)

Reload the layout if the previous shot was missed.

Parameters
lReference to the general layout

Definition at line 234 of file play.c.

◆ setParameters()

void setParameters ( LAYOUT_TEXT t,
float  a,
float  sp 
)

Set the angle and speed values for display.

Parameters
tReference angle and speed texts
aAngle value set by the player, pre-shot
spSpeed value set by the player, pre-shot

Definition at line 191 of file play.c.

◆ shoot()

int shoot ( SDL_Surface *  w,
LAYOUT l,
float  a,
float  sp 
)

Determine the ball position from the start point until in touches the floor. Return 1 if the ball landed on the flag, 0 otherwise. Used function : $ y = (Y_START - l->object->h) - ((-0.5 * G * x^2) / cos(a)^2 * sp + tan(a) * x) $

Parameters
wReference to the main window
lReference to the general layout
aAngle value for the current shot
spSpeed value for the current shot

Definition at line 97 of file play.c.