Categories
Game Design Game Development Geek / Technical

Freshly Squeezed Progress Report: Rendering Doors and Things

In last week’s report, I started work on designing and implementing doors for The Dungeon Under My House, my second Freshly Squeezed Entertainment project.

I got doors to render quite soon after publishing that report, but there were a few tricky things happening that I needed to address.

Sprints 18: Pre-production and initialization

Planned and incomplete:

  • Doors can be opened/closed

The floors and ceilings render one way, the walls render another way, and then I have “things” like doors, which kinda need to act like walls, only they aren’t necessarily at grid edges the way walls are.

It took a little effort, but I was able to render doors in the arbitrary location I wanted them to be in.

The Dungeon Under My House - door rendering

The Dungeon Under My House - door rendering

The Dungeon Under My House - door rendering

The Dungeon Under My House - door rendering

Things need to render from back to front, and so they needed to pay attention to a depth buffer.

Then I needed to make sure that if the door was seen from an angle that it looked like it took space at an angle.

The Dungeon Under My House - door rendering

The Dungeon Under My House - door rendering

This involved interpolating a transform calculation between the hinge side of the door to the far side of the door.

I tried to make sure that the door was not taking up the entire height of the wall, since there is supposed to be a doorframe, and my math never quite worked out, but then I decided to just make the source image for the door itself with transparent pixels at the top to make it easier on me.

The Dungeon Under My House - door rendering

I had some weird glitches in which the door should be behind the player but still sometimes seemed to render in front of the player taking up the entire render area. I am sure there was some math I was not doing right, but at the moment my solution has been partially to hack in exceptions to when it should draw the door. I’m not happy with it, but sometimes it is easier to detect the problem than it is to figure out why the problem was happening.

One remaining challenge has been to fix the fisheye effect I was seeing when the door was drawn from an angle, an effect that was very obvious when the camera turned, since the walls don’t have the same effect.

I recognized that it was happening as a direct result of how I was interpolating the calculated distance between the hinge side and the far side of the door. I needed to use the perpendicular distance to the camera plane rather than the distance directly to the point source of the ray.

Drawing walls involves shooting rays from the leftmost column to the rightmost column, stepping through the grid cells until a wall is hit, then rendering that vertical slice of the wall.

When drawing doors, I can determine which column to start drawing from and which column to end drawing on, and then I interpolate both the source image vertical slices and the target vertical slice to draw it to, but I think I’ll need to modify how those rays are cast to similarly use the camera plane whereas at the moment I don’t.

Another thing I need to do is draw the door from the other side. The code technically could draw it in reverse, and in fact it did, but one of my hack/fixes prevents it now, so I will need to address it.

And of course, making the door functional will be key. There’s no point in having doors if they can’t be opened and closed. Ideally they should animate swinging open. And they should block movement through them in either orientation.

Thanks for reading!

Want to learn when I release The Dungeon Under My House, or about future Freshly Squeezed games I am creating? Sign up for the GBGames Curiosities newsletter, and download the full color Player’s Guides to my existing and future games for free!

One reply on “Freshly Squeezed Progress Report: Rendering Doors and Things”

Comments are closed.