init
This commit is contained in:
parent
e117573d3b
commit
1feb55f404
6 changed files with 71 additions and 0 deletions
0
src/Makefile
Normal file
0
src/Makefile
Normal file
0
src/brick_game/tetris/fsm.c
Normal file
0
src/brick_game/tetris/fsm.c
Normal file
0
src/brick_game/tetris/tetris.c
Normal file
0
src/brick_game/tetris/tetris.c
Normal file
71
src/brick_game/tetris/tetris.h
Normal file
71
src/brick_game/tetris/tetris.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
#ifndef TETRIS_H
|
||||
#define TETRIS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
// Константы
|
||||
#define FIELD_WIDTH 10
|
||||
#define FIELD_HEIGHT 20
|
||||
#define NEXT_SIZE 4
|
||||
|
||||
// Типы фигур
|
||||
typedef enum {
|
||||
I = 0,
|
||||
J,
|
||||
L,
|
||||
O,
|
||||
S,
|
||||
T,
|
||||
Z,
|
||||
FIGURE_COUNT
|
||||
} FigureType;
|
||||
|
||||
// Состояния конечного автомата
|
||||
typedef enum {
|
||||
START,
|
||||
SPAWN,
|
||||
MOVING,
|
||||
SHIFTING,
|
||||
ATTACHING,
|
||||
GAME_OVER
|
||||
} GameState;
|
||||
|
||||
// Структура фигуры
|
||||
typedef struct {
|
||||
int x, y; // Позиция фигуры на поле
|
||||
FigureType type; // Тип фигуры
|
||||
int rotation; // Поворот (0–3)
|
||||
} Figure;
|
||||
|
||||
// Структура состояния игры
|
||||
typedef struct {
|
||||
int field[FIELD_HEIGHT][FIELD_WIDTH]; // Игровое поле
|
||||
Figure current_figure; // Текущая фигура
|
||||
Figure next_figure; // Следующая фигура
|
||||
int score; // Текущие очки
|
||||
int high_score; // Максимальные очки
|
||||
int level; // Уровень
|
||||
int lines_cleared; // Удалённые линии
|
||||
GameState state; // Текущее состояние КА
|
||||
bool paused; // Игра на паузе?
|
||||
} GameStateData;
|
||||
|
||||
// Ввод пользователя
|
||||
typedef enum {
|
||||
Start,
|
||||
Pause,
|
||||
Terminate,
|
||||
Left,
|
||||
Right,
|
||||
Up, // не используется
|
||||
Down,
|
||||
Action // вращение
|
||||
} UserAction_t;
|
||||
|
||||
// Основные функции библиотеки
|
||||
void userInput(UserAction_t action, bool hold);
|
||||
GameStateData* getGameState(void);
|
||||
void updateCurrentState(void);
|
||||
|
||||
#endif
|
||||
0
src/gui/cli/display.c
Normal file
0
src/gui/cli/display.c
Normal file
0
src/gui/cli/main.c
Normal file
0
src/gui/cli/main.c
Normal file
Loading…
Add table
Add a link
Reference in a new issue