Puzzle "Push" Mechanic

0 favourites
  • 10 posts
From the Asset Store
An amazing and interesting puzzle game for kids!
  • Hey all,

    I am making a puzzle game wherein pieces are moving through a grid maze and the player eliminates them by selecting them when they have aligned. Pieces are constantly being added to the grid "pushing" the pieces in front of them forward. Therefore, if you have eliminated some pieces in the middle of the grid, pieces "further down the line" shouldn't move until the empty grid spaces have been filled. Unfortunately, I don't know a way to implement this, short of trying some sort of physics situation (which I feel might over complicate the matter). Does anyone know of a simple way to do this?

    Thanks!!

    Capx

  • Tricky..

    In my mind something like detect what rows the tiles are on. When one is removed, if it's on a row moving right then detect if there are tiles on the same row with a greater X than the empty slot, stop these from moving until the slot is occupied.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I think I get what you're saying, but I'm not sure how I would go about implementing it.

    I had originally thought that I could try and have each tile detect whether or not there was a tile "behind" it relative to the direction it was traveling, but I can't figure out how I could get that to then affect every tile "ahead" of the tile that has been triggered as "stopped".

    Anybody have any thoughts on this?

  • I had a think and possibly a better idea...give them IDs starting from 0 and counting up. When one is removed randomly from the middle of the queue i.e. it has ID #3, disable the movement logic for anything with a lower ID number. This will work better as I realised that you will probably need to halt tiles on other rows. So if the tiles are lined up as 5 4 3 2 1 0 and you remove 3, it appears as 5 4 [ ] 2 1 0, you stop 2 1 0 from moving and it would end up 5 4 2 1 0 eventually. I didn't look in detail at how you were doing the movement but I could see co-ord type logic so just disable that. You should be able to easily compare an instance variable and run a foreach function for every object that has a lower ID.

  • When making a grid-based game like this, it's generally not a bad idea to run the game logic using arrays.

    Your game pieces would be represented by different values and you could then just loop through every cell and move the value to the next one until there is an empty(0) cell.

  • I think this might work, as I'm hoping to have several different layouts, so I am hesitant to make the logic to reliant on the level layout. I suppose I'll have to look more into how UID's work, unless there's a better way to go about assigning id's to sprites?

    PixelRebirth I'm not sure how I'd go about using matrices for this, but I do have some experience using them. Would I be able to use it with different level layouts?

    Thank you so much for the quick and helpful responses!!

  • Arrays don't pose any particular problem I can think of when used in multiple layouts. Your game logic would likely work in an event sheet included in all of your level layouts.

    Maybe I'll make a little example later to better illustrate what I'm getting at.

  • Here is an example of what I was talking about:

    https://dl.dropboxusercontent.com/u/2306601/pushArray.capx

    I decided to use a 1-dimensional array that basically just contains a long continuous list of your game pieces (or rather values that represent the pieces of course).

    Made a couple of functions to push a new value into the array and then to actually draw the playfield. Hope it gives you an idea.

  • PixelRebirth

    Nice! I really should look into arrays a bit more..

  • PixelRebirth Wow, that's exactly what I was trying for! Thank you so much!!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)