How to read/adapt coding style that look like this

Started by
21 comments, last by TheChubu 10 years, 10 months ago

So I am watching this video of Notch coding Minecraft.

His coding style is bizarre to me. I seen other open source game projects that have

straightforward code.

I will type a sample code from the video for clarity.

Timecode for the video for this code is 1:05.

Vec3.newTemp(target.x + target.xd * time, target.y + target.yd*time,target.z + target.zd * time);

He does not have comments in his code so I am not sure how the developers would follow the code.

Source:

Advertisement

Looks like a change in new 3D position over based on time. Probably called every update or so.

Vec3: 3 valued vector.

Target.*: Target's current coordinates

Target.*d: Delta change for each value

time: elapsed time since last update

Looks like a change in new 3D position over based on time. Probably called every update or so.

Vec3: 3 valued vector.

Target.*: Target's current coordinates

Target.*d: Delta change for each value

time: elapsed time since last update

Thanks DragonSoulj! It makes a lot of sense now!

It makes sense that the code he's actively working on doesn't have comments yet. He's adding an experimental feature and the code is changing a lot.

From what I saw of the few frames where the code is in focus, his coding style seems fine to me.


Thanks DragonSoulj! It makes a lot of sense now!

wink.png Helps to know X, Y, and Z are 3D planes (X and Y for 2D), and a point in the 3D space needs a value of each. A change of something is a delta, hence the D.

Thanks DragonSoulj! It makes a lot of sense now!


wink.png Helps to know X, Y, and Z are 3D planes (X and Y for 2D), and a point in the 3D space needs a value of each. A change of something is a delta, hence the D.


The word is "coordinates", not "planes".
I guess it depends on experience? I looked at that line and it made perfect sense to me. "Vec3" tells me to expect x,y and z coordinates. A "d" in the variable name tells me it is a delta variable. He's constructing a new vector from an old vector, while translating it by delta values scaled by time. Without looking at the video, I would say this is part of a 3D animation system.

Of course, it strikes me as a bit of a WTF that his vector class doesn't support vector add and multiply operations.

They would make it a lot easier to read...

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

I guess it depends on experience? I looked at that line and it made perfect sense to me. "Vec3" tells me to expect x,y and z coordinates. A "d" in the variable name tells me it is a delta variable. He's constructing a new vector from an old vector, while translating it by delta values scaled by time. Without looking at the video, I would say this is part of a 3D animation system.

Where is the new vector going? It's not assigning a return value to anything. I wonder, is in unfinished code, or does Minecraft have global / thread local temp variables to avoid allocations?


The word is "coordinates", not "planes".

Actually, I believe those are coordinate planes as I am referring to the whole. His .x, .y, and .z are coordinates on those planes.

This topic is closed to new replies.

Advertisement