Mateo Gomez-Randulfe / Mbed 2 deprecated The_Children_of_Cronos

Dependencies:   mbed

Fork of The_Children_of_Cronos_el15mggr by ELEC2645 (2016/17)

Embed: (wiki syntax)

« Back to documentation index

hydralib Class Reference

hydralib Class Reference

hydralib Class More...

#include <hydralib.h>

Public Member Functions

 hydralib ()
 Constructor.
void init ()
 Function that initialises the values for the main positions.
bool border ()
 Function that checks if the snake touched the extremes of the screen or if it ate itself.
bool touch ()
 Function that checks if the snake head position is the same as any of his tail parts position ie if it ate itself.
void commands (Gamepad &pad, DigitalOut &a, DigitalOut &b, DigitalOut &x, DigitalOut &y)
 Allow player to move and changes velocity of movement depending on the players input.
void updatescr ()
 Updates the movement of the snake tail and head id the snake moves.
void draw (N5110 &lcd)
 Main draw function that draws all the component of the game.
void gameover (N5110 &lcd, DigitalOut &start, Gamepad &pad)
 Function that displays the game over screen and allows player to restart game once restarted,all values set to original ones.
void leds (Gamepad &pad)
 Function that switches only the same number of leds on as the same number of lifes the player still have left.
void velocities ()
 Function that sets the velocity of the game and the difficulty level the highest the score the faster the game will go and the more difficult.
void rectangles (N5110 &lcd)
 Function that draws a difficulty levels indicator in the bottom on the screen next to the score.
bool eat ()
 Function that checks if the position of the head and the food is relatively the same both of them are 3x3 rectangles.
void pausegame (DigitalOut &l, DigitalOut &r, N5110 &lcd, DigitalOut &back)
 Pauses the game.
void auxiliar ()
 Function that helps lately in the main file to generate food and increase score and lenght.
int score ()
 stores score

Detailed Description

hydralib Class

Library for the first game, Hydra Revision 1.3

Author:
Mateo Randulfe
Date:
May 2017

Definition at line 46 of file hydralib.h.


Constructor & Destructor Documentation

hydralib (  )

Constructor.

Definition at line 8 of file hydralib.cpp.


Member Function Documentation

void auxiliar (  )

Function that helps lately in the main file to generate food and increase score and lenght.

Definition at line 298 of file hydralib.cpp.

bool border (  )

Function that checks if the snake touched the extremes of the screen or if it ate itself.

Returns:
if it touches or not

Definition at line 174 of file hydralib.cpp.

void commands ( Gamepad pad,
DigitalOut &  a,
DigitalOut &  b,
DigitalOut &  x,
DigitalOut &  y 
)

Allow player to move and changes velocity of movement depending on the players input.

Parameters:
a/b/x/ydown,right,left and up
paddown,right,left and up

Definition at line 244 of file hydralib.cpp.

void draw ( N5110 lcd )

Main draw function that draws all the component of the game.

Parameters:
lcdfor drawing into the screen

Definition at line 190 of file hydralib.cpp.

bool eat (  )

Function that checks if the position of the head and the food is relatively the same both of them are 3x3 rectangles.

If any 2x2 parts of them are in contact it returns true if it would be all 3x3 it would be too difficult if it would be any 1x1 it would be too easy

Returns:
true if eated

Definition at line 74 of file hydralib.cpp.

void gameover ( N5110 lcd,
DigitalOut &  start,
Gamepad pad 
)

Function that displays the game over screen and allows player to restart game once restarted,all values set to original ones.

Parameters:
lcdfor drawing into the screen
startfor restarting the game
padfor putting leds off

Definition at line 51 of file hydralib.cpp.

void init (  )

Function that initialises the values for the main positions.

Definition at line 19 of file hydralib.cpp.

void leds ( Gamepad pad )

Function that switches only the same number of leds on as the same number of lifes the player still have left.

Parameters:
padcontrols leds

Definition at line 34 of file hydralib.cpp.

void pausegame ( DigitalOut &  l,
DigitalOut &  r,
N5110 lcd,
DigitalOut &  back 
)

Pauses the game.

Parameters:
l/r/lcdpauses the game and adds a p of pause in the screen

Definition at line 40 of file hydralib.cpp.

void rectangles ( N5110 lcd )

Function that draws a difficulty levels indicator in the bottom on the screen next to the score.

Definition at line 99 of file hydralib.cpp.

int score (  )

stores score

Returns:
score

Definition at line 13 of file hydralib.cpp.

bool touch (  )

Function that checks if the snake head position is the same as any of his tail parts position ie if it ate itself.

Returns:
if it touches or not

Definition at line 159 of file hydralib.cpp.

void updatescr (  )

Updates the movement of the snake tail and head id the snake moves.

Definition at line 227 of file hydralib.cpp.

void velocities (  )

Function that sets the velocity of the game and the difficulty level the highest the score the faster the game will go and the more difficult.

Definition at line 136 of file hydralib.cpp.