ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18jkeo

Dependencies:   mbed

SpaceInvaderEngine/SpaceInvaderEngine.h

Committer:
josh_ohara
Date:
2020-05-18
Revision:
33:d8284dee58db
Parent:
24:ff5af5a013b5
Child:
35:517b56b010df

File content as of revision 33:d8284dee58db:

#ifndef SPACEINVADERENGINE_H
#define SPACEINVADERENGINE_H

#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
#include "Ship.h"
#include "Armada.h"
#include "Cover.h"
#include <vector>

#define BORDER 2

class SpaceInvaderEngine
{

public:
    SpaceInvaderEngine();
    ~SpaceInvaderEngine();
    void init(int ship_height, int ship_width, int alien_size, int no_aliens, int armada_column_size, int armada_row_size, int cover_y, int cover1_x, int cover2_x, int cover3_x, int no_rocks, int level); //initialise all needed objects and set private member variables
    void read_input(Gamepad &pad);                                              //read the gamepad input (buttons and joystick)
    void update(Gamepad &pad, N5110 &lcd, int counter, int level);              //update all objects 
    void render(N5110 &lcd);                                                    //draw all objects
    void ship_bullet_alien_collision(Gamepad &pad, N5110 &lcd);                 //check for collision between the ship bullets and the aliens
    void ship_bullet_cover1_collision(Gamepad &pad, N5110 &lcd);                //check for collision between the ship bullets and cover 1
    void ship_bullet_cover2_collision(Gamepad &pad, N5110 &lcd);                //check for collision between the ship bullets and cover 2
    void ship_bullet_cover3_collision(Gamepad &pad, N5110 &lcd);                //check for collision between the ship bullets and cover 3
    void alien_bullet_ship_collision(Gamepad &pad, N5110 &lcd);                 //check for collision between the alien bullets and the ship
    void alien_bullet_cover3_collision(Gamepad &pad, N5110 &lcd);               //check for collision between the alien bullets and cover 3
    void alien_bullet_cover1_collision(Gamepad &pad, N5110 &lcd);               //check for collision between the alien bullets and cover 1
    void alien_bullet_cover2_collision(Gamepad &pad, N5110 &lcd);               //check for collision between the alien bullets and cover 2
    void alien_ship_collision(Gamepad &pad, N5110 &lcd);                        //check for collision between the aliens and the ship
    void alien_cover1_collision(Gamepad &pad, N5110 &lcd);                      //check for collision between the aliens and cover 1
    void alien_cover2_collision(Gamepad &pad, N5110 &lcd);                      //check for collision between the aliens and cover 2
    void alien_cover3_collision(Gamepad &pad, N5110 &lcd);                      //check for collision between the aliens and cover 3
    //accessors and mutators//
    void get_ship_pos();                                                        //return the position of ths ship
    bool get_armada_life();                                                     //return the life value of the alien armada
    bool get_ship_life();                                                       //return the life value of the ship
    void kill_all();                                                            //set life value of all objects to 0
 
private:

    Armada _armada;                                                             //armada (vector of aliens) object
    Ship _ship;                                                                 //ship object
    BulletS _ship_bullets;                                                      //ship bullet vector
    Cover _cover_1;                                                             //cover object (vector of rocks)
    Cover _cover_2;                                                             //cover object (vector of rocks)
    Cover _cover_3;                                                             //cover object (vector of rocks)
    
    int _ship_height;                                                           //height of ship
    int _ship_width;                                                            //width of ship
    int _alien_size;                                                            //size of alien
    int _alien_number;                                                          //number of aliens
    int _armada_column_size;                                                    //number of of aliens per column of armada
    int _armada_row_size;                                                       //number of aliens per row of armada
    
    int _ship_x;                                                                //x position of ship
    int _ship_y;                                                                //y position of ship
    int _cover_y;                                                               //y position of covers
    int _cover_1_x;                                                             //x position of cover 1
    int _cover_2_x;                                                             //x position of cover 2
    int _cover_3_x;                                                             //x position of cover 3
    int _rock_number;                                                           //number of rocks per cover
        
    
    Direction D;                                                                //direction of joystick
    float _mag;                                                                 //magnitude of joystick offset
};

#endif