ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

RosenEngine/RosenEngine.h

Committer:
ikenna1
Date:
2019-05-09
Revision:
50:69fc9b5e3335
Parent:
49:aa204bf7ee2e
Child:
51:2231e2e141b9

File content as of revision 50:69fc9b5e3335:

#ifndef ROSENENGINE_H
#define ROSENENGINE_H

#include "mbed.h"
#include <ctime>
#include "N5110.h"
#include "Gamepad.h"
#include "Ship.h"
#include "Weapons.h"
#include "Menu.h"
#include "Enemy.h"
#include "Health.h"
#include "Lore.h"

/** RosenEngine Class
@brief Library that used all other game libraries in order to make game functions
@author Ozoemena Adrian Ikrnna
@date 8th May 2019
*/
class RosenEngine
{

public:
    /** constructor */
   RosenEngine();
   /** deconstructor */
    ~RosenEngine();
    
    /** A mutator method that initializes ship size and speed, the default ship is the kestrel
    *@param ship_width, the width of the ship
    *@param ship_height, the height of the ship
    *@param ship_speed, the speed of the ship
    *@param ship_xpos, the ship's x co-ordinate
    *@param ship_ypos, the ship's y co-ordinate
    */
    void init(int ship_width,int ship_height,int ship_speed,int ship_xpos,int ship_ypos);
    /** A mutator method that resets some key values that neet to be reinitialized when the player
    *returns to the ment
    */
    void reset();
    /** An accessor method that reads the input from the gamepad
    *@param &pad pointer to the gamepad library used to read inputs and send outputs to the gamepad
    */
    void read_input(Gamepad &pad);
    /** A mutator method that updates all position and variable values based on inputs and the
    * time that has passed
    *@param &pad pointer to the gamepad library used to read inputs and send outputs to the gamepad
    */
    void update(Gamepad &pad);
    /** Draws all game assets on lcd display
    *@param &lcd pointer to the N5110 library used for the lcd display
    *@param &pad pointer to the gamepad library used to read inputs and send outputs to the gamepad
    */
    void draw(N5110 &lcd, Gamepad &pad);
    /** An accessor method that gets the position of all important game objects on screen
    */
    void get_pos();
    /** Displays the title screen on the lcd
    *@param &lcd pointer to the N5110 library used for the lcd display
    */
    void title(N5110 &lcd);
    /** An accessor method that gets the ycursor value to be used in the menu
    *@returns the  ycursor value
    */
    int get_ycursor();
    /** A mutator method used to set the ship being used in the game.
    * either the kestrel, the imperion or the orion
    *@returns the ship being used
    */
    SHIP set_shipUsed();
    /** Displays the ship option in the menu to allow player switch ships
    *@param &lcd pointer to the N5110 library used for the lcd display
    */
    void ship_select(N5110 &lcd);
    /** A mutator method that checks the enemies and players health. it resets an enemy if
    * its health falls to 0 and sets dead to true if the players health falls to 0.
    * either the kestrel, the imperion or the orion
    */
    void check_health();
    /** Calulates the amount of time past in seconds 
    *@param fps, the frames per second.
    */
    float timer(int fps);
    /** An accessor method that returns true when a player dies
    */
    bool dead();
    /** Displays the intro to the game 
    *@param &lcd pointer to the N5110 library used for the lcd display
    */
    void intro(N5110 &lcd);
    /** An accessor method used to get the current number of the two enemies, seeker and shooter, on screen
    @returns a 2D vector of the enemy numbers with the .x referring to shooters and the .y referring to seekers
    */
    Vector2D get_enemynum();

