Trigonometry in Heretic

Heretic was one of the first computer games I came across. I remember that my aunt got a Windows 95 at the time when that was something revolutionary, and we had a CD with several demo games, including Heretic. This is a game of the FPS genre, those in which we have a first-person view and usually only see our weapon/hand, but at the time I still didn’t have the necessary dexterity to move the character, so I was just on the shoot button and my aunt controlled it the character. But shooting monsters was a secondary diversion, what was exciting about this game were the secret passages and traps. Think you’re walking down a hallway and find a powerful weapon… but as soon as you pick up the weapon, the lights go out and we start hearing monsters around you (shortly we start losing life points), or the ceiling starts to descend in our heads… but it also happened that we passed through monotonous places with nothing interesting… there was probably a secret passage there that his lack of curiosity ignored. Anyway, this is a very fun game, which makes you think and gives you some despair and fear peaks, especially when you start to hear the monsters nearby and you have little ammo… At the end of each phase it showed how many monsters there were in the level, how many items and how many secret passages, and how many of each you discovered. This caused a serious frustration of feeling that we missed something, and we kind of retraced the entire itinerary looking for where the secret passage that still needed to be discovered could be.

However, an issue that we have in common with most games of this genre, the fact that we can adjust the character’s aim to the maximum value, but the game does not tell us what this angle is. We can simply accept that this information is not offered to the players, or else, find in elements internal to the gameplay itself, ways to calculate this value. Of course we chose the second option :).

Let’s first draw our situation. We have the character with his weapon pointed at the default height:

When he fires, the shot travels straight to the target.

On the other hand, we can adjust the crosshairs up to the maximum top angle.

When he fires, the shot follows in a straight line to the target (it is important to emphasize here that the trajectory is not parabolic).

That is, the angle we are looking for can be expressed from a right triangle, with opposite side z (given by the difference in heights between the two shots), and adjacent side y (equal to the distance from the character to the target). Knowing these values, we can say that the tangent of this angle x will be z/x.

Well, knowing enough about the game, we can find these values. In this case, this wall is very suitable for what we want, as it is completely formed by isosceles (or almost) right triangles.

Checking where the maximum angle shot hits, we can get an idea of the difference in heights.

But we still need to think of a unit of measurement for our calculations… for that, we’ll use the character’s steps. That is, how much the character moves at the slightest tap on the keyboard. Thus, with 7 little steps we completely pass the section that corresponds to this wall with water. I chose this section specifically because of that, because you can see the change in height when the character goes down into the water, and when he comes out of the water.

So, to make the math easier, I did 10 steps backwards.

Then each half of one of the right triangles, which will also be a right triangle, will have height and base equal to 6/7 steps.

Finally, we estimate the height difference of the shots from these triangles, concluding their height must be 18/7 steps.

So, when we go back to the initial calculations, we can figure out what the angle x should be.

tang(x) = (18/7)/10

tang(x) = 9/35

arctang(9/35) = 14.42º

There are certainly several inaccuracies in our method, as well as the game developers would be unlikely to choose a non-integer angle. So I dare say that the maximum angulation should be 15º.

The interesting thing about this text is not exactly the calculation, as there is nothing new in using sides of a right triangle to find its angle. However, the way in which the information needed to model our triangle was deduced within Heretic’s own gameplay. We therefore invite you to discover this game (you can easily download it or play online) and also to look for other mathematical models within digital games.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *