ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el19zf

Dependencies:   mbed

shot/shot.h

Committer:
el19zf
Date:
2020-05-15
Revision:
15:3571beaaeed8
Parent:
13:eb60628db8bf
Child:
16:cf2bfada3adf

File content as of revision 15:3571beaaeed8:

#ifndef SHOT_H
#define SHOT_H

#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include <vector>
#include <time.h>
#include <stdlib.h>

/** shot class
@set several kinds of shot and come from all around
@author Zeyu Feng
@13 April 2020
*/
/**struct of shot position type and direction*/
struct shot_posandtype {
    int x;
    int y;
    int type;
    int dir;
};

class shot
{

public:

    /**constructor*/
    shot();
    /**destructor*/
    ~shot();
    /**generate first 10 shots*/
    void init();
    
    /**produce a random_pos(21,0)(42,0)(63,0)(21,45)(42,45)(63,45)
    *@param vector_i(shot_posandtype*)
    */
    void init_pos(shot_posandtype *i);
    
    /**move shots in their own directions*/
    void update();
    
    /**generate shots as time goes on*/
    void update_shot();
    
    /**draw updated shots*/
    void draw(N5110 &lcd);
    
    /**if beyoud border, delete it and generate new one, keep total number constant*/
    void delete_shot();
    /**control difficulty of game(size)
    *@param timerflag(int)
    *@param increment(float)
    *@param max(int)
    */
    void gen_shot(int timer_flag, float increment, int max);

    /**accessors  resize shots
    *@param size(int)
    */
    void set_size(int size);
    
    void set_shot(int x, int y, int type, int Direction);

    /**mutators get size
    *@return current size
    */
    int get_size();
    
    Vector2D get_shot();

private:
    std::vector<shot_posandtype> _p;
    int _size;
    float _size_f;
    Vector2D _shot_pos;
};
#endif