Rampart style castle walls

  • I've had a game idea in my head for a while and I'm about to start putting it together. However the one aspect that has me drawing a blank is the wall building aspect.

    If you check out this video

    http://youtu.be/mKITmnmlzxM?t=1m20s

    You will it's right at the point where the player is rebuilding his castle walls. To stay alive in rampart, you must completely surround a castle with walls. As you can see in the video, as soon as wall is completed, the area of the ground that it surrounds turns blue and we know the game can go on.

    My question is this. If using a variety of pieces to build the wall (like tetris), what is would be the best way to determine if the wall is completed with no breaks?

    I hope I am making sense :).

  • If it

  • If its tilebased, I'd start flooding every non-walled tile starting from the castle and see if flooding makes it to the edge of screen. Basically check if any tiles surrounding flooded tiles are not flooded and flood them. Walls would block flooding. Could be optimized but that might not be necessary :)

  • I'm not familiar with the term flooding. I think I might understand what you mean though. I'll look it up and see if I can find an example.

    Thanks.

  • I have not used pathfinding in CS2 yet, but I think you can try to find a path from inside the castle to a point outside. When the wall is completed you should get some 'no possible path' output from the pathfinder.

  • That's a good idea Jongf7. Thanks.

    I created a really basic layout

    https://www.dropbox.com/s/tgzufmtnwbkmcdu/walls.capx

    When you click a wall is formed (grey box) what I would like is when the walls form a complete square/rectagle then the area inside the walls is changed.

    I'm going to play with the pathfinder. Thanks.

  • OK, I am not familiar with the pathfinding behavior at all, so I am bit confused as to why my latest capx isn't working.

    Any help would be greatly appreciated. I'm going to go play around with pathfinding and figure out why my character just goes right through all the solid obstacles.

  • Well, path finding won't work. Was a really good idea though. The reason it won't work is because I want this:

    <img src="http://content.screencast.com/users/ArcadEd/folders/Jing/media/609e18c6-3bdd-4867-9f21-23c42ad867d4/2013-10-29_1141.png" border="0" />

    To be considered as non closed. However there is no way for path finding to get through it.

  • Here is an example somewhat following vee41's idea of using a flood fill:

    https://dl.dropboxusercontent.com/u/5426011/examples19/wall_build.capx

    In a nutshell it marks every grid as EMPTY then marks all grids with walls as FILLED. After that an eight direction flood fill is done starting at the top left corner (0,0), and finally the grid array is looped over and any grid positions still EMPTY are enclosed and can be drawn blue.

    It has a lot of room for improvement but should give a basic overview of the concept.

  • Thanks R0j0hound. I'll give it a whirl

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That works great. The only thing off is if you put a wall at 0,0, then everything fills. Should not be an issue though. Thanks again.

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