JavaFX Game: Minesweeper

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

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

  • @zoaltamam
    @zoaltamam 3 года назад +1

    I am so glad I found this channel!
    It is exciting to follow your thought process while coding. This shows the true nature of a programmer's thought process.

    • @AlmasB0
      @AlmasB0  3 года назад

      Thanks, glad you are finding these useful.

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

    Thank you so much, you're an amazing person and coder. You've made the video very easy to follow and the code very easy to scale bigger.

  • @NaDennIsGut
    @NaDennIsGut 6 лет назад +2

    seriously man your style of making tutorials is very good! short compact information-perfect!

  • @khreed
    @khreed 9 лет назад +2

    The java 8 functional programming was very interesting, thanks!

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

      +khreed Glad you liked it

  • @OwnerOfTheCosmos
    @OwnerOfTheCosmos 9 лет назад +2

    Thanks, that was very informative,concise, and had no annoyances at all. (Volume was just right for me.) Will look into using the stream features. I only used Lambdas in the default scenarios so far and the unbelievably kickass feature that method references are. This was a nice taste of JavaFX, that's what I mainly watched it for - I know it's rather the present than the future, but I'm still a Swing guy.
    I would have made a method that retrieves a tile at a coordinate - or null if there is no tile there - instead of doing that whole 1d-array-that-represents-2d-and-stuff thing, would have stored the return value into a temp variable, then added to neighbors list if not null. Also, I think it's better to always call your return values "ret", to indicate their infrastructural role, to distinguish them from other variables you might have in a method.
    Finally, and I'm serious, I pitied you when you entered the variable names - I don't know it like that, I just type the first few letters and then press Tab because IntelliJ (Community Edition is free, feature-rich, and can legally be used for any commercial project.) suggests variable names in the autocomplete list. Same for for loops: I just type fori, press tab, and then enter the proper variable name because of IntelliJ's Live Templates (which you can extend yourself, but fori and iter (Enhanced for loops.) is a default). Btw., Eclipse has sysout which you can autocomplete to System.out.println, which in IntelliJ via its Live Templates would be sout and then Tab. - I heartily recommend that you take a look at IntelliJ IDEA www.jetbrains.com/idea/download/ I used Eclipse for about two years, then tried IntelliJ for a day, *never* looked back, except to feel even more comfortable about the choice. You can also (usually) switch back and forth at any time. I also told a coworker about IntelliJ when I tried it and stuck to it years ago. He now finally decided to try it himself, mentions the advantages almost every day (sitting across from me).

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

      +God, creator of the universe Hi, thank you for your feedback, much appreciated. Yes will definitely take a look at IntelliJ.

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

    Thanks alot, I got minesweeper as my school year homework, had about 3 months to do it, but since i dont understand programming for shit, i just copied this and it works, thanks alot dude

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

      btw how do you select bombs or end the game ?

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

      holy shit, 3 months? All I have is a week, lol

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

    Hey mate I want to program the same Minesweeper game with some differences regarding to dynamic size. So in other words these 3 rules should be respected:
    1. The squares should always stay squares (even though the size can change by changing the size of the scene).
    2. All squares should always be shown no matter how small the user resizes the scene.
    3. The rectangular playing-field should use as much space as the pane allows it.
    Could you please help me out with an idea? I'm pretty new to javaFx :-) What do I need to change in your code, so that the 3 rules are accomplished?
    Thanks in advance! Keep it up - love your vids!

  • @orlandomota5938
    @orlandomota5938 2 года назад

    Thank You dude

  • @Ataraxia-Trading
    @Ataraxia-Trading 5 лет назад +1

    Thank u for the code. That's perfect

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

    Hi that was a nice tutorial. I just ahve one question please.You used a function in which you create the root node so I can't use the varialble root directly. What if I want to add a canvas to this node?

    • @AlmasB0
      @AlmasB0  7 лет назад +2

      Hi, you can create the root node outside the function and simply return the reference from the function. This will allow you to increase the scope of the "root" variable.

  • @ΜανώληςΧατζηαλεξιου

    hello, really nice video i wanted to ask where in the code you insert the bombs to the tile.

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

    hey, someone is adding these to Reddit's java subreddit. So when people make comments on it, the comments are not going to you to discuss, but to whoever it is who posts them. It would be better if you posted them yourself.

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

      +Bill McGecko Hi, thanks for letting me know, will pop in there from time to time

  • @shrootisingh5338
    @shrootisingh5338 4 года назад

    Hey I tried doing in IntelliJ with scene builder but something is getting wrong...can u help?

  • @s.graham9364
    @s.graham9364 8 лет назад

    Thank you for sharing!
    Was curious how you would implement a winning method in this version of Minesweeper? Are you changing a property of Tile?

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

      Hi, I'm not sure I follow you. What do you mean by "a winning method"? Can you elaborate?

    • @s.graham9364
      @s.graham9364 8 лет назад

      Sorry for being unclear; your current code only has a "losing" state, but I was curious how you would complete the program so the user can "win" (uncover all non-mine tiles)?
      As someone fairly new to Java, I may be misusing the terminology as well...apologies!

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

      Hi, I can't quite remember the actual code. However, at the start (one way or another) we know how many mines there are. We could have a variable, say *mines*, that keeps track of the number of mines in the game. So, if the user uncovers a mine or several, then subtract the amount from the *mines* variable. If *mines* == 0 then the game is won.

  • @kathryncruz8525
    @kathryncruz8525 3 года назад

    Sorry to bother you, but I'm having trouble with setting the color for border? IntelliJ keeps asking me to rename the reference. I think it's saying that there's no method for setting the color?

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

    Hi, one question, i´m doing a maze and i´m doing kind of similar to this video to build the grid, i just wanna know how can i get the position of one cell? and the positions of the cells that are next to the actual position?

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

      Hi, I'm not sure what you mean but wouldn't the position of a cell be (x, y) in the 2d array? So neighbours are (x+1, y), (x-1, y), (x, y+1), (x, y-1). Also have a look at this 2d maze generator - github.com/AlmasB/maze3d/blob/master/src/com/almasb/maze/MazeGenerator.java

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

      thanks for the answer, i mean, i need to know a position of one cell that isn´t my neighbour, i need to draw a "rect" line (bresenham line) in the beggining, then move my character random on a neighbour cell

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

    I really dont understand the "getChildren().addAll(border, text);" in your Tile constructor.
    Why does this work without being called through an object. ? Where does the border and text get added to?

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

      Hi, getChildren() is called within the constructor, so it is called on that object that is being constructed. It is the same as if you called "this.getChildren()".

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

      I see. Thanks for the quick answer !

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

    I really don't understand why people make inner classes instead of external classes to make everything clearer and less chaotic. Sure you'll have more files but it's easier to change stuff, no?

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

      +Gilles Hi, yes inner classes should only be used if the scope is limited to a single file. For the purposes of the tutorial I thought it would be easier for everyone to see all of the code in one place.

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

      Thanks for the quick reply. I understand :)

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

    Hey Almas, I'm having a problem getting my GUI to initialize all of the squares. It populates the 3/4 of the first line and the rest of the GUI pane is white. Any suggestions?

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

      +Anwar Saleeby Hi, I'd recommend checking your code against source code repo on GitHub. Ideally just copy and paste from there. See if that helps

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

      +Almas Baimagambetov (AlmasB) I got the gui working, but I have a small bug with the tiles expanding but I'll do that and see how it comes out. Thanks!

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

    how do you finish the game? theres no way to win

  • @d.naveenkumar9380
    @d.naveenkumar9380 7 лет назад

    which data structure you have used?

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

    Sir need a information how to save this project im getting errors plzzz tell me ☹☹

  • @j3froc63
    @j3froc63 4 года назад

    Why did you write absolutely everything in one file/class? I know you have answered a comment here saying that you want everyone to see the code in 1 place. But shouldn't you be separating out this application/game into model-view-control?

    • @AlmasB0
      @AlmasB0  4 года назад +1

      Hi. Several years ago I would have said: "Absolutely, each class should be in a separate file". Having worked with systems small and large since then, my answer is now: it really depends, there is no single approach that works for every use case. If all users of a class are within a single file and the file is reasonably small, I'd actually intentionally put everything in one file. Unless your tools, e.g. Scene Builder, require you to have separate files, there won't be much of a significant difference provided SOLID principles are adhered to. If users of a class are in various packages / modules, then it sounds like separating out classes into files might be a good idea.
      As for MVC (model-view-controller), it's a design pattern that works well in some but not all cases. So we shouldn't attempt to apply it to all software. Apologies for a somewhat vague answer, hope this helps.

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

    Dude....Volume