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