Java Minesweeper Game

[Shangxuetang] Java300 zero-based video tutorial for beginners_Java300 zero-based tutorial_Java beginner video basic consolidation tutorial_Java language entry to proficiency_bilibili_bilibiliThe Java minesweeper game needs to be centered on the current coordinates (x, y)

To determine the parameters of the eight surrounding grids

Use a double for loop to traverse

i-1,j-1     i,j-1      i+1,j-1

i-1,j      i,j         i+1,j

i-1,j+1     i,j+1     i+1,j+1

Need to use GridLayout grid layout and BorderLayout border layout

Through these two layout managers, a Minesweeper interface is formed and then the page layout is edited.

Download some material pictures from the Internet and then add them to form a complete game interface.

After completing the early inspection, I found that it was not possible to replay the game. The originally defined method of replaying the game was to directly reset some buttons, reset, etc.

But no matter how I change it, I can’t start over and the compiler doesn’t report an error.

After many tests, it was found that it was carelessness in not calling the method, which caused a long delay in adding, deleting, modifying and checking.

From this lesson, I learned what to do and not to be careless about small problems or big problems. In the future, I will make every comment and standardize the code writing format to make my code more readable.

Basic functions that need to be completed for minesweeper:

1.Button

2. Timing

3. Number blocks

4. Empty blocks

5. Generate thunder blocks

6. Click on an empty block to automatically display all grids connected to the empty block.

7. Optional, right-click and left-click together to prompt an unmarked button.

8. If a mine is struck, the timer will stop, all mines will be displayed, the expression will be changed, and the current mine mark will be red.

9. Click on the number to display the current number

10. Right-click the mouse to mark the red flag. The red-flag mark block disables the left-click event. Right-click again to cancel the red flag.

11. Mark all mine blocks to end the game

At the same time, as we continue to study below, we will continue to improve and summarize the previous knowledge points, get better and better, and keep making progress. Come on, Oli.



 

Related Posts

Browser–Complete list of commonly used search operators–Usage/Examples

Practical deployment of ingress-controller in k8s and issues with path prefix configuration

Solve the problem of No active profile set, falling back to 1 default profile: “default” and how to check the spring boot version number

es query modification

Leetcode points at Offer questions – Day 9

Git | One article will help you quickly get started with Git from scratch

Computer Network–Network Layer

Java project: student management system (java+Springboot+Maven+mybatis+Vue+Mysql)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*