Browse Source

Merge tetris from https://github.com/xMasterX/all-the-plugins

Willy-JL 9 tháng trước cách đây
mục cha
commit
50c3c45135
2 tập tin đã thay đổi với 13 bổ sung1 xóa
  1. 1 1
      tetris/.gitsubtree
  2. 12 0
      tetris/tetris_game.c

+ 1 - 1
tetris/.gitsubtree

@@ -1 +1 @@
-https://github.com/xMasterX/all-the-plugins dev base_pack/tetris_game 4558d74c9da36abc851edd96a95d18f7d5511a75
+https://github.com/xMasterX/all-the-plugins dev base_pack/tetris_game a8a849220002299b2e9900ef4b2c415f64afcfcd

+ 12 - 0
tetris/tetris_game.c

@@ -85,6 +85,7 @@ typedef struct {
     Piece currPiece;
     uint16_t numLines;
     uint16_t fallSpeed;
+    bool hardDropping;
     GameState gameState;
     FuriTimer* timer;
     FuriMutex* mutex;
@@ -276,6 +277,7 @@ static void tetris_game_init_state(TetrisState* tetris_state) {
     tetris_state->gameState = GameStatePlaying;
     tetris_state->numLines = 0;
     tetris_state->fallSpeed = MAX_FALL_SPEED;
+    tetris_state->hardDropping = false;
     memset(tetris_state->playField, 0, sizeof(tetris_state->playField));
     memset(tetris_state->bag, 0, sizeof(tetris_state->bag));
 
@@ -412,6 +414,8 @@ static void
         if(tetris_game_piece_at_bottom(tetris_state, newPiece)) {
             furi_timer_stop(tetris_state->timer);
 
+            tetris_state->hardDropping = false;
+
             tetris_game_render_curr_piece(tetris_state);
             uint8_t numLines = 0;
             uint8_t lines[] = {0, 0, 0, 0};
@@ -521,12 +525,20 @@ int32_t tetris_game_app() {
             }
         }
 
+        if(tetris_state->hardDropping) {
+            for(int i = 0; i < 4; i++) {
+                newPiece->p[i].y += 1;
+            }
+            wasDownMove = true;
+        }
+
         if(event_status == FuriStatusOk) {
             if(event.type == EventTypeKey) {
                 if(event.input.type == InputTypePress || event.input.type == InputTypeLong ||
                    event.input.type == InputTypeRepeat) {
                     switch(event.input.key) {
                     case InputKeyUp:
+                        tetris_state->hardDropping = true;
                         break;
                     case InputKeyDown:
                         break;