2048-homework/src/2048.h

34 lines
603 B
C

#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#ifndef HEADER_2048
#define HEADER_2048
#define max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
typedef enum Direction {
NoDirection,
Up,
Down,
Right,
Left
} Direction;
typedef struct Game
{
uint32_t score;
size_t field_size_x, field_size_y;
uint16_t **field;
bool game_over;
bool won;
} Game;
Game game_init(size_t field_size_x, size_t field_size_y);
void game_move(Game *game, Direction direction);
void game_destroy(Game *game);
#endif