fogleman/Craft

A few questions about the code

bztsrc opened this issue · 2 comments

Hi,

First I'd like to say this is pretty amazing piece of code, I like it!
Although there aren't a lot of comments in the source, so I have a few questions if you don't mind.

How does p, q relate to x,y,z in world.c, create_world()?

If I want to make blocks without light source darker, how can I do that? I mean blocks with sunlight and near a shining block is perfect, but those underground without any light are way too bright.

How does the code handle the size of generated world around the player? How can I make it bigger or smaller?

How can I change how much world is rendered around the player?

(Right now it seems that generated and rendered world size is the same. What I have in mind is having a bigger world generated than rendered, so that I can place entire structures into the world without the need of partially rendering them. Let's say the biggest structure I have is 16x16 in size and we render 32x32 blocks around the player, then I'd like to generate 48x48 blocks around the player. How can I do that?)

Thanks!

  1. p, q are chunk coordinates. Each chunk is 32x32 blocks in the flat plane: https://github.com/fogleman/Craft/blob/master/src/config.h#L51

  2. To darken blocks you'll probably need to tweak the block fragment shader: https://github.com/fogleman/Craft/blob/master/shaders/block_fragment.glsl

  3. These constants define how many chunks around the player are loaded, rendered, etc: https://github.com/fogleman/Craft/blob/master/src/config.h#L47-L50

Hi,

Those answered all my questions, so I close this issue.

  1. actually I was able to figure this out, but a few comments would have been nice :-)
  2. thank you!
  3. thanks! I'm planning to replace the render radius constant with a variable, so that I can dynamically decrease the radius if fps drops below 30.

I'd like to say I like your code stile very much. Dependency free as much as possible, no bloat, just the essence. Only if there were a few more comments or an API.md doc, it would be perfect! Thank you very much sharing your code with the world!

Thanks,
bzt