Click here to Skip to main content
Click here to Skip to main content
Go to top

Improved Minesweeper, I Think

, 28 Jan 2009
Rate this:
Please Sign up or sign in to vote.
A simulation of Minesweeper by Microsoft with improvement, I think

Introduction

This Minesweeper game is a simulation of the one made by Microsoft. The playing field and the mine- and time counter are an exact copy of the one made by Microsoft. I've not copied the smiley thing, I don't like it.

Background

Since I am using Microsoft Windows Vista or Microsoft Windows 7, I really dislike the Minesweeper game. I think the one shipped with Microsoft Windows XP is the best. Except the use of left and right button simultaneously for opening fields after setting some flags. Why should I want to use two buttons while using only the left button is much more useful? Especially since it's not taken by any other function.

Using the Code

MinesweeperPanel

This JPanel creates the playing field based on the difficulty. There are three levels of difficulty: beginner, intermediate and expert. It contains a 2 dimensional array of fields.

Field

A field knows its x and y coordinates for painting at the right spot, how many neighbour fields contain a mine, if it is clicked, if it is a mine, if the user made it a flag and if the user clicked it while it is a flag.

The numbers, flag and mine are painted by hand so they will look the same on any OS. At least, I hope so.

The method setGameOver is used for setting up the playing field after the user has clicked a mine. The method setWon is used for setting up the playing field after the user has removed all non mine fields.

Display & Digit

Displays are the mine counter and the time display. A display consists of three digits.

Disclaimer

English isn't my main language, so it can be unreadable. I'm sorry. I don't use comments in my coding, it scares me and I think comments makes the code unreadable. After all, methods should do what they are called.

History

  • 28th January, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Eric Beijer
Software Developer Fortes Solutions BV
Netherlands Netherlands
It's good to be me.
Follow on   Twitter

Comments and Discussions

 
GeneralCool and Nifty DooDad Pinmembersam.hill17-Apr-10 7:08 
GeneralMy vote of 1 PinmemberShukaido4-Feb-09 7:28 
QuestionNo comments in source code because the function should do what it does ? PinmemberJ_Gamin3-Feb-09 5:14 
AnswerRe: No comments in source code because the function should do what it does ? PinmemberShukaido4-Feb-09 7:27 
GeneralRe: No comments in source code because the function should do what it does ? PinmemberEric Beijer1-Jun-12 15:17 
AnswerRe: No comments in source code because the function should do what it does ? PinmemberEric Beijer1-Jun-12 15:33 
GeneralMy vote of 2 PinmemberSteve Maier28-Jan-09 10:54 
GeneralMy vote of 2 Pinmembertamash_ionut28-Jan-09 9:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 28 Jan 2009
Article Copyright 2009 by Eric Beijer
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid