我看了 TheCherno 的游戏编程教程:
http ://www.youtube.com/watch?v=RKPEQfkhbAY
在这一集中,他编写了这段代码来制作 3d 世界。
package game.display.graphics;
public class Render3D extends Render {
public Render3D(int width, int height) {
super(width, height);
}
public void floor() {
for(int y = 0; y < height; y++) {
double ydepth = y - height / 2;
double z = 100.0 / ydepth;
for(int x = 0; x < width; x++) {
double xdepth = x - width / 2;
xdepth *= z;
int xx = (int) (xdepth) & 5;
pixels[x+y*width] = xx * 128;
}
}
}
}
我真的不明白代码..所以有人可以向我解释吗?