ELEC2645 (2018/19) / Mbed 2 deprecated fy14lkaa

Dependencies:   mbed

SpaceEngine/SpaceEngine.cpp

Committer:
fy14lkaa
Date:
2019-05-05
Revision:
125:b83378770171
Parent:
124:77f379153715
Child:
126:c63c5ad39f73

File content as of revision 125:b83378770171:

#include"SpaceEngine.h"

SpaceEngine::SpaceEngine()
{
}
SpaceEngine::~SpaceEngine()
{
}



void SpaceEngine::init(int x_spaceship,int y_spaceship, int x_bullet, int y_bullet,int fired_bullet, int x_alien,int y_alien, int speed_alien, int speed_bullet, int speed_spaceship)
{

    _x_spaceship=x_spaceship;
    _y_spaceship=y_spaceship;
    _x_bullet=x_bullet;
    _y_bullet=y_bullet;
    _fired_bullet= fired_bullet;
    _x_alien= x_alien;
    _y_alien= y_alien;
    _speed_alien= speed_alien;
    _speed_bullet=speed_bullet;
    _speed_spaceship=speed_spaceship;
    _bullet.init(_x_bullet, _y_bullet, speed_bullet,fired_bullet);
    _alien.init (_x_alien, _y_alien,_speed_alien);
    _spaceship.init( _x_spaceship, _y_spaceship, _speed_spaceship);
}

void SpaceEngine::read_input(Gamepad &pad)
{

    _d = pad.get_direction();
    _mag = pad.get_mag();

}



void  SpaceEngine::draw(N5110 &lcd)
{
    _bullet.draw(lcd);
    _alien.draw(lcd);
    _spaceship.draw(lcd);
}



void  SpaceInvadersEngine::update(Gamepad &pad)
{
    check_goal(pad);
    bullet1.update();
    space_ship1.update(_d,_mag);

    alien.update();

    check_Alien_collision(pad);
    checkspace_ship_collisions(pad);


}

void SpaceEngine::update(Gamepad &pad)
{
    _bullet.update(_d,_mag);
    _alien.update(_d,_mag);
    _spaceship.update(_d,_mag);
    if(_d==E){
        _fired_bullet=1;
            //_x_bullet=11;
            //_y_bullet=y;
            _bullet.set_pos(_spaceship.get_pos_x()+11, _spaceship.get_pos_y());
        }
    
    
}