Yufan Zhong / Mbed 2 deprecated GOLD_MINER

Dependencies:   mbed

MinerEngine/MinerEngine.h

Committer:
ZhongYufan
Date:
2020-05-12
Revision:
16:e3ecfcd2a389
Parent:
14:3731b0791970
Child:
17:3ba4ec25c4c5

File content as of revision 16:e3ecfcd2a389:

#ifndef MINERENGINE_H
#define MINERENGINE_H

#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
#include "Claw.h"
#include "Winch.h"
#include "Monster.h"
#include "Gold.h"

// gap from edge of screen
#define GAP 2

/** MinerEngine Class
@author Yufan Zhong, University of Leeds and SWJTU
@brief Class for the structure of the game
@brief It includes the control input, menu and other display parts(welcome,select,gameover,etc)
@date May 2020
*/ 

class MinerEngine
{

public:
    /** Constructor */
    MinerEngine();
    /** Destructor */
    ~MinerEngine();
    /** Initialise the components of the MinerEngine
    *
    *   This function initialises the components of the MinerEngine.
    *   @param  winch_width - the width of the winch
    *   @param  winch_height - the height of the winch
    *   @param  gold_num - the gold number
    *   @param  monster_speed - the speed of monster
    */
    void init(int winch_width,int winch_height,int gold_num,int monster_speed);
    /** Initialise the unchanged parameter
    *
    *   This function initialises the unchanged parameter.
    */
    void init_unchanged_parameter();
    /** Switch the states
    *
    *   This function switches the states.
    *   @param  pad - Gamepad library
    *   @param  lcd - N5110 library
    */
    void state_switch(Gamepad &pad, N5110 &lcd);
     /** Get the select
    *
    *   This function gets the select from the gamepad.
    *   @param  pad - Gamepad library
    */
    int get_select(Gamepad &pad);
     /** Print the instruction
    *
    *   This function prints the instruction on the screen.
    *   @param  pad - Gamepad library
    *   @param  lcd - N5110 library
    */
    void instruction(Gamepad &pad, N5110 &lcd);
     /** Print the menu
    *
    *   This function prints the menu on the screen.
    *   @param  pad - Gamepad library
    *   @param  lcd - N5110 library
    */
    void menu(Gamepad &pad, N5110 &lcd);
     /** Select the difficulties
    *
    *   This function selects the difficulties.
    *   @param  pad - Gamepad library
    *   @param  lcd - N5110 library
    */
    void options(Gamepad &pad, N5110 &lcd);
     /** Run the game
    *
    *   This function runs the game loop.
    *   @param  pad - Gamepad library
    *   @param  lcd - N5110 library
    */
    void game_run(Gamepad &pad, N5110 &lcd);
     /** Draw all the components
    *
    *   This function draws winch, claw, gold and monster on the screen.
    *   @param  lcd - N5110 library
    */
    void draw(N5110 &lcd);
     /** Read the gamepad input
    *
    *   This function raed the gamepad input.
    *   @param  pad - Gamepad library
    */
    void read_input(Gamepad &pad);
     /** Update the data
    *
    *   This function update all data components.
    *   @param  pad - Gamepad library
    */
    void update(Gamepad &pad);
     /** Print welcome component and wait for start
    *
    *   This function prints welcome component on the screen.
    *   @param  pad - Gamepad library
    *   @param  lcd - N5110 library
    */
    void welcome(Gamepad &pad, N5110 &lcd);
     /** Print game over on the screen
    *
    *   This function prints game over on the screen.
    *   @param  pad - Gamepad library
    *   @param  lcd - N5110 library
    */
    void game_over(Gamepad &pad, N5110 &lcd);
     /** Play the music
    *
    *   This function plays the music.
    *   @param  pad - Gamepad library
    */
    void play_music(Gamepad &pad);
     /** Roll up the picture
    *
    *   This function rolls up the picture.
    *   @param  pad - Gamepad library
    *   @param  lcd - N5110 library
    */
    void screen_rollup(Gamepad &pad, N5110 &lcd);
     /** Print loading on the screen
    *
    *   This function prints loading on the screen.
    *   @param  pad - Gamepad library
    *   @param  lcd - N5110 library
    */
    void loading(Gamepad &pad, N5110 &lcd);
     /** Play the tunnel animation on the screen
    *
    *   This function plays the tunnel animation on the screen.
    *   @param  pad - Gamepad library
    *   @param  lcd - N5110 library
    */
    void tunnel(Gamepad &pad, N5110 &lcd);
     /** Draw the tunnel
    *
    *   This function draws the tunnel.
    *   @param  lcd - N5110 library
    */
    void draw_tunnel(N5110 &lcd);
     /** Draw the walking man
    *
    *   This function draws the walking man.
    *   @param  lcd - N5110 library
    */
    void draw_man(N5110 &lcd);
     /** Print message in the tunnel
    *
    *   This function prints the message on the screen.
    *   @param  pad - Gamepad library
    *   @param  lcd - N5110 library
    */
    void tunnel_print(Gamepad &pad, N5110 &lcd);
    
    
private:

     /** Check if the gold has been lifted
    *
    *   This function checks if the gold has been lifted.
    *   @param  pad - Gamepad library
    */
    void check_gold_collision(Gamepad &pad);
     /** Check if the monster collides with claw
    *
    *   This function checks if the monster collides with claw.
    *   @param  pad - Gamepad library
    */
    void check_monster_collision(Gamepad &pad);
     /** Check if the claw gets the gold or the bottom
    *
    *   This function checks if the claw gets the gold or the bottom.
    *   @param  pad - Gamepad library
    */
    void check_claw_collision(Gamepad &pad);
     /** Check if gold reloading is needed
    *
    *   This function checks if gold reloading is needed.
    */
    void check_gold_reload();
     /** Print the score on the screen 
    *
    *   This function prints the current score and highest score on the screen.
    *   @param  lcd - N5110 library
    */
    void print_scores(N5110 &lcd);
  
    Winch _winch;
    Claw _claw;
    Gold _gold;
    Monster _monster;
    
    int _winch_width;
    int _winch_height;
    int _gold_num;
    float _monster_speed;
    int _s;
    int _state;
    int _catching;
    int _claw_get;
    int _claw_speed;
    int _monster_collision;
    int _now_score;
    int _highest_score;
    int _gold_reached_num[9];
    int _h;
    int _i;
    int _n;
    int _z;
    int _j;
    
    Direction _d;
    float _mag;
    
};

#endif