QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Larryrl on October 03, 2018, 07:08:40 pm

Title: click type game
Post by: Larryrl on October 03, 2018, 07:08:40 pm
I want to make a game where it uses box characters ascii 176 177 178 and 219 and maybe 240, and if I click on a block, all of the same character that are touching each other must be erased, and all of the ones from above fall into the holes to cover them up solid again adding new pieces to the top once the top ones have fallen so that the screen is always solid. Sounds easy if you say it fast enough :) Problem is getting it to start at the piece you clicked on then check each of the four pieces adjacent to it, and keep going until it runs out of connected pieces yet stopping at the edges of the screen.   

Any ideas would be greatly appreciated
Title: Re: click type game
Post by: FellippeHeitor on October 03, 2018, 07:12:02 pm
Just give bplus 10 minutes.
Title: Re: click type game
Post by: FellippeHeitor on October 03, 2018, 07:14:27 pm
You'll probably want an array with two dimensions, for rows and cols. Do you already have something?
Title: Re: click type game
Post by: TerryRitchie on October 03, 2018, 07:20:52 pm
You need to use a recursive flood-fill algorithm. I had to create this very same concept for my minesweeper game to remove all cells adjacent to each other with no bomb in them, and the others to display a number if there was a bomb inside.

Here is a link to minesweeper. Feel free to look at and modify the code I have created for your purpose.

https://www.qb64.org/forum/index.php?topic=455.0

The subroutine you are looking for is REVEALCELL()
Title: Re: click type game
Post by: bplus on October 03, 2018, 08:19:12 pm
Just give bplus 10 minutes.

Yeah and then find out "Ninja Fingers" has it posted on github already! ;-))

Actually the game being described sounds Insane:
https://www.qb64.org/forum/index.php?topic=601.msg4578#msg4578
Dav's version insanely shifts columns to the right as they empty,  I had learned and programmed the game as Click-O-Mania shifting left. Please don't tell Pete.

But I don't know how the twist of always refilling from the top would work out, what then is the object of the game?
Sounds Sisyphean to me.  https://www.merriam-webster.com/dictionary/Sisyphean

Larryrl, Do you have code attempted so far?

By the way, how did the file dialog work out?
Title: Re: click type game
Post by: bplus on October 03, 2018, 09:12:32 pm
Oh! I just realized Pathfinder was doing this non recursively.

The code in reply #18 of https://www.qb64.org/forum/index.php?topic=410.15
sub prepStepMap, might be modified for a non recursive elimination of blocks.
(This is when I switched off from diagonal cells and only considered the 4 neighboring cells: left, right, up and down)

But these things are easier understood from your own code beginnings.

Recursive methods like flood-fill and mine-sweeper are tricky to understand if haven't played with recursion yet.
Title: Re: click type game
Post by: Larryrl on October 05, 2018, 12:16:58 pm
You need to use a recursive flood-fill algorithm. I had to create this very same concept for my minesweeper game to remove all cells adjacent to each other with no bomb in them, and the others to display a number if there was a bomb inside.

Here is a link to minesweeper. Feel free to look at and modify the code I have created for your purpose.

https://www.qb64.org/forum/index.php?topic=455.0

The subroutine you are looking for is REVEALCELL()

I downloaded the file and am going to study it thoroughly. Btw thank you for your service to our country.
Title: Re: click type game
Post by: Pete on October 05, 2018, 05:30:54 pm
I made a game called MIME SWEEPER once. It was one mime in one box with one broom. Unfortunately, it didn't catch on very well. Apparently keeping the mime and broom confined within the box kept it from sweeping the country. Oh well, live and learn.

Pete