Harry Rance 200925395 Embedded Systems Project

Dependencies:   mbed

main.cpp

Committer:
harryrance
Date:
2017-04-11
Revision:
0:c9bf674fe0c7
Child:
1:95d7dd44bb0d

File content as of revision 0:c9bf674fe0c7:

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

#define SHIELD_X 0
#define SHIELD_Y 0
#define US_X 0
#define AA_X 2
#define SPEED 1

////////// structs //////////
struct UserInput {
  Direction d;
  float mag;
};

////////// objects //////////
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
GameEngine engine;

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

////////// functions //////////
int main()
{
  int fps = 30;

  init();
  render();
  wait(1.0f/fps);

  while(1){
    engine.read_input(pad);
    engine.update(pad);
    render();
    wait(1.0f/fps);
  }
}

void render()
{
  lcd.clear();
  engine.draw(lcd);
  lcd.refresh();
}

void init()
{
  lcd.init();
  pad.init();

  engine.initialise(SHIELD_X, SHIELD_Y, US_X, AA_X, SPEED);

}