0
\$\begingroup\$

I'm trying to teach myself to program some basic engines. I've been following this tutorial: http://www.playfuljs.com/a-first-person-engine-in-265-lines/ to get a decent idea of a basic way to render objects.

I'm confused, though, about certain items. I remember that in JavaScript, one must declare and define variables and objects, to me it doesn't seem like this programmer defines objects and methods like "column" and "step". For example, when he tries to find a ray's angle, he has these three lines of code:

var x = column / this.resolution - 0.5;
var angle = Math.atan2(x, this.focalLength);
var ray = map.cast(player, player.direction + angle, this.range);

The problem is, I'm trying to connect the dots and see how he defines "column", "angle", and "ray" and how they fit into the code at large, but in his tutorial I don't see those definitions everywhere! So I have no idea how this code seems to fit together. Is there something I'm missing? Some library or built-in stuff with Javascript?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

The code snippets provided in this article are not correct programs, but just short extracts. They won't work on their own, they require to be put together with other pieces of code to make sense. The author of the article highlights the interesting parts of the source code, and does not cite the parts that would be uninteresting for the target audience, which - in this case - are programmers with significant experience in javascript and graphical engines.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .