Preggo Game Jam progress 2023-05-07
Posted by
I spent all weekend trying to figure out how to make the
perspective look right when scrolling the scenery in flying
levels. It is much, much harder than I expected. The problem of getting a plane into perspective is basically
the problem of mapping coordinates from a rectangle onto a
trapezoid. My initial approach was this: This almost worked. Objects move in the correct
direction in perspective. But the distances are
all wrong. Really, the vertical grid spacing should be much
larger when you're closer to the "camera". I tried to come up with a function to do this mapping
correctly, but it's way over my head and I can't afford to
keep spending time on it. Apparently the correct solution
involves
Homography,
but I'm just not grokking it. As a rough approximation of the correct mapping, I'm
cubing the y position before passing it to the lerp function.
It's not correct, and you can tell that the trees seem to slow
down as they approach the camera, but it's the best I've
managed to do. As you can see in the video, there's an infinite field of
trees that rushes below you. The red lines are there so I can
verify the trees are moving away from the vanishing point
correctly. Tres also have collisions enabled when they're near the
bottom of the screen, so you'll take damage if you get too
close. Still a very long way to go.A weekend of failed math