Steven Mahasin / Mbed 2 deprecated DreamDungeon

Dependencies:   mbed MotionSensor

Entity/Player/Player.h

Committer:
el17sm
Date:
2019-04-29
Revision:
27:a1b41626f57c
Parent:
23:5a8f75e93508
Child:
29:6b8411bb040a

File content as of revision 27:a1b41626f57c:

#ifndef PLAYER_H
#define PLAYER_H
#include "Entity.h"
#include "Bullets.h"

const int bullets_max = 20;

class Player : public Entity
{
private:

    // Member Variables
    int fire_rate_counter;
    int fire_rate_delay;
    int _bullet_speed;
    const static int invulnerability_period = 50;
    int invulnerability_counter;
    
public:
    // Constructors
    Player(float, float);
    // Deconstructors
    ~Player();

    // Functions
    virtual void move(float, float, int * map);
    virtual int * get_frame();
    virtual void take_damage(int);
    void buttons(bool, bool, bool, bool);
    int get_hearts_width();
    int get_hearts_height();
    int * get_hearts_sprite();

    // accessors
    int get_bullet_speed();

    // variables
    Bullets *bullets_array[bullets_max];
    bool valid_bullets[bullets_max];
    
};

// Sprite
const int sprite_heart[9][9] = {
    {0,1,1,0,0,0,1,1,0,},
    {1,1,1,1,0,1,1,1,1,},
    {1,2,1,1,1,1,1,1,1,},
    {1,2,1,1,1,1,1,1,1,},
    {1,2,1,1,1,1,1,1,1,},
    {0,1,2,1,1,1,1,1,0,},
    {0,0,1,1,1,1,1,0,0,},
    {0,0,0,1,1,1,0,0,0,},
    {0,0,0,0,1,0,0,0,0,}
};

const int sprite_dying_player [5][12][12] = { // sprite_dying_player [Frame][Size_Y][Size_X]
    {
        {0,1,1,1,1,0,0,0,0,0,0,0,},
        {1,1,1,1,1,1,0,0,0,0,0,0,},
        {1,2,1,1,1,1,0,0,0,0,0,0,},
        {1,1,1,1,1,1,0,0,0,0,0,0,},
        {0,1,1,1,1,0,0,0,0,0,0,0,},
        {0,0,1,1,0,0,0,0,0,0,0,0,},
        {0,0,1,1,0,0,0,0,0,0,0,0,},
        {0,0,1,1,0,0,0,0,0,0,0,0,},
        {0,0,1,1,0,0,0,0,0,0,0,0,},
        {0,0,0,1,0,0,0,0,0,0,0,0,},
        {0,0,0,1,0,0,0,0,0,0,0,0,},
        {0,0,1,1,0,0,0,0,0,0,0,0,},
    },
    {
        {0,0,0,0,1,1,1,0,0,0,0,0,},
        {0,0,0,1,2,1,1,1,0,0,0,0,},
        {0,0,0,1,1,1,1,1,0,0,0,0,},
        {0,0,0,1,1,1,1,1,0,0,0,0,},
        {0,0,0,0,1,1,1,0,0,0,0,0,},
        {0,1,1,1,1,0,0,0,0,0,0,0,},
        {0,0,1,1,1,0,0,0,0,0,0,0,},
        {0,0,1,1,0,0,0,0,0,0,0,0,},
        {0,1,1,1,0,0,0,0,0,0,0,0,},
        {0,1,0,1,0,0,0,0,0,0,0,0,},
        {1,0,0,1,0,0,0,0,0,0,0,0,},
        {0,0,1,1,0,0,0,0,0,0,0,0,},
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,1,0,0,0,1,1,1,0,},
        {0,0,0,0,0,1,0,1,1,2,1,1,},
        {0,0,0,0,0,1,1,1,1,1,1,1,},
        {0,0,0,1,1,1,1,1,1,1,1,1,},
        {0,1,1,1,1,1,1,0,1,1,1,0,},
        {1,0,0,1,1,0,0,0,0,0,0,0,},
        {0,0,1,0,0,0,0,0,0,0,0,0,},
        {0,1,0,0,0,0,0,0,0,0,0,0,},
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {1,0,0,0,1,0,0,0,1,1,1,0,},
        {0,1,1,0,0,1,1,1,1,2,1,1,},
        {1,0,0,1,1,1,1,1,1,1,1,1,},
        {1,1,1,1,1,1,1,1,1,1,1,1,},
    },
    {
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,0,0,0,0,},
        {0,0,0,0,0,0,0,0,1,1,1,0,},
        {0,0,0,0,0,0,0,1,1,1,1,1,},
        {1,0,0,1,1,1,1,1,1,1,1,1,},
        {1,1,1,1,1,1,1,1,1,1,1,1,},
    }
};
    

