Skip to main content

Sprites for Walls

·471 words·3 mins

I just found the world boundary shape. Previously I used these huge rectangles to prevent blocks from being dragged outside the viewport. Now I see there’s a better way.

Okay, so better looking walls.

I installed Inkscape and drew my first shape. Took a bit to figure out the nodes… there are corner nodes and smooth nodes and they have different kinds of handles for manipulating them. And there’s a special tool for manipulating those nodes. Once I wrapped my head around that I got a very basic pebble-looking shape.

I figured I better keep it convex otherwise collisions won’t work.

Godot has an amazing feature where it can generate a collision shape for you.

You configure how much detail you need (how many vertices to use) and whether to shrink or grow the outline. I used this video for a rundown on it. https://www.youtube.com/watch?v=Btk8IzhvaDo&t=21s&ab_channel=TheShaggyDev

I started adding walls to the level and it looks, well, uh, horrible.

Limiting myself to convex shapes looks horrible.

Now this method for laying out the walls was inspired by another video I saw a couple weeks ago: https://www.youtube.com/watch?v=y1D4DiZhSIo&ab_channel=JimmyGameDev

I revisited the video and found that he’s using concaves shapes no problem. The collision polygon handles that automatically.

Here’s convex.

Here’s concave.

It breaks up the concave polygon into convex sub-polygons.

So. Back to the drawing board.

New wall:

I arranged this one wall around the borders of the viewport and here’s the result:

It’s not the time for working on the aesthetic right now but I added a little touch of depth.

I just took the wall SVG and expanded the polygon a little bit. My hope was to duplicate each of the twenty or so walls and replace them with the expanded polygons. Unfortunately, there’s no easy way to replace them in the editor so I wrote a little script.

The script iterates over each wall instance and creates an outline instance with the same transformations applied. That child gets a different colour (inherited from its parent). The big downside with doing it in a script is I can’t make corrections to the shapes manually. For example, the little outcropping in the bottom left which shields the light sensor has a very narrow outline. That’s because the scale of that bit of wall is much smaller than all the other bits of wall.

It would also be nice to add some variation to the outline but again, it won’t make sense unless I can do it manually. Maybe if I could write a @tool script to do it right in Godot..?

Better make sure it only executes once!

Wow. I think that’s the first time I’ve run a script in an editor like that. And it was surprisingly easy. Now I’ve got wall outline instances that I can tweak to my heart’s content.