TETRIS IN UNITY - TUTORIAL

Поділитися
Вставка
  • Опубліковано 22 лис 2024

КОМЕНТАРІ •

  • @ElizaTheRaccoon
    @ElizaTheRaccoon 3 роки тому +5

    There's a fundamental bug in the latter half of this code that wasn't fixed: here's where it is, and how to resolve it. You'll need to edit your ClearLines() method in the GameLogic script. What's happening is that you're moving the lines down, incrementing Y without adjusting for the shifted blocks, and missing all cases where two lines of rows are completed adjacent to each other.
    This is my fixed method. I reversed the for loop, checking for completed blocks from the top down instead of the bottom up.
    public void ClearLines() {
    for (int y = height-1; y >= 0; y--) {
    if (IsLineComplete(y)) {
    DestroyLine(y);
    MoveLines(y);
    }
    }
    }

  • @Namklaww
    @Namklaww 4 роки тому +8

    I didn't get the blocks to move down correctly after clearing a line with your code, I may have done some things different that have impacted it, but I made it work with this:
    private static void MoveLines(int y)
    {
    for (int i = y; i < gameHeight - 1; i++)
    // The array goes out of bounds if you don't set -1,
    // since you check for the grid above in the second for loop
    {
    for (int x = 0; x < gameWidth; x++)
    {
    if (grid[x, i + 1] != null)
    // In the tutors code, the code only checks for the row above, now it checks every row
    {
    grid[x, i] = grid[x, i + 1];
    grid[x, i].gameObject.transform.position -= new Vector3(0, 1, 0);
    grid[x, i + 1] = null;
    }
    }
    }
    }
    private static void DestroyLine(int y)
    {
    for (int x = 0; x < gameWidth; x++)
    {
    Destroy(grid[x, y].gameObject);
    grid[x, y] = null;
    // Setting the cleared grid to null, then MoveLines will correct this if it got blocks above
    }
    }

    • @f.a.r4655
      @f.a.r4655 3 роки тому +1

      Thank you random citizen.

    • @CHTOUROU_BECHIR
      @CHTOUROU_BECHIR 3 роки тому

      Yeah but it works only with one full line at once, if we have two full lines it doesnt work ... it works only for the first line ...

  • @fabian5549
    @fabian5549 3 роки тому +3

    I finished your Tutorial but there are two big bugs:
    1. Blocks don't stop other blocks when they collide ob the right Side of the block.
    2. I cannot clear a line but I think that's because of the first one.
    There ist a problem in your video as well...54:14. The blue Line is buggy.

  • @حسنأبوالرحي
    @حسنأبوالرحي Рік тому

    Thank you very much, it is a very excellent explanation🎉

    • @حسنأبوالرحي
      @حسنأبوالرحي Рік тому

      // Function to check if the game is over
      public bool IsGameOver()
      {
      // Check the top row of the grid for any occupied cells
      for (int x = 0; x < gridWidth; x++)
      {
      if (grid[x, gridHeight - 1] != null)
      {
      return true; // If there's a block at the top, the game is over
      }
      }
      return false; // If the top row is empty, the game is not over
      }
      // ... (other TetrisManager code)
      // Call this function to check for game over conditions
      public void CheckGameOver()
      {
      if (IsGameOver())
      {
      // Implement game over logic here, such as displaying a game over screen or resetting the game.
      Debug.Log("Game Over!");
      }
      }

  • @incogneato420
    @incogneato420 3 роки тому +1

    So the ClearLine function (or it's helper functions) don't work correctly. If I have multiple complete lines, only the bottom most is cleared, and only the line directly above the cleared line moves down.
    Additionally, new blocks stop spawning after a line has been cleared.

  • @kaichristensen7984
    @kaichristensen7984 3 роки тому +1

    At the end of the video it still not working right...... when i had knew this before i went directly to other video from other guy

  • @shoyofilms
    @shoyofilms 3 роки тому +1

    54:12 something wrong when the blue bar hits the floor. anyway I shall figure out how to make it work by my one.

  • @Leo-uy1ic
    @Leo-uy1ic 3 роки тому +1

    i am a beginner and have a question...can we use collider to prevent moving through other blocks and use gravity to make objects fall and also will it be too much computationally intensive than the other method?.. gr8 video btw

    • @matercan5649
      @matercan5649 Рік тому

      The collider wouldn't be exact to the block and the script would need to work with every single block.

  • @puluntu
    @puluntu 2 роки тому

    When I try to spawn blocks randomly and save the source code, it says error: "Mathf" does not contain a definition for "floorToInt". What is happening?

  • @КонстантинЛактионов-щ1ю

    What about game like tetris but only clear not lines, but 3 blocks sequence, horizontal or vertical? Like game Puyo puyo ar columns or maybe match 3 games. How to recognize when 3 blocks are ready for destroy ? How to know that line complete in this case?

  • @alanmc9660
    @alanmc9660 3 роки тому +1

    Where to get score counter and level up plug ins? any idea? thanks for sharing!

  • @Manhsterz
    @Manhsterz 3 роки тому

    Thank you so much for your tutorial, very clear one !

    • @kaichristensen7984
      @kaichristensen7984 3 роки тому

      Its not working right......you see at the end of video still bucks...how do you fixed it?

  • @RebellonRM
    @RebellonRM 3 роки тому

    Some error with RegisterBlock method. And part of blocks destroy, but other parn will not. And in the left side i can't rotate. Something is wrong with the center of the blocks.

  • @4EyedOgre
    @4EyedOgre 3 роки тому

    is your scale setting for your grid set to unity default of 1? i get an error where im alway -.5 off on the y axis although all of my sprite centering. sprite sizes are identical to what you’ve shown in the lesson.

  • @david_jfrancisco
    @david_jfrancisco 3 роки тому

    I'm getting errors with the timer. Console error says that the name Timer does not exist in the current context.

    • @microdavid7098
      @microdavid7098 3 роки тому

      Are you finish ludum dare jam in 3 hours team? I've frankly gotten a bit lost in the tutorial a little. Halfway through before bugs bugged me

  • @potatolord2858
    @potatolord2858 3 роки тому

    That intro sounds familiar ;3

  • @365fun_public
    @365fun_public 3 роки тому

    very good!

  • @LigthFire
    @LigthFire 3 роки тому

    can we have the source code ?

  • @СеменМихайлов-ъ1н
    @СеменМихайлов-ъ1н 10 місяців тому

    54:13 Баг с линией, она провалилась, в Т фигуру..

  • @cscmusictv
    @cscmusictv 4 роки тому

    I tried the code but it doesn't work. I can't move the blocks.

    • @ClipperDev
      @ClipperDev  4 роки тому

      I’m sorry to hear that. Maybe you can pass your code either here or on discord so we can try to fix the issue?

    • @cscmusictv
      @cscmusictv 4 роки тому

      @@ClipperDev i sent an email to you

    • @ClipperDev
      @ClipperDev  4 роки тому

      Could you please send again? Nothing received, checked spam as well. I’ll see tomorrow if anything changes

    • @cscmusictv
      @cscmusictv 4 роки тому

      @@ClipperDev I sent you a Dropbox link to it, cause neither Gmail or Yahoo want me to send it.

    • @cscmusictv
      @cscmusictv 4 роки тому

      @@ClipperDev I sent you an email with a link to my Tetris code

  • @aikou2886
    @aikou2886 3 роки тому

    17:17 Did you do something off camera again? I was able to keep up with the sudden changes until this point. The piece won't move if I run the test.
    EDIT: Somehow I was able to get the piece to move and didn't have the out of bound error you had, which is really weird.

  • @difoldery
    @difoldery 3 роки тому +2

    You russian? =)

    • @ClipperDev
      @ClipperDev  3 роки тому +1

      Niet, Polak

    • @ClipperDev
      @ClipperDev  3 роки тому +1

      Pierogi

    • @difoldery
      @difoldery 3 роки тому +1

      @@ClipperDev ooo, Polish is a dialect of Russian, its my opinion.I can tell by your accent that you're not English man. But you have very good content, you cool ;)

  • @aleksandraaleksandra7934
    @aleksandraaleksandra7934 Рік тому

    Cześć Clipper!
    Dzięki za Twój tutorial :) Udało mi się w przyjemny sposób zrobić gierkę oraz poprawić kilka drobnych błędów, które wkradły się w Twój film (w podobny sposób co w komentarzach poniżej, więc nie będę powtarzała). Niestety wciąż mam ten błąd: Index was outside the bounds of the array.
    Prześledziłam kod i wydaje mi się (właściwie jestem pewna, że mam tak jak u Ciebie). Wklejam fragmenty kodu, w których wywala błąd. Może wiesz, co jest nie tak?
    bool CheckValid()
    {
    foreach (Transform subBlock in rig.transform)
    {

    if(subBlock.transform.position.x >= GameLogic.width ||
    subBlock.transform.position.x