PowerPoint Creative
Log In or Register to participate in PPC!
PowerPoint Creative
Log In or Register to participate in PPC!

Go down
Jarek
Jarek
Featured Creator
Featured Creator
Posts : 341
Join date : 2018-12-06
Location : Poland

powerpoint - Minesweeper on PowerPoint Empty Minesweeper on PowerPoint

Wed Jun 15, 2022 3:34 am
Message reputation : 100% (2 votes)
powerpoint - Minesweeper on PowerPoint Zrzut_11

My take on the Microsoft classic. If you never played Minesweeper then you can search it on the web. Seasoned players should feel comfortable with this version. 3 difficulty levels with a random amount of mines for each level:
- EASY = 20-25 mines
- NORMAL = 30-35 mines
- HARD = 40-45 mines
- the grid size for each level doesn't change only the number of mines
- clicking on a tile with an empty space uncovers only 8 neighbouring tiles at a time
- remember to switch between flagging mines and digging

Have fun!

Download
johnr
johnr
Administrator
Administrator
Posts : 941
Join date : 2017-08-17
Location : UK
http://www.powerpointgames.uk

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Wed Jun 15, 2022 4:47 pm
Played this today and it really works well!

I used to play the Microsoft version of this during breaks at work many years ago.

You are putting me to shame with the expertise you seem to be building with VBA. I haven't even started doing anything with it yet!

Well done you!!
Jarek
Jarek
Featured Creator
Featured Creator
Posts : 341
Join date : 2018-12-06
Location : Poland

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Thu Jun 16, 2022 12:56 pm
John - what you don't know is that I always liked computer programming. It started with the Sinclair ZX - couldn't afford the Spectrum. I learned the Basic programming language and this knowledge now helps me with VBA. VBA seems in a lot ways similar to Basic. Funny that after so many years some things we learned earlier presumed by now to have become obsolete are still useful...

And another thing - the more I get to grips with VBA the more I see its limitations. Nothing spectacular about it. No shame on you, my friend! You are a master of raw PowerPoint to an extreme I can only dream of. BTW - how do you make the pennies go further or closer in your recent Shove Ha'Penny game?
johnr
johnr
Administrator
Administrator
Posts : 941
Join date : 2017-08-17
Location : UK
http://www.powerpointgames.uk

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Fri Jun 17, 2022 3:40 am
Ah Ha! That explains how you have taken to VBA so quickly!

As for the stopping of the coins in Shove Ha'penny, they are each on a motion path to the top of the board with a Repeat of 'Until next click' and triggered by the button. An 'Appear' animation is then added to start 'On click' of the same button. So you click once on the button to start the motion path, then again to stop it.

Jarek likes this post

Jarek
Jarek
Featured Creator
Featured Creator
Posts : 341
Join date : 2018-12-06
Location : Poland

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Wed Jun 22, 2022 3:34 am
Update:
when clicking an empty tile now ALL empty tiles are cleared and not only 8 (except for the first click). Brings it closer to the original.

Download

Still can't figure out how to guarantee that the first click is always on an empty tile....
rusnakcreative
rusnakcreative
Administrator
Administrator
Posts : 633
Join date : 2017-08-16
https://www.rusnakcreative.com

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Wed Jun 22, 2022 4:00 pm
Jarek wrote:Update:
when clicking an empty tile now ALL empty tiles are cleared and not only 8 (except for the first click). Brings it closer to the original.

Download

Still can't figure out how to guarantee that the first click is always on an empty tile....

