Tag Info

Hot answers tagged

10

Imagine the following setup: 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 1 1 1 1 1 As a side note, I refer to squares in the matrix like this: (row, column). I've represented mines with "1" and empty spaces with "0". Assume the user clicks on the empty space at (2, 2) (the corner at the top-left is (0, 0)). This is what would happen: ...


7

I can't tell from your (lack of) code, but you are probably just missing a stop to make sure that you don't handle tiles which have already been handled. At the top of the function you should put something like: if(thistile.hasbeenhandled){ return; } else{ thistile.hasbeenhandled=true; } Otherwise any two adjacent tiles that are to display empty ...


5

You forgot to put addMouseListener(this); to your frame/panel


5

You are probably forgetting to hook up your listener.


4

eBuisiness's answer is correct. But you're setting the HasBeenHandled flag after trying to update all the neighbors which then causes a stack overflow. You should instead set the flag before doing anything else. EDIT: You've also made typos in the if statements. if (Bottom.btn != null) set_text_of_button(Bottom.btn); if (Bottom_Left.btn != null) ...


4

The 3BV score is essentially counting the number of clicks required to reveal all non-mine squares. A Minesweeper board is essentially an m*n array. To calculate the 3BV, you will need to process the cells in this array in a particular order, so you will need to be able to mark each cell after you process it (so you don't process it multiple times). Then, ...


2

I think the fastest method will be by not generating the numbers at board generation (I know it's almost cheating). It's most likely fastest to only generate the number when the player clicks on a square rather then during board generation. Secondly consider how you are going to generate mines, is each place on the board going to pass a check (loop over ...


1

Create two dimensional array Randomly place mines and place mine location to list Foreach mines and add +1 to adjacent cells Mine creation int x = random.next(min, max); int y = random.next(min, max); mineList.add(new XYClass(x,y)) Number calculation Foreach(XYClass xy : mineList) addPlusOneToAdjacentCells(xy); This way, you don't even have to ...


1

glViewport(0, 0, width, height); // reset the viewport glMatrixMode(GL_PROJECTION); // modify the projection matrix glLoadIdentity(); // load an identity matrix into the projection matrix glOrtho(0, width, 0, height, -1.0, 1.0); // create new projection matrix /// Important!!! You need to switch back to the model-view matrix /// or else your ...



Only top voted, non community-wiki answers of a minimum length are eligible