Documentation
¶
Index ¶
Constants ¶
const ( ChunkWidth = 16 ChunkHeight = 256 ChunkDepth = 16 )
The size of the chunk (width, height, and depth), in blocks.
const ( // MaxRenderRadius is the maximum number of chunks ahead of the player which // we can feasibly render. MaxRenderRadius = 32 )
Variables ¶
This section is empty.
Functions ¶
func ToChunkSpace ¶
ToChunkSpace returns the coordinates of the chunk and the block within that chunk that contain the given world-space coordinate.
Types ¶
type BlockInfo ¶
type BlockInfo struct {
Name string // Display name of the block
Visible bool // True if the block actually renders something
Collidable bool // True if the block has a collidable AABB
Transparent bool // True if we can see the block behind at any angle
Texture string // Path to the texture to use for all faces
UV FaceUV // UV coordinates to use for all faces
}
BlockInfo contains the properties of a block type.
type BlocksInfo ¶
type BlocksInfo struct {
Blocks []*BlockInfo
}
BlocksInfo contains the properties of every block type.
type Chunk ¶
type Chunk struct {
Blocks blockData // The cached block data for the chunk
// contains filtered or unexported fields
}
Chunk stores information associated with a chunk, including OpenGL rendering information, block data, vertex data, and lighting data.
type FaceUV ¶
type FaceUV struct {
X, Y float32
}
FaceUV represents the base UV coordinate for a block face in the block texture atlas.
type RenderInfo ¶
RenderInfo stores information required by the world for rendering.
type World ¶
type World struct {
RenderRadius int // Current render distance
// contains filtered or unexported fields
}
World manages the loading, unloading, and rendering of chunks.
func (*World) FindChunk ¶
FindChunk checks to see if the chunk at the given coordinates is already loaded, and if so returns a pointer to it. Otherwise, returns nil.
func (*World) GenChunksAround ¶
GenChunksAround generates all chunks within the render radius around a central chunk (usually the chunk that the player is in).
func (*World) GetBlockInfo ¶
GetBlockInfo returns information about a particular block type.
func (*World) Render ¶
func (w *World) Render(info RenderInfo)
Render draws all loaded chunks with vertex data to the screen.