ELEC2645 (2018/19) / Mbed 2 deprecated el17arm

Dependencies:   mbed

Sprites/Sprites.h

Committer:
el17arm
Date:
2019-04-15
Revision:
40:913339e324b8
Parent:
38:55bb9da08a52
Child:
41:0cf320f73424

File content as of revision 40:913339e324b8:

#ifndef SPRITES_H
#define SPRITES_H

#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
//#include "rtos.h"

const int miner_right[24] =   {
        1,1,1,
        1,1,0,
        1,1,1,
        0,1,0,
        1,1,1,
        1,1,1,
        0,1,0,
        0,1,1,

    };

    const int miner_left[24] =   {
        1,1,1,
        0,1,1,
        1,1,1,
        0,1,0,
        1,1,1,
        1,1,1,
        0,1,0,
        1,1,0,
    };

const int enemy[15] =   {
        
        1,1,1,
        1,0,1,
        1,1,1,
        0,1,0,
        1,1,1,
    };
    
const int key[12] =   {
        1,1,0,0,
        1,0,1,1,
        1,1,0,1,
    };

const int key_collected[12] =   {
        
        0,0,0,0,
        0,0,0,0,
        0,0,0,0,
    };
    
const int spike[9] =   {
        
        1,0,1,
        0,1,0,
        1,0,1,
    };
    
const int solid_block[18] =   {
        
        1,1,1,1,1,1,
        1,0,1,1,0,1,
        1,1,1,1,1,1,
    };
    
const int door[30] = {
        
        1,1,1,1,1,
        1,0,1,0,1,
        1,1,0,1,1,
        1,0,1,0,1,
        1,1,0,1,1,
        1,0,1,0,1,
};

///////structs for sprites detection///////////////////

struct keyed {
    bool key[5];
    double kx[5];
    double ky[5];
};

struct enemies_init {
    bool eflag[5];
    double ex[5];
    double ey[5];
    int counter[5];
    int distance[5];
};


////////structs for populating levels//////////////////

struct Enemies {
    bool f[5];
    double ex[5];
    double ey[5];
    int c[5];
    int d[5];
    double v[5];

};

struct Traps {
    double tx[5];
    double ty[5];
};

struct Keys {
    double kx[5];
    double ky[5];
};

struct Solid_blocks {
    double bx[5];
    double by[5];
};

struct Soft_blocks {
    double sx[5];
    double sy[5];
    int sz[5];
};

struct Level_exit {
    double lx[5];
    double ly[5];
};

class Sprites
{

public:
    
    Sprites();
    ~Sprites();
    
    void miner_init(int x, int y);
    int miner_move(Direction d, N5110 &lcd);
    void miner_draw(N5110 &lcd);
    void miner_gravity(N5110 &lcd);
    int miner_jump(N5110 &lcd, Gamepad &pad);
    void miner_land(N5110 &lcd);
    
    void enemy_init(int i, int x, int y, int d);
    void enemy_move(int i, double v, N5110 &lcd);
    bool enemy_collision(int i);
    
    void key_collect(int k, int x, int y, N5110 &lcd, Gamepad &pad);
    int keys_collected();
    
    bool exit_level(int x, int y, N5110 &lcd);
    
    bool trap(int x, int y, N5110 &lcd);
    void blocks(Direction d, int x, int y, N5110 &lcd);
    void soft_blocks(int x, int y, int z, N5110 &lcd);
    
    Vector2D get_pos();

    keyed _k;

private:

    int _direction;
    int _gravity;
    bool _jump;
    int _y;
    int _x;
    bool _j_flag;
    int _j_counter;
    
    bool block[5];
    bool right_collision;
    bool left_collision;
    
    bool _collision;
    int _keys;
    
    double bx[5];
    double by[5];

    bool _key[5];
    double kx[5];
    double ky[5];
    
    enemies_init _enem;
    
    
};
#endif