A suggestion: What if your first click generated the playing field and instantly becomes either blank or has a number. You can have in the code to not place a mine down on the square that was just clicked, but treat the square like anything else at the end of the square reveal. I'd have this under a conditional statement that checks if this is the first move or not, which will then run the generate level code, and then the rest of the normal reveal code you have.
Jarek
Jarek
Featured Creator
Featured Creator
Posts : 341
Join date : 2018-12-06
Location : Poland

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Thu Jun 23, 2022 4:41 am
That is how I see it too. Because of the way I approached the project I can't figure out a way to check for the first click and ignore consecutive clicks. Sounds simple but gives me a problem.
rusnakcreative
rusnakcreative
Administrator
Administrator
Posts : 633
Join date : 2017-08-16
https://www.rusnakcreative.com

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Thu Jun 23, 2022 10:07 am
Jarek wrote:That is how I see it too. Because of the way I approached the project I can't figure out a way to check for the first click and ignore consecutive clicks. Sounds simple but gives me a problem.

Create a global boolean variable called firstclick. When you click new game or any time the game clears itself, set firstclick to false. Have your conditional check the status of firstclick. If it's false, then run the generate and then the rest of the move as normal. Don't forget to change firstclick = true before exiting your conditional, which will prevent it from running again until you give firstclick = false when the game clears or gets ready for a new game.
Jarek
Jarek
Featured Creator
Featured Creator
Posts : 341
Join date : 2018-12-06
Location : Poland

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Fri Jun 24, 2022 5:55 am
Done. 

Final version (also updated for all links in this thread):   Download

My problem was of a slightly different nature. The names of the shapes in Minesweeper are also the coordinates of the table. So if for instance I click shape "8,12" I also get the coordinates of the table for row=8 and col=12 with the following code:

Code:
Sub Field(oshp As Shape)     
    shpName = oshp.Name 
'   Splitting based on delimiter ","
    Dim a As Variant
    a = Split(shpName, ",")
    Dim row, col as Byte
    row = a(0)
    col = a(1)
End Sub

Next I use the variables "row" and "col" to check if the randomly generated coordinates "i" and "j" for a mine placement fall within a 9 field radius immediately surrounding the clicked shape. If yes, then the program keeps looping for a new pair of randomly generated coordinates until they fall outside the tested range (so a mine can get placed):

Code:
'
'
loop1:
    Randomize
    i = Int(13 * RND + 2)
    Randomize
    j = Int(21 * RND + 2)

    If i = row - 1 Or i = row Or i = row + 1 Then
        If j = col - 1 Or j = col Or j = col + 1 Then
            GoTo loop1
        End If
    End If
'
'

All looked great and should have worked except that the double "If" loop didn't. Some mines were still being placed in the 9 field radius - including the clicked field! Obviously that meant instant death on the first click. What was wrong? If you compare the loops above and below you'll notice one little thing that fixed the problem:

Code:
   If i = row - 1 Or i = row + 0 Or i = row + 1 Then
        If j = col - 1 Or j = col + 0 Or j = col + 1 Then
            GoTo loop1
        End If
   End If

It took me almost 3 days of trial and error, pulling my hair out, etc. to find this out and I still don't know why I had to do it. Is it because "a" was declared as a Variant? So then subsequently "row" and "col" had to undergo a mathematical equation because a Dim statement for them was not enough? One of many VBA quirks? What else?

All in all at the end of the day Minesweeper seems to be working

powerpoint - Minesweeper on PowerPoint 1f600
Jarek
Jarek
Featured Creator
Featured Creator
Posts : 341
Join date : 2018-12-06
Location : Poland

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Mon Jun 27, 2022 4:44 am
Hopefully fixed a minor 1st-click bug that on rare occassions - when mass clearing empty fields - caused some neighbouring fields not to have a value assigned to them.

Download


John - for once in my lifetime REALLY fixed a bug!  powerpoint - Minesweeper on PowerPoint 1f604
Jarek
Jarek
Featured Creator
Featured Creator
Posts : 341
Join date : 2018-12-06
Location : Poland

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Thu Jun 30, 2022 6:16 am
The best way to test a game for me is to give it...
...to my wife!

Everything that could have gone wrong went wrong including accidentally hitting the NEW (and later the QUIT) button thus immediately and involuntarily exiting in the middle of the current game, as well as a complaint that she didn't know how long it took her to complete the level.

