Boulders Affect / Movement

0 favourites
From the Asset Store
Boulders
$3.99 USD
A collection of 30+ boulders. Great for side scrollers, platformers, and more!
  • Hi,

    I have recently started making (or trying!) to make some 2D games, having lots of fun on the way but I'm currently total lost on trying to do something with Boulders / rock sprites.

    I'm basically trying to get the same affect that the boulders have on 'Boulderdash' for anybody that has played it.

    Here is a working HTML5 example of that game

    boulderdash.krissz.hu/cave/A8YAEx1vuxvH/boulder1-intro/

    If you notice how the boulders fall to the side if stacked on top of each other and there are gaps to the left or right, that is what I'm trying to achieve.

    I'm new to construct today having given Stencyl a try but could not accomplish the above so going to go through the tutorials on here and see if I can do it.

    If anybody has any advice / tips on doing the above I would be very Grateful.

    Thanks! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • I've done this though not in C2 but here's how I accomplished it loosely based on the original game logic.

    First decide which objects you want the boulders to fall from. I selected boulders and gems. in classic BD they call these objects round.

    assign a boolean var to each rock instance eg isRound and set to false by default.

    Now you'll need to acquaint yourself with the "overlapping at offset" event.

    Say you have a 3x3 grid and your rock is on the middle square.

    123

    4R6

    789

    On start of level for each rock:

    Check if it's overlapping a round object at offset x=0, Y=(1 X tilesize)corresponding to square 8.

    If it is then set the isRound var to true. The rock can now roll

    Make a timed loop

    System every 0.2 seconds

    System for each rock

    add a second condition so it only checks rocks that you permit may fall.

    if isRound is true

    then:

    Check if it's overlapping an object on the square to your left.

    if it is then check if it's overlapping an object on the square to your right.

    If it isn't overlapping anything on the left ie the square is empty then check if it's overlapping anything in the square left one, down one if it isn't then fire the "Roll" function) if it is overlapping at either of those two points try the same thing on the right ie is X overlapping at X + tilesize, Y=Y then X + tilesize, Y + tilesize.

    Back to the square of nine Rock is on 5 you check 4 then 7 if both empty roll rock left if either occupied check 6 then 9 if both empty roll right if either occupied then no roll possible but now is a good time to update the Rock vars as something may have changed since the last time So add an Else:

    Check if it's overlapping a round object at offset x=0, Y=(1 X tilesize)corresponding to square 8. (As at beginning)

    Game has moved all moveable instances and updated all instances to see if they are potentially movable.

    Roll function can be simple movement 1 x tilesize left or right and let gravity do the rest bullet works best.

    Use platform behaviour to detect if a rock is falling or has landed and toggle the isRound var otherwise you'll have rocks dropping off objects you don't want, round only!

    As in BD the same movements can be applied to the diamonds to achieve the correct drop effect for those too.

  • dl.dropboxusercontent.com/u/44710358/Boulder%20dash/boulder%20dash.capx Neller this is not full example but for start making this example

  • Thanks for the replies guys,

    Bertie Booster - thanks for that I will give it a try today, although will need to learn C2 first but shouldn't take me long hopefully :) , but reading what you say makes sense

    delgado - thanks I had a look at that and looks great, the problem for me though is the main thing missing from it is the part I actually can't do (the falling rocks when stacked)

    Again thanks for the fast responses, I will see if I can code something like Bertie Booster mentioned above when I finish work.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah the falling rocks and diamonds like in original game is hardest to do

    i try with physics and platform behavior all dont work perfect for me

  • Here's one way to do the falling rocks:

    https://www.dropbox.com/s/pl1y8rfo3temq ... .capx?dl=1

    /examples21/boulderdash.capx

    It differs from Bertie Booster's idea in that it uses a array for a grid instead of using overlapping at offset.

  • That is a very very nice solution RojoHound, I'm a lover of nailing grid positions with arrays this works very well indeed.

  • Had a look and that looks perfect, thanks R0J0hound

    I will use that with it working so well and just build the game from there, still learning the basics of C2 atm so going to do it as I go.

    Thanks for all your help guys <img src="smileys/smiley1.gif" border="0" align="middle" />

  • R0J0hound you should make great game soon with your skills

  • Here's one way to do the falling rocks:

    https://dl.dropboxusercontent.com/u/542 ... rdash.capx

    It differs from Bertie Booster's idea in that it uses a array for a grid instead of using overlapping at offset.

    your capx is really great R0J0hound and i just finished adapting it to use with a tilemap but it seems my way of looping though the tilemap to find the "rock" tiles is far more cpu intensive then your "for each sprite" loop.

    is there maybe a better way to find the rocks / loop through a tilemap?

    i also tryed the following, but it doesnt make much difference, i think.

  • fldr

    It's more efficient to use for each boulder since it only checks the spaces around the boulders. The only reason to use a tilemap instead is perhaps faster rendering. For that you could make all the sprites invisible and update the tilemap as things are moved.

  • Thanks!

  • does anyone else have this capx from R0J0hound? Can someone do reupload?

  • does anyone else have this capx from R0J0hound? Can someone do reupload?

    R0J0hound is usually happy to renew his dead links. Just make sure to tag him.

  • TheFaith30

    link updated

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