Wall Connecting Behavior (to be found in WallConnect Example Actor)

Sunflower

  • Posts: 591
Hello, fellow game creators!
I've been recently working on my first Stencyl game and after many tries and errors managed to make a wall connection system. In other words: after all walls are placed on screen, this system makes them connect in nice way, so that edges are drawn only at the actual border of wall. This is useful when you don't want to place many tiles yourself, each corresponding to certain edge. It turns out to be even more useful, when you don't know how the walls will look at all - which happens with random generated walls or level editors!

You can find it in Stencyl Forge as WallConnect Example Actor! The reason for publishing it as actor rather than behavior is mentioned later.

Generally, when you use my system, there are three things to remember:
1. Animation: there are 13 images to make. They are: 1 for the entire middle of wall, 4 for outer corners, 4 for edges and 4 for inner corners (it should become more clear when checking the animation in example; that's why I decided to upload WallConnect as actor rather than behavior itself).
2. Collision Box: it should have twice the width and the height of animation, and the actual image should be in the left-upper corner. That's because animation frames are only quarters of the complete image. Also, that may be also the reason to use in scenes tiles larger than animation, too (or rather, that's the reason why animation is smaller than tiles).
3. Condition: you need to edit "compare block next to [Self] at [XOff] [YOff]". That's because there are different ways to decide if there's a wall adjacent to the checked part (and if it's the correct wall). Normally it's supposed to return TRUE when there's connectible block next to checked one at tile at [XOff][YOff] relative to position of [Self] (and FALSE otherwise), but you're the one to set the condition determining if block is connectible*.

Also, to make this work, you should add all walls to the scene first (if they weren't already added in Scene editor), and then tell walls to "connect". If you add walls through scene creation code, you can place this command right after that; if walls are placed by scene editor, you may need to call it after short timeout.

If you have any suggestion regarding this example or wall system modifications, please post them here or through forum message system.

*Of course, the main reason behind not adding the typical condition for connectible walls is that I have no idea how to work with Regions, and the condition I use myself is quite unusual.

« Last Edit: July 09, 2011, 11:35:07 am by Sunflower »