ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

RosenEngine/RosenEngine.cpp

Committer:
ikenna1
Date:
2019-04-10
Revision:
13:e114d362186d
Parent:
12:47578eb9ea73
Child:
14:88ca5b1a111a

File content as of revision 13:e114d362186d:

#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)
{
    if(_xcursor == 0){
        _ship.set_ship(9,6);
        _ship.draw_ship(lcd);
        _weapons.draw(lcd);
    }
    if(_xcursor == 1){
        _ship.set_ship(7,10);
        _ship.draw_imperion(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_ycursor();
}
void RosenEngine::title(N5110 &lcd)
{
    _menu.title(lcd); 
    _menu.update(_d);
}
int RosenEngine::get_ycursor()
{
    _ycursor = _menu.get_ycursor();
    return _ycursor;
}
int RosenEngine::get_xcursor()
{
    _xcursor = _menu.get_xcursor();
    return _xcursor;
}
void RosenEngine::ship_select(N5110 &lcd)
{
    _menu.update(_d);
    _menu.disp_ships(lcd);
}