Archived

This topic is now archived and is closed to further replies.

Conceptual help with puzzle game?

This topic is 5603 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''m looking to make a puzzle game as sort of an introduction to game programming for myself, and I''m having trouble conceptualizing how to go about coding it. The game is played on a square grid of tiles and I want to be able to slide a group of blocks around on it. My problem is how to best go about taking a group of blocks and "sliding" them... that is, having them actually move between tiles on the board and not just "jump" from tile to tile. They also need to test for other blocks (or the edge of the board) to stop their slide. This may sound like mere child''s play, but I can''t readily reconcile how to keep track of where blocks are on the grid, and where they are when they''re sliding around. I''m thinking I might need: -A BLOCK data structure -A double array of BLOCK pointers representing the board Any help on this matter is greatly appreciated! It seems very complicated to me right now.

Share this post


Link to post
Share on other sites
You''ll first need a tile map engine, which stores the xy-coordinates of each tile. This can be represented using a 2 dimensional array, which could be used to initialize the position of each tile at the start of the game.

A BLOCK data structure is fine, and could be used to represent the actual block itself, which should contain the index of the picture u used to represent. It should also contain x and y, to tell where the block is or to set it''s position.

So, lets say that each tile is represented in a 4*4 dimension, and u wanna move from MAP[0][0] to MAP[0][4], representation in pixel format could be (0,0) to (0,16). U could then shift the position of the block pixel by pixel, or use some physics formula to simulate force and deceleration.



- there is no difference between reality and fantasy -

Share this post


Link to post
Share on other sites
Thanks for the advice! It makes sense to me.

I decided to keep the rendering of the blocks while they move separate from their placement.

So the board is represented physically by a double array of integers.

int grid[][]

If blocks need to slide, I''ll do all the calculations with integers (representing colors), and then use BLOCK structures for rendering them as they move.

That''s what I finally decided on. Any comments?

Share this post


Link to post
Share on other sites