A rouge-like rpg, heavily inspired on the binding of isaac. Running on a FRDM-K64F Mbed board. C++.

Dependencies:   mbed MotionSensor

Entity/Entity.h

Committer:
el17sm
Date:
2019-05-09
Revision:
57:1c12361b6e3d
Parent:
51:4d0cd75e7ed3
Child:
58:c8d90bb7404a

File content as of revision 57:1c12361b6e3d:

#ifndef ENTITY_H
#define ENTITY_H
#include "sprites.h"
#include "math.h"
#include "N5110.h"

class Entity
{
protected:
    struct Hitbox {
        int width;
        int height;
    };
    struct SpriteSize {
        int width;
        int height;
        // Top-left corner of sprite is offset_x
        // to the right of top-left corner of hitbox
        int offset_x;
        // Top-left corner of sprite is offset_y
        // above of top-left corner of hitbox
        int offset_y;
    };
    struct Position {
        float x;
        float y;
    };
    struct FrameCount  {
        int count;
        int number;
        int max;
    };
    Hitbox _hitbox;
    SpriteSize _sprite_size;
    Position _position;
    Position _prev_pos;
    FrameCount _frame;
    int _hp;
    int _attack;
    int _face;
    float _velocity;
    int _hp_drop_chance;

public:
    // Function
    virtual void move(float, float, char * map, bool * doorways) = 0; // movement control and miscellaneous updates
    virtual void take_damage(int) = 0;
    virtual void draw(N5110 &lcd) = 0;
    void undo_move_x(bool condition);
    void undo_move_y(bool condition);
    void update_prev_pos();
    bool entity_to_map_collision_test(float pos_x, float pos_y, char * two_d_map, bool * doorways);

    // Mutator
    void set_position(float x, float y);
    void position_add_x(float change_x);
    void position_add_y(float change_y);
    
    // Accessors
    int get_hp_drop_chance();
    int get_hitbox_width();
    int get_hitbox_height();
    int get_face();
    int get_sprite_width();
    int get_sprite_height();
    int get_offset_x();
    int get_offset_y();
    int get_pos_x();
    int get_pos_y();
    int get_prev_pos_x();
    int get_prev_pos_y();
    int get_attack();
    int get_hp();
    float get_velocity();

};

#endif