Recursion and minesweeper (java programming tutorial)

Поделиться
HTML-код
  • Опубликовано: 24 окт 2024

Комментарии • 34

  • @JackLe1127
    @JackLe1127  7 лет назад +7

    Guys this is really old and it's not a good practice anymore to avoid the keywords. Just name your functions and variables full readable names like "width", "height" or "resize".

  • @shackles5850
    @shackles5850 Год назад

    Thank you! I had a uni assignment with a similar minesweeper program, and I was really struggling with implementing recursion. Finally figured it out!

  • @alejandroivanlevinsonaguil389
    @alejandroivanlevinsonaguil389 5 лет назад +1

    Hey man I want to separate the logic from the GUI in two different packages but I´m having a rough time doing it cause once th code is done, once I run it it stops working right, could you help me with that plss?!

  • @bellymelo7901
    @bellymelo7901 8 лет назад

    In the video Recursion and minesweeper ( java programming tutorial ) . I would like you to explain how the implementation of the blocks using JToggleButton because when you run appears the blocks occupying all the spaces next to each other.

    • @JackLe1127
      @JackLe1127  8 лет назад

      The JToggleButtons are generated when you run the program. The code calculates the location and size of each button. That is not the best way actually. You should look into grid layout. That's the better way and it take less work

  • @NailujAgelliv
    @NailujAgelliv 6 лет назад +1

    Hi, one question, wouldn't it be better to create a new class that extends the JToggleButton and then give our new button the functionalyti to return it's posisttion in the blocks array?
    Casue then we wouldn't need to sweep the hole array to findo out wich button we clicked on. Great video btw, keep up the god work !

    • @JackLe1127
      @JackLe1127  6 лет назад

      Yeah that was not the best idea. You can actually to just store the JToggleButton inside a HashMap with the reference as the key and its index as the value.

  • @Irnt1
    @Irnt1 9 лет назад +1

    It's really helpful thanks a lot about this.
    bro can i ask about the minesweeper java exercise.
    It's basically minesweeper but added the extra "treasure" grids.
    each grid now displays (a/b) in stead of (a). For minesweeper its the a is the amount of bombs nearby. But now for this exercise a is the amount of "treasure" nearby and b is the amount of bombs nearby. If u click on all treasure grids u win. U click on bomb grid u lose.
    Can you give me some ideas about this.

    • @JackLe1127
      @JackLe1127  9 лет назад

      +Milano KT i think it will be the same. You technically just make 2 kinds of bombs and treat them the same but when user clicks on a treasure, he/she doesn't lose but earn some points

  • @atiqulislam4783
    @atiqulislam4783 7 лет назад +1

    did you create a method for jPanell when you used it at 22.26

    • @atiqulislam4783
      @atiqulislam4783 7 лет назад

      dw realised it was a 1 and not another l

    • @JackLe1127
      @JackLe1127  7 лет назад

      getWidth() and getHeight() are built-in jpanel methods.

  • @Geostalker
    @Geostalker 7 лет назад +1

    How would you go about adding difficulty into this though?

    • @JackLe1127
      @JackLe1127  7 лет назад +1

      More bombs :D

    • @Geostalker
      @Geostalker 7 лет назад

      lol i get more bombs...should have been more specific im saying if you would create a new menu beside game or something and called it difficulty or what not then you had 3 menu items for 3 types of difficulty how would you get that to function without having to write a lot more code since you already have wei and hei defined as 10 and 10 and bombs at 10 and at least 2 of the methods wouldn't work when you called them under another menu item like for open and spawn

    • @JackLe1127
      @JackLe1127  7 лет назад +1

      Geo stalker you can change those variables before you generate the board.

    • @Geostalker
      @Geostalker 7 лет назад

      i was trying that just testing some stuff out with your code and i couldnt get it to remake the board for some reason not sure what i was doing wrong ill play around with it a bit

    • @Geostalker
      @Geostalker 7 лет назад

      like remake as in instead of 9/9 i was trying to remake it under another menu item with 20/20
      with whatever amount of bombs but it was doing weird shit im still messing with it

  • @decemberblue9307
    @decemberblue9307 8 лет назад +1

    thnx alot for the game codes! it helped me with my project. But i happened to see one problem. I inserted pictures of the bomb to the blocks and it works perfectly fine however, if supposedly we did press on a mine and click new game, the pictures of the mine remains visible. what codes do i put in menu option to avoid this?

    • @JackLe1127
      @JackLe1127  8 лет назад

      +December Blue just loop through the buttons and remove the pictures.

  • @jesuswwwept
    @jesuswwwept 7 лет назад +1

    can i have your source code?

    • @jesuswwwept
      @jesuswwwept 7 лет назад

      pleaseee

    • @JackLe1127
      @JackLe1127  7 лет назад

      Isn't it in the description?

    • @jesuswwwept
      @jesuswwwept 7 лет назад

      Jack Le I figured it out. I don't know how to put icons in the bomb spaces though and I'm new to java too

    • @JackLe1127
      @JackLe1127  7 лет назад +1

      I think I answered it in one of the comment. I'm just going to copy and paste it here.
      just drag the image into the source code folder/package and to show the image on the button you can use:
      button.setIcon(new ImageIcon(getClass().getResource("mine-xp.gif")));
      mine-xp.gif is the name of the image. You should use either gif or png image to preserve the transparency of the background

    • @jesuswwwept
      @jesuswwwept 7 лет назад

      Jack Le thank youuuu