Rampart style castle walls

Get help using Construct 2

Post » Tue Oct 29, 2013 4:39 pm

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 :).
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Tue Oct 29, 2013 4:53 pm

If it
B
24
S
9
G
7
Posts: 756
Reputation: 7,292

Post » Tue Oct 29, 2013 4:57 pm

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 :)
B
24
S
9
G
7
Posts: 756
Reputation: 7,292

Post » Tue Oct 29, 2013 4:59 pm

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.
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Tue Oct 29, 2013 5:28 pm

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.
B
6
Posts: 14
Reputation: 416

Post » Tue Oct 29, 2013 5:31 pm

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.
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Tue Oct 29, 2013 5:43 pm

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.
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Tue Oct 29, 2013 6:43 pm

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


To be considered as non closed. However there is no way for path finding to get through it.
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Tue Oct 29, 2013 7:05 pm

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.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Tue Oct 29, 2013 7:10 pm

Thanks R0j0hound. I'll give it a whirl
B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Next

Return to How do I....?

Who is online

Users browsing this forum: Held, mikehive, Ninjadoodle, NN81 and 11 guests