Document somewhat, among final (?) tweaks
dkl9

dkl9 commited on 2025-196 23:46:55
Showing 3 changed files, with 31 additions and 4 deletions.

... ...
@@ -0,0 +1,24 @@
1
+voxels is a prototype of a Minecraft-like game.
2
+It was more fun to make than it is to play.
3
+
4
+Dependencies (install with pip as needed):
5
+- PyOpenGL
6
+- PyOpenGL_accelerate
7
+- numpy
8
+- pygame
9
+
10
+To run:
11
+python src/main.py
12
+
13
+If you got a SyntaxError, your Python is too old. Update it.
14
+The game has a few settings, chosen as command-line flags. For details:
15
+python src/main.py --help
16
+
17
+Move the mouse to look around.
18
+Esc/left-click to release/focus the cursor.
19
+Arrow keys, WASD, or <AOE (Dvorak equivalent) to move.
20
+Left-click to break a voxel. Right-click to place a voxel.
21
+Middle-click a voxel to pick its material, or press a number key, 1 to 6.
22
+F to toggle flying/gravity. N to toggle collisions/noclip.
23
+
24
+This is all in Python. Be ready for lag.
... ...
@@ -35,7 +35,7 @@ class Camera:
35 35
 
36 36
     def persp_mat(self):
37 37
         near = 0.1
38
-        far = 100
38
+        far = 250
39 39
         f = 1.0 / np.tan(np.radians(self.fovy) / 2)
40 40
         depth = near - far
41 41
         return vec([
... ...
@@ -17,18 +17,21 @@ def in_view(wr, cam):
17 17
     rwrc = wr.pos + wr.r / 2 - cam.pos
18 18
     close = np.linalg.norm(rwrc) < conf["view-dist"]
19 19
     ld = cam.looking()
20
-    cv = rwrc + 8 * ld
20
+    cv = rwrc + conf["region"] * ld
21 21
     frust = np.dot(cv, ld) / np.linalg.norm(cv) > 0.5
22 22
     return close and frust
23 23
 
24 24
 def main():
25 25
     parser = argparse.ArgumentParser()
26 26
     for (k, v) in conf.items():
27
-        parser.add_argument(f"-{k[0]}", f"--{k}", type=type(v))
27
+        parser.add_argument(
28
+            f"-{k[0]}", f"--{k}",
29
+            type=type(v), default=v,
30
+            help="default %(default)s"
31
+        )
28 32
     args = parser.parse_args()
29 33
     for k in conf:
30 34
         v = getattr(args, k.replace("-", "_"))
31
-        if v is not None:
32 35
         conf[k] = v
33 36
     display.init_display()
34 37
     glUniform4fv(UNIFORMS["lightPos"][2], 1, vec([*LIGHT_POS, 100]))
35 38