namdrib / java-minesweeper Goto Github PK
View Code? Open in Web Editor NEWA Java version of Mineseweeper.
License: MIT License
A Java version of Mineseweeper.
License: MIT License
If first click was going to be on a mine, move the mine to the top-left corner.
If the top-left corner already has a mine, move it to the right one square. Repeat until there is a safe square that can become a mine.
Some notes on behaviour:
this should only trigger the opening of neighbours if the number of adjacent flags is equal to the cell's number, AND
this should trigger if both left and right mouse buttons are down and one of them is let go
this is still valid if both left and right leave the intended CellIcon and return over it again
Rough plan:
make the face surprised ๐ฎ when left or middle clicking anywhere in the game
This might be quite tricky since the face changes on any click in the game, even on the cells or on the face itself (middle click)
At the moment, opening many cells at the same time repaints them individually, which gives a
bit of a "cascade" effect, as seen in the following .gif
See if there is something that can be done to remedy this
Perhaps using bfs instead of dfs
Or using a flag to only visually open them once they are all opened
Or maybe not repainting till they're all done
This should reduce the amount of hardcoding scattered throughout the codebase.
Some examples include:
Some option under the Game menu to allow the user to choose a theme.
The theme is a folder containing icons for each tile and face icon. Possibly include different counters, too (number of seconds passed and number of mines remaining).
Idea: Game -> Theme chooser ->
Colour
radio menu itemCurrently, if an extremely long name is put in for best times, it elongates the window to try to fit the whole thing in. A side-effect of this is that when the scores are reset while viewing an elongated window, the window still stays with the larger size.
An extremely long name should instead flow off the end of the window and be partially invisible, such as visible here (original WinXP minesweeper running on Linux, so theme is a bit off):
Add more detail into the readme, such as details on what this program does/aims to achieve, other modifications I have, requirements to compile/run the program, etc.
Maybe also have a list of upcoming features that is updated with each commit.
Might be a good idea to have screenshots or a gif displaying the product.
Java's in-built bevel border defaults to single-pixel width with no way to customise this.
See this SO post for something similar to what I want.
The border style of the elements looks like this:
Also note the diagonal ends of the borders: the far bottom-left (and top-right) corners are not the same colour as the main part of the border. They are a separate colour. In this case, all (192, 192, 192)
.
Disable the events of mouse clicks except for on the face button when an end-game condition is reached:
When the game is won (all non-mine Cells opened), every mine square should be automatically flagged.
Likely just use a aggregate operation pipeline to go through each Cell -> if is a mine and is not flagged -> flag it.
in Minesweeper.rbMenuItem.addActionListener, entering a bad input for heightField, widthField or minesField (e.g. empty strings, non-numerical input, etc.) should result in beginner values for each incorrect field.
try {
newHeight = Integer.parseInt(heightField.getText());
} catch (NumberFormatException ex) {
newHeight = 9;
}
try {
newWidth = Integer.parseInt(widthField.getText());
} catch (NumberFormatException ex) {
newWidth = 9;
}
try {
newMines = Integer.parseInt(minesField.getText());
} catch (NumberFormatException ex) {
newMines = 10;
}
This requires an individual try/catch since each field is treated individually
things to store might include:
this issue should handle saving these and loading them upon creating a new game
The beginning and end of the press/release cycle must be done on the face for the game to restart
Sometimes, it can cause the game to erroneously think the player has won despite triggering a mine. Not entirely sure what condition triggers this yet
Thanks to @Protofall for discover
Each preset difficulty (beginner, intermediate, expert) should have a corresponding best time and name (default: 999 seconds) which can be found under the menu Game -> Best Times ...
.
Exploring this window should yield a window like this:
This issue has two parts:
The latter of which includes checking for fast win times and prompting the user for a display name, which looks like this:
Having a way to build and/or write a minefield
Can be used for automated and non-automated testing by allowing for specific contrived situations.
At the very least must take the x and y dimensions of the board and the number of mines.
That way, it can correctly throw exceptions if any of the above is an impossible situation (e.g. all cells are mines, map too small, ...)
could have something like:
Probably requires some refactoring of GameImpl by shifting functions around and extracting some functionality into helpers
This interface should pave the way to unit testing capabilities
0ef9a22: "need to have a way for cellimpl to refer to persistence.getMarks()"
Because right now it hardcodes all Cells to have marking
as true
, regardless of what has been loaded from the database (from #19). This causes the marking
status to be out of sync with the menu options.
GamePanel
has direct access to a Minesweeper
object, which can in turn access the Persistence
object. This may be bad programming, but may be how CellImpl
can do this.
Need to think of a better way to have Persistence
access.
Idea: if detecting that chording is happening, loop through unopened neighbours, change their image
If the mouse leaves the current cell, unpress the neighbours
If the mouse enters a cell, and is chording, press the neighbours
Potential problem: like the cascading "opens" and mine reveals (as in #13) this may cause the cells affected by both the leaving and entering step to become unpressed and pressed again.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.