Asking for action puzzle game design

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
sunny
Posts: 8
Joined: Wed Nov 17, 2004 1:31 am
Location: Hong Kong

Asking for action puzzle game design

Post by sunny » Tue Nov 23, 2004 8:22 pm

Hi, I am now trying to write a mini game like "Dr. Robotnik's Mean Bean Machine" or "Diamond" tetris-liked puzzle game.

I am now struggling on how to detect if the blocks of the same type are connected in an efficiency way.

Followings are what i have done:
1. When the blocks cannot drop further, the sprite will be replaced by a background pattern.
2. The layer of the blocks represented by the background pattern set to $01

Therefore, once the sprite cannot drop further and turned to background. I will check if the background pattern of the neighbour block is the same.

If yes, then the neighbours of the "checked-neighbour" will be checked... until no more blocks with the same background pattern.

During the checking, a counter will log the number of the blocks with the same background pattern are connected together. Once the number of connected blocks are more than or equal to 4, cancellation will be processed.

However, I do think that the method I described in the above is not efficient ...

Is anyone can give me some hints?

Regards,
Sunny

User avatar
Memblers
Site Admin
Posts: 3877
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Post by Memblers » Tue Nov 23, 2004 8:48 pm

Hmm, I had given this same problem a lot of thought before. When I was planning out a similar game (I never implemented it, tho).

My plan was pretty similar to yours, I'd be surprised if there could be a better way to do it. In my game plan, the matching blocks would meld together, so there'd have to be delays for nametable updates with mine. It would take longer, but would look nice.

Once some blocks disappear and the ones above it fall, it's possible it'll have to recheck practically every block on the screen. So I think it'd be best to optimize for that kind of situation, the worst case one.

Just put all your frame-based stuff (music, animations, etc.) in the NMI routine, so if it ever overflows a frame or two, the player wouldn't know the difference.

tepples
Posts: 22049
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Asking for action puzzle game design

Post by tepples » Tue Nov 23, 2004 9:02 pm

sunny wrote:Hi, I am now trying to write a mini game like "Dr. Robotnik's Mean Bean Machine" or "Diamond" tetris-liked puzzle game.
A puyo clone.
I am now struggling on how to detect if the blocks of the same type are connected in an efficiency way.

[...]
once the sprite cannot drop further and turned to background. I will check if the background pattern of the neighbour block is the same.

If yes, then the neighbours of the "checked-neighbour" will be checked... until no more blocks with the same background pattern.

During the checking, a counter will log the number of the blocks with the same background pattern are connected together. Once the number of connected blocks are more than or equal to 4, cancellation will be processed.

However, I do think that the method I described in the above is not efficient ...
Go look up flood fill on Wikipedia. Essentially, whenever you add blocks to the background (either new blocks or blocks that fell), you'll want to flood-fill the areas where they are with a unique identifier. Scan from left to right, doing one column in each frame, and you should be able to fit it easily into the draw period.

sunny
Posts: 8
Joined: Wed Nov 17, 2004 1:31 am
Location: Hong Kong

Post by sunny » Tue Nov 23, 2004 9:20 pm

Memblers wrote: Just put all your frame-based stuff (music, animations, etc.) in the NMI routine, so if it ever overflows a frame or two, the player wouldn't know the difference.
Hi, thank you for your suggestion. However, would you mind to give me more information onf NMI (non-masking interrupt). Would you mind telling me the benifit of using it?

Thanks,
Sunny

sunny
Posts: 8
Joined: Wed Nov 17, 2004 1:31 am
Location: Hong Kong

Re: Asking for action puzzle game design

Post by sunny » Tue Nov 23, 2004 9:22 pm

Go look up flood fill on Wikipedia. Essentially, whenever you add blocks to the background (either new blocks or blocks that fell), you'll want to flood-fill the areas where they are with a unique identifier. Scan from left to right, doing one column in each frame, and you should be able to fit it easily into the draw period.
Thanks very much, I do think the information is very useful ^_^

Regards,
Sunny

User avatar
Memblers
Site Admin
Posts: 3877
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Post by Memblers » Wed Nov 24, 2004 2:59 am

sunny wrote: Hi, thank you for your suggestion. However, would you mind to give me more information onf NMI (non-masking interrupt). Would you mind telling me the benifit of using it?
In the NES, it's the heartbeat of the PPU.

It triggers during vblank, which is the only time you can freely write to video and sprite memory while the screen is on. Very convenient, though IRQs from some cartridges can be even more useful.

Without any interrupts, you'd have to wait for vblank (or sprite zero) in the main program. The problem there is when the main loop runs longer than one frame (I think it would have to sometimes, with a game like this). Everything would slow down, most noticably the music and sound effects.

An NMI routine could at least give stability to the music, and anything else that's independant enough from the main code.

Post Reply