    //*** note: add ship width and ship heirgth in place of 6 and 9 to generalize arrays after they are finished
    
private:
    /** A mutator method that updates the shooters projectile position
    *@param &pad pointer to the gamepad library used to read inputs and send outputs to the gamepad
    */
    void update_shooter_weapon(Gamepad &pad);
    /** Draws the appropriate ship based on shipUsed (the ship being used)
    *@param &lcd pointer to the N5110 library used for the lcd display
    *@param &pad pointer to the gamepad library used to read inputs and send outputs to the gamepad
    */
    void draw_ship(N5110 &lcd, Gamepad &pad);
    /** A mutator function that changes ship_width appropriate ship based on shipUsed (the ship being used)
    */
    void set_ship_size();
    /** A mutator function that changes the players score
    *@param points, the amount of points the player scored
    */
    void score(int points);
    /** Checks for a collision between two 2D objects
    *@param xpos1, the x co-ordinate of the first object
    *@param ypos1, the y co-ordinate of the first object
    *@param width1, the width of the first object
    *@param height1, the height of the first object
    *@param xpos2, the x co-ordinate of the second object
    *@param ypos2, the y co-ordinate of the second object
    *@param width2, the width of the second object
    *@param height2, the height of the second object
    */
    bool check_collision(int xpos1, int ypos1,int width1,int height1,int xpos2, int ypos2,int width2,int height2);
    /** Checks if two objects positione intersect across a vertical line
    *used for the imperion weapon collisions
    *@param xpos1, the x co-ordinate of the first object
    *@param width1, the width of the first object
    *@param xpos2, the x co-ordinate of the second object
    *@param width2, the width of the second object
    */
    bool check_collision1(int xpos1,int width1,int xpos2,int width2);
    /** Checks if a seeker and the player ship collided
    *@param &pad pointer to the gamepad library used to read inputs and send outputs to the gamepad
    */
    void seeker_ship_collision(Gamepad &pad);
    /** Checks if a shooter and the player ship collided
    *@param &pad pointer to the gamepad library used to read inputs and send outputs to the gamepad
    */
    void shooter_ship_collision(Gamepad &pad);
    /** Checks if a shooter's projectile and the player ship collided
    *@param &pad pointer to the gamepad library used to read inputs and send outputs to the gamepad
    */
    void shooterw_ship_collision(Gamepad &pad);
    /** Checks if the kestrel ships's projectile and the seeker collided
    *@param &pad pointer to the gamepad library used to read inputs and send outputs to the gamepad
    */
    void kestrelw_seeker_collision(Gamepad &pad);
    /** Checks if the Imperions lazer and the seeker collided
    *@param &pad pointer to the gamepad library used to read inputs and send outputs to the gamepad
    */
    void imperionw_seeker_collision(Gamepad &pad);
    /** Checks if the kestrel ships's projectile and the shooter collided
    *@param &pad pointer to the gamepad library used to read inputs and send outputs to the gamepad
    */
    void kestrelw_shooter_collision(Gamepad &pad);
    /** Checks if the Imperions lazer and the shooter collided
    *@param &pad pointer to the gamepad library used to read inputs and send outputs to the gamepad
    */
    void imperionw_shooter_collision(Gamepad &pad);
    /** Checks if the orions weapon collided with any enemy
    *@param &pad pointer to the gamepad library used to read inputs and send outputs to the gamepad
    */
    void orionw_collision(Gamepad &pad);
    /** Gradually increased the difficulty of the game over time
    *@param time_elapsed, the amount of time since the player selected play from menu
    */
    void scaling(float time_elapsed);
    /** Generates a random number using the <ctime> library
    *@returns a random number
    */
    int rand_no();
    /** Displays a random tip on lcd
    *@param &lcd pointer to the N5110 library used for the lcd display
    */
    void game_over(N5110 &lcd);
    /** Displays the points the player has on screen
    *@param &lcd pointer to the N5110 library used for the lcd display
    */
    void disp_points(N5110 &lcd);
    /** Checks the seekers health
    */
    void check_se_health();
    /** Checks the shooter health
    */
    void check_sh_health();
    /** Finds the average distance between two points on the 2D screen
    *@param x1 the x co-ordinate of the first point
    *@param y1 the y co-ordinate of the first point
    *@param x2 the x co-ordinate of the second point
    *@param y2 the y co-ordinate of the second point
    *@returns the distance between the two points
    */
    int range(int x1, int y1, float x2, float y2);
    /** Finds the closest enemy ship to the player's ship on screen
    *@ returns the index and distance of closest enemy ship
    */
    Vector2D find_closest1();
    /** An accessor function that finds the position of the closest enemy on screen to ship
    *@param index, the index number of the closest ship (0-3) for shooter and (4-6) dor seekers
    *@returns the position of the closest enemy
    */
    Vector2D find_closest2(int index);
    
    
    // Variables
    
    Ship _ship;
    Weapons _weapons;
    Menu _menu;
    Enemy _enemy;
    Health _health;
    Lore _lore;
    Vector2D _joystick;
    Direction _d;
    SHIP _shipUsed;
    int _ycursor;
    int _shipno;
    int _score;
    int _shno;
    int _shipWidth;
    int _shipHeight;
    Vector2D _shipPos;
    Vector2D _shooterPos[3];
    Vector2D _shooterWPos[3];
    Vector2D _seekerPos[3];
    Vector2D _coloc;
    bool _dead;
    int _times_run;
    int _no_shooters;
    int _no_seekers;
    bool _intro;
    float _wait_time;
    

};
/************STUFF TO FIX******************************
**** add sound effects for sjield braking
**** add passive shield regeneration
**** work on score increase
**** add title screen with name
**** make it so back asks you if you are sure and ststes that you will lose all progress
**** think of level system
**** orion should send out pulses that stun enemy ships and absorb thier shields(use draw line)
**** scale shields properly
**** fix the border issue(i.e the ships clip through healthbar)
**** make it so enemy ship spawning is random use srand
**** add in options for lcd brightness and contrast
**** add in cheats
**** 
*/
#endif
/*
changes not commited
*Fix game playing in background
*Change seeker damage to 175
*make seeker health 5
* implement a viewing system for enemy ships
* enemy comes from below very fast
* if you hold a button shields come up in front but not sides
* 
*
*/