So here's an update that eliminates all disasters I didn't think of before.

Download
!C8Hypela/M!!fN+hj5w
!C8Hypela/M!!fN+hj5w
Featured Creator
Featured Creator
Posts : 147
Join date : 2021-04-28
Location : Nusantara

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Fri Jul 01, 2022 8:50 am
PPC, where we solve problems that people doesn't even have... WITH POWERPOINTS!
Spoiler:

My only criticism would be the inability to dig by clicking the numbers that had been surrounded by the same amount of flags. And when you fail, you can still continue digging the board, I don't think that's intentional...

Also,

Jarek wrote:The best way to test a game for me is to give it...
...to my wife!

frickin' sent me rolling.
Jarek
Jarek
Featured Creator
Featured Creator
Posts : 341
Join date : 2018-12-06
Location : Poland

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Mon Jul 04, 2022 2:06 am
!C8Hypela/M!!fN+hj5w wrote:... inability to dig by clicking the numbers that had been surrounded by the same amount of flags. And when you fail, you can still continue digging the board, I don't think that's intentional...

I don't understand what you mean Hype. Please explain in layman words Smile


---
There's another fault with my game: I have a version from Google's Play Store on my mobile which guarantees that you never get stuck having to make a wild guesse - it's always possible to figure it out logically. I am unable to reproduce that because of my poor mathematics. With the HARD level especially when there are many mines it can happen more often Sad

---
Yeah, I know that Minesweeper has been around since the 90's. It's still a fun time killer, though. Apart from Pacman it's the only one that came to my mind that I could attempt to write in VBA. Have you tried my Pacman? You're welcome to rate it...  powerpoint - Minesweeper on PowerPoint 1f631
!C8Hypela/M!!fN+hj5w
!C8Hypela/M!!fN+hj5w
Featured Creator
Featured Creator
Posts : 147
Join date : 2021-04-28
Location : Nusantara

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Mon Jul 04, 2022 5:06 am
Uh oh, let me attach a video for that first one. It's on 2:14



Although another part of my mind says this could be a nice piece of software to train for flag-less speedrun attempt, due to the options to switch between 'dig' and 'flag' are so complicated (from a speedrunning standpoint) and thus discouraging players from using it. It trains the instinct to only rely on left-click.

For the other one, I just figured it was actually a bug(?) where you can continue playing even after hitting the bomb. It seemed to only happen on my first playthrough in the first version though, so maybe you can ignore this one..?
Jarek
Jarek
Featured Creator
Featured Creator
Posts : 341
Join date : 2018-12-06
Location : Poland

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Mon Jul 04, 2022 10:36 am
I wasn't aware of the first one! Throughout all these years I played it without that option! On second thought I figure it doesn't change much in terms of game play since the after effect is identical to whichever of the 2 fields you choose to click on. I'm not sure if I can still implement it without tearing the game down. Which I wouldn't want to go through. You seem to know the retro games quite well... 

The second one must have been a fluke chance I didn't encounter when testing. Hitting a mine = instant game over. Let me know if it happens again.
!C8Hypela/M!!fN+hj5w
!C8Hypela/M!!fN+hj5w
Featured Creator
Featured Creator
Posts : 147
Join date : 2021-04-28
Location : Nusantara

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Mon Jul 04, 2022 11:57 pm
I frequently played minesweeper when I found myself bored on me desk, pretty timeless game I gotta say haha.

But yeah, I can see why tearing apart that heck-a-doodling-doo wall of codes just to add some slight modification to the gameplay doesn't sound like a worthy ordeal.

So, we're all set then! I guess?

Jarek likes this post

Sponsored content

powerpoint - Minesweeper on PowerPoint Empty Re: Minesweeper on PowerPoint

Back to top
Permissions in this forum:
You cannot reply to topics in this forum