FINAL VERSION

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

BreakoutEngine Class Reference

BreakoutEngine Class Reference

BreakoutEngine Class. More...

#include <BreakoutEngine.h>

Public Member Functions

 BreakoutEngine ()
 Constructor declaration.
 ~BreakoutEngine ()
 Destructor declaration.
void init (int paddle_width, int paddle_height, int ball_size, int speed)
 Initialises game variables.
void read_input (Gamepad &pad)
 Reads inputs from the Gamepad.
void update (Gamepad &pad)
 Updates the Game attributes.
void draw (N5110 &lcd)
 Draws the objects' at their respective coordinates on the LCD.
void lives_leds (Gamepad &pad)
 Updates the Gamepad LEDs with lives remaining.
void set_prev_score (int prev_score)
 Sets the variable _prev_score to current score.
void inc_index ()
 Increments the laser index.
void reset_index ()
 Resets the laser index to 0.
void reset_game ()
 Returns the game (and all relevant objects) to initialised state.
void reset_num_left ()
 Sets the variable _number_left to 18.
void inc_mult ()
 Increment the multiplier if continue is selected upon victory.
void reset_mult ()
 Resets the multiplier to 0.
void set_paddle_motion (bool tilt, float sens)
 Sets the paddle motion options for use in game.
void check_life_powerup ()
 Sets the powerup to a random x position on screen if conditions are met.
void reset_paddle_lives ()
 Resets the paddle lives to 6, used to reset the game.
void dec_num_left ()
 Decrements the number of bricks left on screen when one is destroyed.
int get_num_left ()
 Returns the number of Bricks remaining on screen.
int get_prev_score ()
 Returns the score achieved on victory in the previous iteration of the game.
int get_paddle_lives ()
 Returns the number of lives remaining.
int get_mult ()
 Returns the current multiplier value.
bool check_loss (Gamepad &pad)
 Checks if the ball goes past the screen y boundary.
int get_score ()
 Returns the current score to print to LCD in the game.

Detailed Description

BreakoutEngine Class.

Author:
James Heavey, University of Leeds Controls the Breakout game
Date:
May 2019

Definition at line 27 of file BreakoutEngine.h.


Constructor & Destructor Documentation

Constructor declaration.

Definition at line 3 of file BreakoutEngine.cpp.

Destructor declaration.

Definition at line 8 of file BreakoutEngine.cpp.


Member Function Documentation

void check_life_powerup (  )

Sets the powerup to a random x position on screen if conditions are met.

Definition at line 461 of file BreakoutEngine.cpp.

bool check_loss ( Gamepad pad )

Checks if the ball goes past the screen y boundary.

Parameters:
pada Gamepad pointer
Returns:
a bool; true if ball is off screen, false

Definition at line 421 of file BreakoutEngine.cpp.

void dec_num_left (  )

Decrements the number of bricks left on screen when one is destroyed.

Definition at line 495 of file BreakoutEngine.cpp.

void draw ( N5110 lcd )

Draws the objects' at their respective coordinates on the LCD.

Parameters:
lcda N5110 pointer

Definition at line 162 of file BreakoutEngine.cpp.

int get_mult (  )

Returns the current multiplier value.

Returns:
_multiplier

Definition at line 519 of file BreakoutEngine.cpp.

int get_num_left (  )

Returns the number of Bricks remaining on screen.

Returns:
_number_left

Definition at line 489 of file BreakoutEngine.cpp.

int get_paddle_lives (  )

Returns the number of lives remaining.

Returns:
the paddle variable _lives

Definition at line 549 of file BreakoutEngine.cpp.

int get_prev_score (  )

Returns the score achieved on victory in the previous iteration of the game.

Returns:
_prev_score

Definition at line 477 of file BreakoutEngine.cpp.

int get_score (  )

Returns the current score to print to LCD in the game.

Returns:
_score

Definition at line 507 of file BreakoutEngine.cpp.

void inc_index (  )

Increments the laser index.

Definition at line 531 of file BreakoutEngine.cpp.

void inc_mult (  )

Increment the multiplier if continue is selected upon victory.

Definition at line 513 of file BreakoutEngine.cpp.

void init ( int  paddle_width,
int  paddle_height,
int  ball_size,
int  speed 
)

Initialises game variables.

Parameters:
paddle_widthinteger width of paddle
paddle_heightinteger height of paddle
ball_sizeinteger diameter of ball in pixels
speedinteger initial speed of ball

Definition at line 13 of file BreakoutEngine.cpp.

void lives_leds ( Gamepad pad )

Updates the Gamepad LEDs with lives remaining.

Parameters:
pada Gamepad pointer

Definition at line 204 of file BreakoutEngine.cpp.

void read_input ( Gamepad pad )

Reads inputs from the Gamepad.

Parameters:
pada Gamepad pointer

Definition at line 118 of file BreakoutEngine.cpp.

void reset_game (  )

Returns the game (and all relevant objects) to initialised state.

Definition at line 90 of file BreakoutEngine.cpp.

void reset_index (  )

Resets the laser index to 0.

Definition at line 537 of file BreakoutEngine.cpp.

void reset_mult (  )

Resets the multiplier to 0.

Returns:
_prev_score

Definition at line 525 of file BreakoutEngine.cpp.

void reset_num_left (  )

Sets the variable _number_left to 18.

Definition at line 501 of file BreakoutEngine.cpp.

void reset_paddle_lives (  )

Resets the paddle lives to 6, used to reset the game.

Definition at line 543 of file BreakoutEngine.cpp.

void set_paddle_motion ( bool  tilt,
float  sens 
)

Sets the paddle motion options for use in game.

Parameters:
tilta bool that sets tilt if true and joystick if false
sensa float that is derived from the pot, it multiplies the velocity of the paddle

Definition at line 438 of file BreakoutEngine.cpp.

void set_prev_score ( int  prev_score )

Sets the variable _prev_score to current score.

Parameters:
prev_scorethe new previous score which is the score achieved at victory

Definition at line 483 of file BreakoutEngine.cpp.

void update ( Gamepad pad )

Updates the Game attributes.

Parameters:
pada Gamepad pointer

Definition at line 182 of file BreakoutEngine.cpp.