changing
This commit is contained in:
parent
fef0d8cbe3
commit
f8b74bf43d
3 changed files with 13 additions and 10 deletions
|
|
@ -47,14 +47,13 @@ const int (*get_figure_shape(FigureType type, int rotation))[4] {
|
||||||
return shapes[type][rotation];
|
return shapes[type][rotation];
|
||||||
}
|
}
|
||||||
|
|
||||||
void userInput(UserAction_t action, bool hold) {
|
void user_input(UserAction_t action) {
|
||||||
(void)hold; // Подавляем предупреждение
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
memset(&game_state, 0, sizeof(game_state));
|
memset(&game_state, 0, sizeof(game_state));
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action >= Figure1 && action <= Figure5) {
|
if (action >= Figure1 && action <= Figure7) {
|
||||||
FigureType type = (FigureType)(action - Figure1);
|
FigureType type = (FigureType)(action - Figure1);
|
||||||
game_state.current_figure.type = type;
|
game_state.current_figure.type = type;
|
||||||
game_state.current_figure.x = FIELD_WIDTH / 2 - 2;
|
game_state.current_figure.x = FIELD_WIDTH / 2 - 2;
|
||||||
|
|
|
||||||
|
|
@ -46,15 +46,17 @@ typedef enum {
|
||||||
Up,
|
Up,
|
||||||
Down,
|
Down,
|
||||||
Action,
|
Action,
|
||||||
Figure1, // 1
|
Figure1,
|
||||||
Figure2, // 2
|
Figure2,
|
||||||
Figure3, // 3
|
Figure3,
|
||||||
Figure4, // 4
|
Figure4,
|
||||||
Figure5 // 5
|
Figure5,
|
||||||
|
Figure6,
|
||||||
|
Figure7
|
||||||
} UserAction_t;
|
} UserAction_t;
|
||||||
|
|
||||||
// Основные функции библиотеки
|
// Основные функции библиотеки
|
||||||
void userInput(UserAction_t action, bool hold);
|
void user_input(UserAction_t action);
|
||||||
GameStateData* getGameState(void);
|
GameStateData* getGameState(void);
|
||||||
|
|
||||||
const int (*get_figure_shape(FigureType type, int rotation))[4];
|
const int (*get_figure_shape(FigureType type, int rotation))[4];
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ int main() {
|
||||||
case '3': action = Figure3; break;
|
case '3': action = Figure3; break;
|
||||||
case '4': action = Figure4; break;
|
case '4': action = Figure4; break;
|
||||||
case '5': action = Figure5; break;
|
case '5': action = Figure5; break;
|
||||||
|
case '6': action = Figure6; break;
|
||||||
|
case '7': action = Figure7; break;
|
||||||
case KEY_LEFT: action = Left; break;
|
case KEY_LEFT: action = Left; break;
|
||||||
case KEY_RIGHT: action = Right; break;
|
case KEY_RIGHT: action = Right; break;
|
||||||
case KEY_DOWN: action = Down; break;
|
case KEY_DOWN: action = Down; break;
|
||||||
|
|
@ -37,7 +39,7 @@ int main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action != Undefined) {
|
if (action != Undefined) {
|
||||||
userInput(action, hold);
|
user_input(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
display_game();
|
display_game();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue