GMSweeper - A simple minesweeper game

Show off your games, demos and other (playable) creations.
User avatar
GreffMASTER
Prole
Posts: 10
Joined: Tue Apr 12, 2022 6:43 pm
Location: Poland
Contact:

GMSweeper - A simple minesweeper game

Post by GreffMASTER »

Hi there! :ultraglee:
I wanted to use my GMUI library for something more than just a test project, so I've decided to make a simple minesweeper game that uses most of the lib's features.

Game Features
  • Three difficulties (easy, medium, hard)
  • Custom mode, where you can set width and height of the grid and the mine count
  • Highscore table for the top 10 best times for each difficulty
  • Scalable window (scales every 0.5x until it no longer fits in the screen)
Changelog:
v1.2 (The Polishing Update)
  • Added chording (how did I miss it :oops: )
  • Added maximum window scale check
v1.1.1
  • Added static window scaling (to change scale, press the button in the top-right corner of the window)
  • Added slider buttons for the custom mode settings (hold-to-increment)
  • Disabled unused modules
  • General code cleanup
v1.1 (The Diet Update)
  • Overhauled the rendering code to greatly reduce CPU usage
  • You can now click the buttons on the toolbar while a window is open
v1.0.1
  • Reduced CPU usage
  • Fixed a softlock when starting a new game while the current one is in progress
v1.0
  • Initial release

Notice: This game is not made with mobile support in mind and I am not planning to change that. Run at your own risk and expect issues.

You can find the GitHub repository here.
Let me know what you think!
gmsweeper-1.2.love
GMSweeper v1.2
(33.69 KiB) Downloaded 83 times
Attachments
About window
About window
gmsweeper-1.2_about.png (16.49 KiB) Viewed 2451 times
Last edited by GreffMASTER on Sun Dec 04, 2022 7:26 pm, edited 9 times in total.
User avatar
BrotSagtMist
Party member
Posts: 604
Joined: Fri Aug 06, 2021 10:30 pm

Re: GMSweeper - A simple minesweeper game

Post by BrotSagtMist »

Plays very well. Perfect minesweeper implementation.

But i get a very high cpu load on creating a big custom game, maybe look into that.
obey
User avatar
GreffMASTER
Prole
Posts: 10
Joined: Tue Apr 12, 2022 6:43 pm
Location: Poland
Contact:

Re: GMSweeper - A simple minesweeper game

Post by GreffMASTER »

BrotSagtMist wrote: Wed Nov 09, 2022 2:40 pm Plays very well. Perfect minesweeper implementation.

But i get a very high cpu load on creating a big custom game, maybe look into that.
Thank you so much for the report! I personally haven't bumped into any problems regarding the performance, but after I checked for myself, something was truly wrong. Apparently I had V-Sync turned off and that was the main issue (oops). I also found another bug, so I need to update the game anyway. I will upload the fixed love file after I'm sure there's nothing more to do and pack all the files for the GitHub release.

I'm glad you like the game! :awesome:
User avatar
BrotSagtMist
Party member
Posts: 604
Joined: Fri Aug 06, 2021 10:30 pm

Re: GMSweeper - A simple minesweeper game

Post by BrotSagtMist »

I am afraid thats not it, still high cpu.
For a puzzle game like that i figured i could just replace the main loop with an input driven loop effectively eliminating cpu usage at all.
I gave it a try, but somehow this thing keeps using cpu even when the loop is paused, weird. I dont see anything in the code that would cause that.
obey
User avatar
GreffMASTER
Prole
Posts: 10
Joined: Tue Apr 12, 2022 6:43 pm
Location: Poland
Contact:

Re: GMSweeper - A simple minesweeper game

Post by GreffMASTER »

Looks like there is no easy fix for this, because the reason of the high CPU load are the draw calls for the grid buttons. I would have to rewrite the entire input part of the game. I will see what I can do but it might take some time.

Edit: I have an idea on how to improve things without drastic changes. Once I find some time, I'll try to implement it and see the results.
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: GMSweeper - A simple minesweeper game

Post by darkfrei »

1) It must be at least twice bigger on the 4K monitors
2) Please change the GUI that I can switch the tabs Game/Scores/About without closing it.
Attachments
2022-11-10T10_42_59-GMSweeper.png
2022-11-10T10_42_59-GMSweeper.png (8.74 KiB) Viewed 4224 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
GreffMASTER
Prole
Posts: 10
Joined: Tue Apr 12, 2022 6:43 pm
Location: Poland
Contact:

Re: GMSweeper - A simple minesweeper game

Post by GreffMASTER »

A new version has been released.
This update overhauled the way playfield is rendered (it no longer draws thousands of buttons each frame and instead, it redraws the playfield only if a tile/multiple tiles have been uncovered).
It should greatly reduce the CPU usage (for real this time :crazy: ).
darkfrei wrote: Thu Nov 10, 2022 9:45 am 1) It must be at least twice bigger on the 4K monitors
2) Please change the GUI that I can switch the tabs Game/Scores/About without closing it.
1) I've tried to implement global 2x scaling but the filtering doesn't make it look too well (both linear and nearest). I have a working test branch that I could send but I would need more time to implement it properly.
2) Here you go!
User avatar
BrotSagtMist
Party member
Posts: 604
Joined: Fri Aug 06, 2021 10:30 pm

Re: GMSweeper - A simple minesweeper game

Post by BrotSagtMist »

You call that reduced cpu usage?
*draws Sword*
*cuts of audio module and frame refresh*
minweeperlow.zip
(32.71 KiB) Downloaded 88 times
That now is 0.7% cpu compared to 13% it had before. Quite a drastic difference for adding very little code.

This is basically what i meant with input driven loop above. It triggers only when either an event appears or the clock turns a second.
This can be further finetuned to only trigger on certain events, mouse clicks instead movement for example and to only update the counter section of the screen by the timer.
Also since you have no sound there is no reason to activate the soundcard so i deactivated the module in conf.
I am actually puzzled why love even uses resources on audio without audio being played.
obey
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: GMSweeper - A simple minesweeper game

Post by darkfrei »

Yes, such games must have events just on mouse movement, click (or release) mouse buttons. Ok, you can also update the timer on every second.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
GreffMASTER
Prole
Posts: 10
Joined: Tue Apr 12, 2022 6:43 pm
Location: Poland
Contact:

Re: GMSweeper - A simple minesweeper game

Post by GreffMASTER »

Oh dear, there is still so much I need to learn... :oops:
Well, I will try to re-implement the run callback to make it more optimized without entirely copying your solution.
I still have a few features that I would like to implement in the near future, like window scaling for bigger resolutions and "button sliders" (hold to increment) for custom mode buttons.
I don't have as much time as I did before, but I will try to maintain the code as much as I can.

Thanks so much for the feedback! :D

Edit: I will not modify the run callback, because your solution makes the timer behave quite strange and I need consistent updates for other windows (like text entry and slider buttons). Besides, I'm happy with the performance of the current build. (I will disable unused modules though.)
Last edited by GreffMASTER on Sun Nov 13, 2022 10:13 pm, edited 1 time in total.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 10 guests