Mochu Yao explorer game

Dependencies:   mbed

Gameengine/Gameengine.h

Committer:
el17my
Date:
2020-04-27
Revision:
10:559487aac60e
Parent:
9:e11bb7cef050
Child:
13:30330d61f09c

File content as of revision 10:559487aac60e:

#ifndef GAMEENGINE_H
#define GAMEENGINE_H

//* @the enginee file has these functions
//  1 make the whole explorer game run and set the score the reset process
//  2 cheak the collision and the reset or fall flag
//  3 draw on the lcd screen and load the gamepad controll
//* @date April 24th 2020
//* @author Yaomochu

/** Gameengine Class
@code
#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
#include "Gameengine.h"

N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad gamepad;
Gameengine _game_engine;

bool _start_flag;
int _player_score;

int main() {
    _game_engine.init();
    while(1) {
        _game_engine.check_reset(lcd, gamepad);
        _start_flag = _game_engine.get_start_flag();
        _game_engine.read_input(gamepad);
        _game_engine.get_sprite();
        _game_engine.get_explorer_direction();
        _game_engine.get_explorer_y(gamepad);
        _game_engine.get_explorer_x();
        _game_engine.generate_lines();
        _game_engine.check_collision(gamepad);
        _game_engine.update_lcd(lcd);
        _player_score = _game_engine.get_score();
        _game_engine.run_engine(lcd, gamepad); 
        }
}

@endcode
*/


#include "N5110.h"
#include "mbed.h"
#include "Gamepad.h"
#include "item.h"
#include "explorer.h"
#include "surface.h"
#include <cstdlib>
#include <ctime>

struct Coordinate {
  Vector2D coord; /**< Vector 2D for joystick coords */ 
  };
  
class Gameengine {
 // Constructor and destructor.
public:
Gameengine();
~Gameengine();
//first init all the parameter
    void init();
    void reset_game_engine();
    void read_input(Gamepad &pad);
    void check_reset(N5110 &lcd, Gamepad &gamepad);
    void check_collision(Gamepad &gamepad);
    void check_start(N5110 &lcd, Gamepad &gamepad);
    void set_fall_flag();
    bool get_start_flag();
    void generate_lines();
    int  get_score();
    void get_explorer_direction();
    void get_sprite();
    void get_explorer_y(Gamepad &gamepad);
    void get_explorer_x();
    void update_lcd(N5110 &lcd);
    void run_engine(N5110 &lcd, Gamepad &gamepad);


private:
Coordinate _coordinate;
item _item;
Explorer _player;
Surface _surface;
    bool X_flag;
    int _player_x;
    int _player_y;
    bool _collision_flag;
    bool _f_flag;
    bool _r_flag;
    bool _start_flag;
    int  _speed;
    int _jump_height;
    int _player_score;
Line set_line_1;
Line set_line_2;
Line set_line_3;
Line line_1_value;
Line line_2_value;
Line line_3_value;
Line line_4_value;
Line line_5_value;
Line line_6_value;
Player_direction _player_direction;
Explorer_sprite _explorer_sprite; 
};
#endif