Author Topic: click type game  (Read 3958 times)

0 Members and 1 Guest are viewing this topic.

Offline Larryrl

  • Newbie
  • Posts: 26
    • View Profile
click type game
« 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

FellippeHeitor

  • Guest
Re: click type game
« Reply #1 on: October 03, 2018, 07:12:02 pm »
Just give bplus 10 minutes.

FellippeHeitor

  • Guest
Re: click type game
« Reply #2 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?

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: click type game
« Reply #3 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()
« Last Edit: October 03, 2018, 07:23:41 pm by TerryRitchie »
In order to understand recursion, one must first understand recursion.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: click type game
« Reply #4 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?
« Last Edit: October 03, 2018, 08:34:35 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: click type game
« Reply #5 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.

Offline Larryrl

  • Newbie
  • Posts: 26
    • View Profile
Re: click type game
« Reply #6 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.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: click type game
« Reply #7 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
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/