Minesweeper in 100 minutes - React JS Game

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ม.ค. 2025

ความคิดเห็น • 17

  • @buyerinsight
    @buyerinsight ปีที่แล้ว +1

    10:23 createboard
    18:31 createboard (full)
    24:42 designing Cell component
    50:50 reveal.js

  • @w1nd251
    @w1nd251 ปีที่แล้ว +1

    Too many code in reveal.js. Simply use recursive function that will spread from clicked square to all the directions till the bombs

    • @w1nd251
      @w1nd251 ปีที่แล้ว +1

      You have 150 lines of code, it can be done in 30

    • @eduriseworld
      @eduriseworld  ปีที่แล้ว

      @w1nd251 that is interesting to see.
      Have you done it so far?

    • @eduriseworld
      @eduriseworld  ปีที่แล้ว

      @w1nd251 I would love to see it too. Yes agree for sure can be done in a recursive manner, but I wanted to focus on the iterative approach at the time of creating this video.

    • @w1nd251
      @w1nd251 ปีที่แล้ว

      const mark = (board: Square[][], x: number, y: number) => {
      try{
      if(board[x][y].revealed === true){
      return;
      }
      if(board[x][y].value === 0){
      board[x][y].revealed = true;
      }
      if(board[x][y].value !== 0 && board[x][y].value !== -1){
      board[x][y].revealed = true;
      return;
      }
      // top row
      mark(board, x - 1, y - 1)
      mark(board, x - 1, y)
      mark(board, x - 1, y + 1)
      //left and right
      mark(board, x, y - 1)
      mark(board, x, y + 1)
      // bottom row
      mark(board, x + 1, y - 1)
      mark(board, x + 1, y)
      mark(board, x + 1, y + 1)
      return board;
      } catch (e){
      return;
      }
      }@@eduriseworld

    • @w1nd251
      @w1nd251 ปีที่แล้ว

      I call this function once before checking if I did not click on the bomb and everything works perfectly. Try catch for "array out of bound exception"@@eduriseworld

  • @kacper6107
    @kacper6107 4 ปีที่แล้ว +1

    great turorial, are you sure that generate Bomb cant generate duplicate coords?

    • @eduriseworld
      @eduriseworld  4 ปีที่แล้ว

      Yes 100% positive, the logic is in createBoard.js. Can you tell why it won't generate duplicate coords based on the code?

    • @kacper6107
      @kacper6107 4 ปีที่แล้ว +1

      @@eduriseworld i created board 10x10 with 90 bombs and had duplicate. I think that reveal function could be written much faster, look :D
      const Reveal = (grid, x, y, mapSize, nonMineCount) => {
      if(grid[x][y].value === 0)
      {
      for(let i=-1; i = 0 && x < mapSize && y >= 0 && y < mapSize){
      return true;
      }
      else{
      return false;
      }
      }
      export default Reveal;

    • @eduriseworld
      @eduriseworld  4 ปีที่แล้ว

      @@kacper6107 let me check that.

  • @ReAgent003
    @ReAgent003 3 ปีที่แล้ว

    Thank you, nice video!

  • @MaxProgramming
    @MaxProgramming 4 ปีที่แล้ว +1

    Wait what! 🤯

  • @gamershome1100
    @gamershome1100 4 ปีที่แล้ว +1

    8th