const int sprite_transparent_player[12][6] = {
    {0,0,0,0,0,0,},
    {0,0,0,0,0,0,},
    {0,0,0,0,0,0,},
    {0,0,0,0,0,0,},
    {0,0,0,0,0,0,},
    {0,0,0,0,0,0,},
    {0,0,0,0,0,0,},
    {0,0,0,0,0,0,},
    {0,0,0,0,0,0,},
    {0,0,0,0,0,0,},
    {0,0,0,0,0,0,},
    {0,0,0,0,0,0,}
};

const int sprite_player [4][4][12][6] = {   // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
    {
        // Up
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,1,1,1,1,1,},
            {1,1,1,1,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,1,1,0,},
            {1,0,1,1,0,1,},
            {1,0,1,1,0,1,},
            {0,0,1,1,0,0,},
            {0,1,0,0,1,0,},
            {0,1,0,0,1,0,}
        },
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,1,1,1,1,1,},
            {1,1,1,1,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,1,1,0,},
            {1,0,1,1,0,1,},
            {0,0,1,1,0,1,},
            {0,0,1,1,0,0,},
            {0,1,0,0,1,0,},
            {0,1,0,0,0,0,}
        },
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,1,1,1,1,1,},
            {1,1,1,1,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,1,1,0,},
            {1,0,1,1,0,1,},
            {1,0,1,1,0,1,},
            {0,0,1,1,0,0,},
            {0,1,0,0,1,0,},
            {0,1,0,0,1,0,}
        },
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,1,1,1,1,1,},
            {1,1,1,1,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,1,1,0,},
            {1,0,1,1,0,1,},
            {1,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,1,0,0,1,0,},
            {0,0,0,0,1,0,}
        }
    },
    {
        // Right
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,1,1,1,2,1,},
            {1,1,1,1,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,0,0,0,},
            {0,0,1,0,0,0,},
            {0,0,1,1,0,0,}
        },
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,1,1,1,2,1,},
            {1,1,1,1,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,0,1,0,},
            {0,1,0,0,1,0,},
            {0,1,0,0,0,1,}
        },
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,1,1,1,2,1,},
            {1,1,1,1,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,0,0,0,},
            {0,0,1,0,0,0,},
            {0,0,1,1,0,0,}
        },
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,1,1,1,2,1,},
            {1,1,1,1,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,0,1,0,},
            {0,1,0,0,1,0,},
            {0,1,0,0,0,1,}
        }
    },
    {
        // Down
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,2,1,},
            {1,1,2,2,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,1,1,0,},
            {1,0,1,1,0,1,},
            {1,0,1,1,0,1,},
            {0,0,1,1,0,0,},
            {0,1,0,0,1,0,},
            {0,1,0,0,1,0,}
        },
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,2,1,},
            {1,1,2,2,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,1,1,0,},
            {1,0,1,1,0,1,},
            {0,0,1,1,0,1,},
            {0,0,1,1,0,0,},
            {0,1,0,0,1,0,},
            {0,1,0,0,0,0,}
        },
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,2,1,},
            {1,1,2,2,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,1,1,0,},
            {1,0,1,1,0,1,},
            {1,0,1,1,0,1,},
            {0,0,1,1,0,0,},
            {0,1,0,0,1,0,},
            {0,1,0,0,1,0,}
        },
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,2,1,},
            {1,1,2,2,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,1,1,0,},
            {1,0,1,1,0,1,},
            {1,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,1,0,0,1,0,},
            {0,0,0,0,1,0,}
        }
    },
    {
        // Left
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,1,1,},
            {1,1,1,1,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,0,1,0,0,},
            {0,0,0,1,0,0,},
            {0,0,1,1,0,0,}
        },
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,1,1,},
            {1,1,1,1,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,1,0,1,0,0,},
            {0,1,0,0,1,0,},
            {1,0,0,0,1,0,}
        },
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,1,1,},
            {1,1,1,1,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,0,1,0,0,},
            {0,0,0,1,0,0,},
            {0,0,1,1,0,0,}
        },
        {
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,1,1,},
            {1,1,1,1,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,1,0,1,0,0,},
            {0,1,0,0,1,0,},
            {1,0,0,0,1,0,}
        }
    }
};

#endif