How do I push multiple blocks on a grid?

0 favourites
  • 10 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • Intro

    I have a game project similar in scope to a game called "Rodent's Revenge", included with Windows PCs back in the 90s. Not everyone has played this but despite seeming simple on the surface I realize it is not as easy as it seems to create.

    I installed Chess, MoveTo & a number of other plugins by rexrainbow which proved to be very useful in creating this quickly.

    Gameplay

    The player moves around the grid going Up, Down, Left and Right. The player can push blocks at will with no limits on stack size, only the confines of the screen.

    The problem I'm having is that the blocks that the player pushes do not act naturally. Instead of waiting to come in contact with another block, all the blocks along the axis & above the player move as if being moved by themselves.

    What I tried

    Currently, if the Player cannot move Up, then it picks the block that is above them along the Y axis and instructs it to move Up, then move the Player. I am trying to create a recursive or nested loop that tests if THAT block cannot move, and if so, grab the block above that, checking each one until there is a free space, then moving all of them.

    Unfortunately I have failed more than a few times getting my code to grab the correct blocks and move them the right way. I'm hoping anybody who 1) has a solution and 2) has familiarity with these particular plugins (long shot, I know) could push me in the right direction, no pun intended.

    I have further plans for this game, as well as graphics and different game mechanics at the ready, but I feel none of them are worth implementing until the basics work at least.

    CAPX

    Here's a link to the file on Google Drive:

    https://drive.google.com/file/d/1nMMugT-i-ea9h0Jf3py13wAiWzbLxlVN/view?usp=sharing

    Final note: The block pushing in this file only works when moving UP. I made the decision to only work on one direction before I rewrite the code for Down, Left and Right. It needs to work first. THANK YOU!

  • NAF

    I never used these plugins, but decided to give it a try:

    dropbox.com/s/s6t30ngl3u2ezqr/block%20push%20rex.capx

    I also did this only for moving UP, it should be easy enough to modify the function to work for all directions.

  • dop2000,

    WOW. I never would have been able to write this myself. Amazing part is I totally understand it. I knew it had to involve a recursive "keep checking for more blocks" function that ended as soon as an empty space but I didn't know how to implement it.

    I already duplicated & modified your code to make Down work. Only a matter of time before I do left and right. All that needs to be changed is the direction parameter (0-3) and the relative coordinate (block.chess.LX(or Y)+/- 1).

    THANK YOU from the bottom of this Internet stranger's heart.

    Just to prove that I do try in these endeavors I want you to check out a mobile/PC game I finished & released this past Summer:

    https://quartz.naf.nyc

    If you PM me I'll send you a code to download the app if you like the demo. Thanks again.

  • No worries! :)

    I played your game, it's pretty fun! I reached room (level?) 5, but I think after a few rooms it gets a little repetitive. I'm guessing new obstacles and enemies appear on later levels?

    Want to try my latest game? :)

    planetotron.com/Demo

  • Yes, the first 10 or so levels are designed to get the player used to jumping and then the next 70 slowly introduce trap doors, enemies, moving platforms, hazards, and way more complicated stage designs.

    Thanks for trying it out!

    Love the polished quality of your game. Clean graphics alongside a fun concept.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dop2000 thank you for your help. i have learned a whole lot since you showed me some new concepts & now i have a workable demo of what i envisioned this game to be.

    if you want to give it a shot i have it uploaded below.

    again, i really appreciated your expertise.

    https://noapparentfunction.itch.io/topaz

  • Really nice game, I reached level 5! The enemy AI is pretty stupid, it's easy to lure and trap them once you understand how they move. But I'm guessing with more enemies on the level it will become harder and harder to escape from them.

  • NAF

    that is an awesome game!!! very simple concept. but very well done - and way too addictive! :)

    I made it to level 13 once... and level 12 a couple other times.

    at the start of one level, a bad guy spawned right on top of me - and ended the game before the level started.

    and boxes routinely spawned on top of the player... (I am sure you knew that)

    would be nice to be able to start at a higher level.

    after about level 8, the bad guys are very difficult to trap.. (the time I beat level 12 took forever to actually trap all of them after I had confined them to an area where they couldn't get me) but I am not really sure what you can do about that...

    any way - with a little more polish, you will have a fantastic game! Congrats!

  • AllanR

    thanks for playing, seriously!

    i'm thinking about how to handle progression, in the same manner that arcade games do. most arcade games simply get faster, which is easy enough. but i need to figure out how to add more enemies but not making the game unplayable. i have control over how often they move so i have been thinking how to slowly decrease it in a way that is still fair.

    i want the enemy count to scale up, while the interval between their movements scale down. it's a matter of coming up with a good formula.

  • NAF

    I played again today - and made it to level 13 again...

    the speed they move at is working really well - the only serious problem is when you have a bunch of them corralled into a confined area and want to squeeze them in to completely trap them. If you can pick them off one by one it works fine, but that isn't really possible at higher levels since there are so many of them. The one closest to you gets "stuck" because it almost never has room to move, so the square he is on almost never is free to push a box in. And as you move around the outside of your "trap" they follow you inside, so you can't easily push the walls in to finish them off...

    so, either their AI has to change if they are confined, or if they can't move because of other bad guys, they need to be push-able... otherwise, game-play suffers.

    anyway - like I said earlier, you have a great start and it is a lot of fun already! :)

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