Subversion Repositories Code-Repo

Rev

Blame | Last modification | View Log | RSS feed

#ifndef TRON_H
#define TRON_H

#include "CUBE.h"

#define TRON_PLAYER_1_COLOR    GREEN
#define TRON_PLAYER_2_COLOR    PURPLE
#define TRON_PLAYER_1_HEAD     BLUE
#define TRON_PLAYER_2_HEAD     RED
#define TRON_COLLISION         ORANGE

typedef struct {
    unsigned x  :8;
    unsigned y  :8;
    unsigned z  :8;
    unsigned    :8;
} TRON_POINT;

typedef union {
    struct {
        unsigned up         :1;
        unsigned down       :1;
        unsigned right      :1;
        unsigned forward    :1;
        unsigned left       :1;
        unsigned backward   :1;
        unsigned            :2;
    };
    uint8_t value;
} TRON_P1_DIRECTION;

typedef union {
    struct {
        unsigned up         :1;
        unsigned down       :1;
        unsigned left       :1;
        unsigned backward   :1;
        unsigned right      :1;
        unsigned forward    :1;
        unsigned            :2;
    };
    uint8_t value;
} TRON_P2_DIRECTION;

typedef struct {
    TRON_POINT p1_body[CUBE_PIXELS];
    TRON_POINT p1_direction;
    uint8_t p1_last_direction;

    TRON_POINT p2_body[CUBE_PIXELS];
    TRON_POINT p2_direction;
    uint8_t p2_last_direction;
    
    uint32_t length;
    uint32_t delay;
} TRON_DATA;

void Tron_Init(TRON_DATA *data);
void Tron_Main(void);
void Tron_Update_Direction(uint8_t p1, uint8_t p2);
void Tron_Update_Frame(void);

#endif  /* TRON_H */