ELEC2645 (2018/19) / Mbed 2 deprecated el17kz

Dependencies:   mbed

GameEngine/GameEngine.cpp

Committer:
kamtas
Date:
2019-05-09
Revision:
3:59e67155e2dd
Parent:
2:1900a4144537
Child:
4:7fca66882a00

File content as of revision 3:59e67155e2dd:

#include "GameEngine.h"

GameEngine::GameEngine()
{

}

GameEngine::~GameEngine()
{

}

void GameEngine::init(int runner_width,int runner_height, int obstacle_width, int obstacle_height)
{
    // initialise the game parameters
    _runner_width = runner_width;
    _runner_height = runner_height;
    
    _obstacle_width = obstacle_width;
    _obstacle_height = obstacle_height;

    // x position on screen - WIDTH is defined in N5110.h
    _rx = 20;
    
    _o1y = 32;
   // _o2y = 25;
    
    _r.init(_rx,_runner_height,_runner_width);
    
    _o1.init(_o1y,_obstacle_height,_obstacle_width);
}

void GameEngine::read_input(Gamepad &pad)
{
    _j = pad.check_event(Gamepad::Y_PRESSED);
}

void GameEngine::draw(N5110 &lcd)
{
    // draw the elements in the LCD buffer
    lcd.drawLine(0,FLOOR,WIDTH,FLOOR,1);
    
    _r.draw(lcd);
    
    _o1.draw(lcd);
}

void GameEngine::update(Gamepad &pad)
{
    _r.update(_j);
    
    _o1.update();
}