Steven Mahasin / Mbed 2 deprecated DreamDungeon

Dependencies:   mbed MotionSensor

Entity/Mobs/Snake/Snake.h

Committer:
el17sm
Date:
2019-05-09
Revision:
54:03ddad11d202
Parent:
36:92d131695e7c
Child:
55:fc618f82d1d0

File content as of revision 54:03ddad11d202:

#ifndef SNAKE_H
#define SNAKE_H
#include "Entity.h"

class Snake : public Entity
{

public:
    // Constructor
    Snake(float, float);

    // Functions
    virtual void move(float, float, char * map, bool * doorways);
    virtual void take_damage(int);
    virtual void draw(N5110 &lcd);

private:
    // Member Function
    void update_prev_face();
    char * get_frame();
    void update_face(float diff_x, float diff_y);
    void move_snake();
    void increment_frame();

    // Member Mutator
    void update_hitbox(int, int, int, int, int, int, int);

    // Member Variable
    int _velocity_index;
    int _prev_face;

};

const float snake_velocity_pattern[6] = {0, 0.15, 0.25, 0.35, 0.25, -0.1};

const char sprite_snake_x[2][4][7][12] = {   // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
    {
        // Right
        {
            {0,0,0,0,0,0,0,0,1,1,1,0,},
            {0,0,0,0,0,0,0,1,1,1,2,1,},
            {0,0,0,0,0,0,0,1,1,1,1,1,},
            {0,0,0,0,0,0,0,1,1,1,0,0,},
            {0,0,0,0,0,0,0,0,1,1,1,0,},
            {0,0,1,1,1,1,0,1,1,1,1,0,},
            {1,1,1,0,1,1,1,1,1,1,0,0,},
        },
        {
            {0,0,0,0,0,0,0,0,1,1,1,0,},
            {0,0,0,0,0,0,0,1,1,1,2,1,},
            {0,0,0,0,0,0,0,1,1,1,1,1,},
            {0,0,0,0,0,0,0,1,1,1,0,0,},
            {0,0,0,0,0,0,0,0,1,1,1,0,},
            {0,1,1,1,1,0,1,1,1,1,1,0,},
            {1,0,0,1,1,1,1,1,1,1,0,0,},
        },
        {
            {0,0,0,0,0,0,0,0,1,1,1,0,},
            {0,0,0,0,0,0,0,1,1,1,2,1,},
            {0,0,0,0,0,0,0,1,1,1,1,1,},
            {0,0,0,0,0,0,0,1,1,1,0,0,},
            {1,0,0,0,0,0,0,0,1,1,1,0,},
            {0,1,0,0,1,1,1,1,1,1,1,0,},
            {0,0,1,1,1,0,1,1,1,1,0,0,},
        },
        {
            {0,0,0,0,0,0,0,0,1,1,1,0,},
            {0,0,0,0,0,0,0,1,1,1,2,1,},
            {0,0,0,0,0,0,0,1,1,1,1,1,},
            {0,0,0,0,0,0,0,1,1,1,0,0,},
            {0,0,0,0,0,0,0,0,1,1,1,0,},
            {1,1,0,1,1,1,1,1,1,1,1,0,},
            {0,0,1,1,0,1,1,1,1,1,0,0,},
        }
    },
    {
        // Left
        {
            {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,},
            {0,0,1,1,1,0,0,0,0,0,0,0,},
            {0,1,1,1,0,0,0,0,0,0,0,0,},
            {0,1,1,1,1,0,1,1,1,1,0,0,},
            {0,0,1,1,1,1,1,1,0,1,1,1,},
        },
        {
            {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,},
            {0,0,1,1,1,0,0,0,0,0,0,0,},
            {0,1,1,1,0,0,0,0,0,0,0,0,},
            {0,1,1,1,1,1,0,1,1,1,1,0,},
            {0,0,1,1,1,1,1,1,1,0,0,1,},
        },
        {
            {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,},
            {0,0,1,1,1,0,0,0,0,0,0,0,},
            {0,1,1,1,0,0,0,0,0,0,0,1,},
            {0,1,1,1,1,1,1,1,0,0,1,0,},
            {0,0,1,1,1,1,0,1,1,1,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,},
            {0,0,1,1,1,0,0,0,0,0,0,0,},
            {0,1,1,1,0,0,0,0,0,0,0,0,},
            {0,1,1,1,1,1,1,1,1,0,1,1,},
            {0,0,1,1,1,1,1,0,1,1,0,0,},
        }
    }
};

const char sprite_snake_y[2][6][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,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,1,0,0,},
            {0,1,1,0,0,0,},
            {0,0,1,1,0,0,},
            {0,0,0,1,1,0,},
            {0,0,0,1,1,0,},
            {0,0,1,1,0,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,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
            {0,1,1,0,0,0,},
            {0,1,1,0,0,0,},
            {0,0,1,1,0,0,},
            {0,0,0,1,1,0,},
            {0,0,0,0,1,0,},
            {0,0,1,1,0,0,},
        },
        {
            {0,1,1,1,1,0,},
            {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,0,0,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,0,0,0,},
            {0,1,1,0,0,0,},
            {0,0,1,1,0,0,},
            {0,0,0,0,1,0,},
            {0,0,0,1,0,0,},
        },
        {
            {0,1,1,1,1,0,},
            {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,0,1,1,1,0,},
            {0,0,0,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,0,0,0,},
            {0,1,1,0,0,0,},
            {0,0,1,1,0,0,},
            {0,0,0,0,1,0,},
        },
        {
            {0,1,1,1,1,0,},
            {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,0,1,1,0,0,},
            {0,0,0,1,1,0,},
            {0,0,0,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,0,0,0,},
            {0,1,0,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,1,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,0,0,0,},
            {0,0,1,1,0,0,},
            {0,0,0,1,1,0,},
            {0,0,0,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,0,0,0,0,},
            {0,0,1,0,0,0,},
        }
    },
    {
        // Down
        {
            {0,0,0,0,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,0,0,0,},
            {0,1,1,0,0,0,},
            {0,0,1,1,0,0,},
            {0,0,0,1,1,0,},
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,2,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,1,0,0,0,0,},
            {0,1,1,0,0,0,},
            {0,0,1,1,0,0,},
            {0,0,0,1,1,0,},
            {0,0,0,1,1,0,},
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,2,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
        },
        {
            {0,0,1,0,0,0,},
            {0,1,0,0,0,0,},
            {0,0,1,1,0,0,},
            {0,0,0,1,1,0,},
            {0,0,0,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,2,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
        },
        {
            {0,1,0,0,0,0,},
            {0,0,1,1,0,0,},
            {0,0,0,1,1,0,},
            {0,0,0,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,0,0,0,},
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,2,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,0,0,1,0,},
            {0,0,0,1,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,0,0,0,},
            {0,1,1,0,0,0,},
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,2,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
        },
        {
            {0,0,0,1,0,0,},
            {0,0,0,0,1,0,},
            {0,0,1,1,0,0,},
            {0,1,1,0,0,0,},
            {0,1,1,0,0,0,},
            {0,0,1,1,0,0,},
            {0,1,1,1,1,0,},
            {1,1,1,1,1,1,},
            {1,2,1,1,2,1,},
            {0,1,1,1,1,0,},
            {0,0,1,1,0,0,},
            {0,0,1,1,0,0,},
        }
    }
};

#endif