Yufan Zhong / Mbed 2 deprecated GOLD_MINER

Dependencies:   mbed

main.cpp

Committer:
ZhongYufan
Date:
2020-05-10
Revision:
14:3731b0791970
Parent:
13:3299ab0ff2f0
Child:
19:08c582bcdc98

File content as of revision 14:3731b0791970:

/* 
ELEC2645 Embedded Systems Project 
School of Electronic & Electrical Engineering 
University of Leeds 

Name: Yufan Zhong
Username: el17yz
Student ID Number: 201199708
Date: May,2020

*/ 
 

///////// pre-processor directives ////////
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "MinerEngine.h"

#ifdef WITH_TESTING
# include "tests.h"
#endif

#define WINCH_WIDTH 12
#define WINCH_HEIGHT 6
#define CLAW_SPEED 3
#define MONSTER_SIZE 3
#define MONSTER_SPEED 1
#define GOLD_NUM 9
/////////////// structs /////////////////
struct UserInput {
    Direction d;
    float mag;
};
/////////////// objects ///////////////
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
MinerEngine miner;

///////////// prototypes ///////////////
void init();
void update_game(UserInput input);

void welcome();

///////////// functions ////////////////
int main()
{
     
#ifdef WITH_TESTING
    int number_of_failures = run_all_tests();

    if(number_of_failures > 0) return number_of_failures;
#endif

    //int fps = 8;  // frames per second

    init();     // initialise and then display welcome screen...
    welcome();  // waiting for the user to start
     // first draw the initial frame 
    //wait(1.0f/fps);  // and wait for one frame period


    // game loop - read input, update the game state and render the display
    while (1) {
        
         miner.state_switch(pad,lcd);
        //wait(1.0f/fps);
    }
}

// initialies all classes and libraries
void init()
{
    // need to initialise LCD and Gamepad 
    lcd.init();
    pad.init();
     
    // initialise the game with correct claw and winch sizes
    miner.init(WINCH_WIDTH,WINCH_HEIGHT,GOLD_NUM,MONSTER_SPEED);
    miner.init_unchanged_parameter();

}

// this function draws each frame on the LCD


// simple splash screen displayed on start-up
void welcome() {
    
    miner.welcome(pad,lcd);
    //miner.menu(pad,lcd);
    
}