-
Object Numbering
Hello all.
I am working on a Minesweeper variant, and am having a few issues with bomb detection.
As of now, the game checks for X and Y coordinates relative to bombs around it. My issue is that these actions only affect the first bomb to be spawned in... all other bombs do not run the command. I know if you make related events to an object it will apply the event to ONLY one object, however I need this to run the events for ALL bombs.
Any help?
Thanks in advance,
-Verbage
-
There is such a thing as object numbering, though it's called something else - the Spread value action (under Alterable Values) will assign values to the instances of that object in sequence starting from the number you specify (usually 0). You can then run a fastloop through them and compare each one individually. You can read the Fastloops tutorial (under Clickteam's tutorial page, on the right sidebar when you're on the forum list) to learn more.
For games based heavily around grids of objects, I would actually recommend using the Advanced Game Board object (which has functionality for checking for adjacent tiles built in) and then using the data in that to draw the visible screen, rather than doing it directly - but if the approach you're using is working for you, it's worth continuing.
-
You might also have some luck with the Easy Grid Extension.
Marv
-
Thank you David for your reply.
I tried researching fast loops... to no avail (for this situation). I understand fast loops generally, but am quite stumped on how to run the event for each bomb. I'll go ahead and list what I have here, and see if anyone can make some corrections.
Always
Start Loop "Numbering" 1000 Times
Always
Spread value 0 in ID
ID of "Tile" = LoopIndex("Numbering")
*position stuff here for all adjacent angles, I've done separate tests so I know they detect*
Add 1 to Bomb [Bomb Angle (1-7 are numbered animations) is always set to the Bomb value]
I feel like I'm doing something wrong. If anyone knows the issue but is beyond describing in words, let me know and I can send you the source file.
Please and thank you.
-
I would use nested fastloops. Create two 1x1px active objects. Name one Detector 1 and the other Detector 2. Give both the Tile object and Detector 2 a value called MineCount.
+Start of Frame -
Start loop "Check 1" GridWidth*GridHeight times
+On Loop "Check 1" -
Detector 1: Set X Position to loopindex("Check 1") mod GridWidth
Detector 1: Set Y Position to loopindex("Check 1") / GridWidth
+On Loop "Check 1"
+Detector 1 overlaps Tile
Start loop "Check 2" 9 times
+On Loop "Check 2"
Detector 2: Set X Position to (X("Detector 1")-TileWidth)+(loopindex("Check 2") mod 3)* TileWidth
Detector 2: Set Y Position to (Y("Detector 1")-TileHeight)+ (loopindex("Check 2")/3)* TileHeight
+On Loop "Check 2"
+Detector 2 overlaps Tile
+Tile is a mine
Detector 2: Add 1 to MineCount
+On Loop "Check 1"
+Detector 1 overlaps Tile
+MineCount("Detector 2") > 0
Tile: Set MineCount to MineCount("Detector 2")
The red variables are defined as follows:
GridWidth: The width of the grid in cells (eg: An 8x8 grid would use 8 for this number)
GridHeight: The height of the grid in cells, see above.
TileWidth: The width of each tile in pixels.
TileHeight: The height of each tile in pixels.
Minecount: The number of tiles adjacent to each tile.
I hope this is clear enough. It's been a few years since I worked on my minesweeper game :P
-
Thank you for your reply Jacob.
I followed your guide step-by-step and reviewed it 3 times. Doesn't work. I can send you my .mfa, but so far this isn't working.
Thanks
-
Is your grid area at 0,0? I didn't put any code to offset it to whatever the grid position is :o
-
Ah that would do it. Yeah, my grid area starts at (10,94).
Also: Do you happen to have a Skype? Would make this thing a bit speedier.
Thanks again.
-
Also, in the spirit of learning, what does "Mod" mean? I see the button, but mousing over it doesn't bring up an explanation box.