ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

RosenEngine/RosenEngine.cpp

Committer:
ikenna1
Date:
2019-04-09
Revision:
10:c33d7593a275
Parent:
9:241a1a7d8527
Child:
11:73cd744ffa80

File content as of revision 10:c33d7593a275:

#include "RosenEngine.h"


// Constructor
RosenEngine::RosenEngine()
{

}
// Destructor
RosenEngine::~RosenEngine()
{

}


void RosenEngine::init(int ship_width,int ship_height,int ship_speed,int ship_xpos,int ship_ypos)
{
    // initialise the game parameters
    _ship.init(ship_width,ship_height,ship_speed,ship_xpos,ship_ypos);
    _menu.init(16);
    
    
}

void RosenEngine::read_input(Gamepad &pad)
{
    Vector2D mapped_coord = pad.get_coord();
    _xjoystick = mapped_coord.x;
    _yjoystick = mapped_coord.y;
    _d = pad.get_direction();
   // printf("_xjoystick ,_yjoystick = %f , %f\n",_xjoystick, _yjoystick);
}

void RosenEngine::draw(N5110 &lcd)
{
    _ship.draw_ship(lcd);
    _weapons.draw(lcd);
}

void RosenEngine::update(Gamepad &pad)
{
    _ship.update_ship(_xjoystick,_yjoystick);
    _weapons.update();
   // _menu.update(_d);
}
void RosenEngine::get_pos()
{

    Vector2D ship_pos = _ship.get_pos();
    ship_xpos = ship_pos.x;
    ship_ypos = ship_pos.y;
    ship_width = 9;
    _weapons.init(ship_xpos, ship_ypos, ship_width);
    _ycursor = _menu.get_cursor();
}
void RosenEngine::title(N5110 &lcd)
{
    _menu.title(lcd); 
    _menu.update(_d);
}
int RosenEngine::get_cursor()
{
    _ycursor = _menu.get_cursor();
    return _ycursor;
}