Jump to content
  • Advertisement
Sign in to follow this  
wthhpe78

Partial Collision Puzzle Game

This topic is 3248 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently working on a 2D puzzle game in the spirit of Super Puzzle Fighter. When similar color blocks combine they will send the said blocks into an excited state, where they act as one unit. The problem I'm having is when this excited state causes the gems to explode, the blocks that subsequently fall as a result are not sensing bottom collision correctly. Since they act as a unit in the excited state I'm looking for a way for them to drop as one unit until one in the unit senses bottom collision or for it to work in such a way that it works without having to define the excited states as a distinct unit. Code for moving a piece down after collision has already been detected: public void DropPieces() { //handles dropping a piece down if only one block specifies bottom collision for (int row = 0; row < GRID_HEIGHT - 1; row++) for (int col = 0; col < GRID_WIDTH; col++) { if (levelGrid[row, col] != -1 && levelGrid[row, col] < GEMMING) { if (levelGrid[row + 1, col] == -1) { int temp = levelGrid[row, col]; levelGrid[row, col] = levelGrid[row + 1, col]; levelGrid[row + 1, col] = temp; } } } }

Share this post


Link to post
Share on other sites
Advertisement
Regarding DropPieces, not sure if the comments mean you are already aware of this, but the vertical iteration goes from top to bottom. This means that even though there may be a gap under a number of blocks, only the one directly above that hole will drop down, because the other blocks still see the undropped block beneath them blocking them.

You could fix this by making the vertical iteration go from bottom to top.

To handle the case where there is more than one gap under a block, you could extend the test in DropPieces to not just look directly beneath a block, but continue looking down underneath the block for a empty place to swap to. Alternatively, you could repeatedly call DropPieces until no pieces have moved in the last call, something like:
while(DropPieces()); // DropPieces returns true if pieces were moved, otherwise false

Also, don't forget to check for a new group of blocks that need to be excited after doing all the block drop actions.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!